24 #ifndef __MOTR_BE_LIST_H__ 25 #define __MOTR_BE_LIST_H__ 28 #include "format/format_xc.h" 184 #define M0_BE_LIST_DESCR(name, amb_type, link_field, magic_field, \ 185 link_magic, head_magic) \ 188 .bld_link_offset = offsetof(amb_type, link_field), \ 189 .bld_link_magic_offset = offsetof(amb_type, magic_field), \ 190 .bld_link_magic = link_magic, \ 191 .bld_head_magic = head_magic, \ 192 .bld_container_size = sizeof(amb_type), \ 194 M0_BASSERT(M0_HAS_TYPE(M0_FIELD_VALUE(amb_type, link_field), \ 195 struct m0_be_list_link)); \ 196 M0_BASSERT(M0_HAS_TYPE(M0_FIELD_VALUE(amb_type, magic_field), \ 202 #define M0_BE_LIST_DESCR_DEFINE(name, hname, scope, amb_type, link_field, \ 203 magic_field, link_magic, head_magic) \ 204 scope const struct m0_be_list_descr name ## _be_list_d = \ 205 M0_BE_LIST_DESCR(hname, amb_type, link_field, magic_field, \ 206 link_magic, head_magic) 211 #define M0_BE_LIST_DECLARE(name, scope, amb_type) \ 213 scope void name ## _be_list_credit(enum m0_be_list_op optype, \ 215 struct m0_be_tx_credit *accum); \ 216 scope void name ## _be_list_create(struct m0_be_list *blist, \ 217 struct m0_be_tx *tx); \ 218 scope void name ## _be_list_destroy(struct m0_be_list *blist, \ 219 struct m0_be_tx *tx); \ 220 scope bool name ## _be_list_is_empty(struct m0_be_list *blist); \ 221 scope void name ## _be_tlink_create(amb_type *obj, \ 222 struct m0_be_tx *tx); \ 223 scope void name ## _be_tlink_destroy(amb_type *obj, \ 224 struct m0_be_tx *tx); \ 225 scope amb_type *name ## _be_list_tail(struct m0_be_list *blist); \ 226 scope amb_type *name ## _be_list_head(struct m0_be_list *blist); \ 227 scope amb_type *name ## _be_list_prev(struct m0_be_list *blist, \ 228 const amb_type *obj); \ 229 scope amb_type *name ## _be_list_next(struct m0_be_list *blist, \ 230 const amb_type *obj); \ 231 scope void name ## _be_list_add(struct m0_be_list *blist, \ 232 struct m0_be_tx *tx, \ 234 scope void name ## _be_list_add_after(struct m0_be_list *blist, \ 235 struct m0_be_tx *tx, \ 237 amb_type *obj_new); \ 238 scope void name ## _be_list_add_before(struct m0_be_list *blist, \ 239 struct m0_be_tx *tx, \ 241 amb_type *obj_new); \ 242 scope void name ## _be_list_add_tail(struct m0_be_list *blist, \ 243 struct m0_be_tx *tx, \ 245 scope void name ## _be_list_del(struct m0_be_list *blist, \ 246 struct m0_be_tx *tx, \ 253 #define M0_BE_LIST_DEFINE(name, scope, amb_type) \ 255 scope M0_UNUSED void name ## _be_list_credit(enum m0_be_list_op optype, \ 257 struct m0_be_tx_credit *accum) \ 259 m0_be_list_credit(optype, nr, accum); \ 262 scope M0_UNUSED void name ## _be_list_create(struct m0_be_list *blist, \ 263 struct m0_be_tx *tx) \ 265 m0_be_list_create(blist, &name ## _be_list_d, tx); \ 268 scope M0_UNUSED void name ## _be_list_destroy(struct m0_be_list *blist, \ 269 struct m0_be_tx *tx) \ 271 m0_be_list_destroy(blist, &name ## _be_list_d, tx); \ 274 scope M0_UNUSED bool name ## _be_list_is_empty(struct m0_be_list *blist) \ 276 return m0_be_list_is_empty(blist, &name ## _be_list_d); \ 279 scope M0_UNUSED void name ## _be_tlink_create(amb_type *obj, \ 280 struct m0_be_tx *tx) \ 282 m0_be_tlink_create(obj, &name ## _be_list_d, tx); \ 285 scope M0_UNUSED void name ## _be_tlink_destroy(amb_type *obj, \ 286 struct m0_be_tx *tx) \ 288 m0_be_tlink_destroy(obj, &name ## _be_list_d, tx); \ 291 scope M0_UNUSED amb_type *name ## _be_list_tail(struct m0_be_list *blist) \ 293 return (amb_type *)m0_be_list_tail(blist, &name ## _be_list_d); \ 296 scope M0_UNUSED amb_type *name ## _be_list_head(struct m0_be_list *blist) \ 298 return (amb_type *)m0_be_list_head(blist, &name ## _be_list_d); \ 301 scope M0_UNUSED amb_type *name ## _be_list_prev(struct m0_be_list *blist, \ 302 const amb_type *obj) \ 304 return (amb_type *)m0_be_list_prev(blist, &name ## _be_list_d, obj); \ 307 scope M0_UNUSED amb_type *name ## _be_list_next(struct m0_be_list *blist, \ 308 const amb_type *obj) \ 310 return (amb_type *)m0_be_list_next(blist, &name ## _be_list_d, obj); \ 313 scope M0_UNUSED void name ## _be_list_add(struct m0_be_list *blist, \ 314 struct m0_be_tx *tx, \ 317 m0_be_list_add(blist, &name ## _be_list_d, tx, obj); \ 320 scope M0_UNUSED void name ## _be_list_add_after(struct m0_be_list *blist, \ 321 struct m0_be_tx *tx, \ 325 m0_be_list_add_after(blist, &name ## _be_list_d, tx, obj, obj_new); \ 328 scope M0_UNUSED void name ## _be_list_add_before(struct m0_be_list *blist, \ 329 struct m0_be_tx *tx, \ 333 m0_be_list_add_before(blist, &name ## _be_list_d, tx, obj, obj_new); \ 336 scope M0_UNUSED void name ## _be_list_add_tail(struct m0_be_list *blist, \ 337 struct m0_be_tx *tx, \ 340 m0_be_list_add_tail(blist, &name ## _be_list_d, tx, obj); \ 343 scope M0_UNUSED void name ## _be_list_del(struct m0_be_list *blist, \ 344 struct m0_be_tx *tx, \ 347 m0_be_list_del(blist, &name ## _be_list_d, tx, obj); \ 350 struct __ ## name ## __be_list_terminate_me_with_a_semicolon { ; } 358 #define m0_be_list_for(name, head, obj) \ 360 const struct m0_be_list_descr *__descr = &name ## _be_list_d; \ 362 struct m0_be_list *__head = (head); \ 364 for (obj = m0_be_list_head(__head, __descr); \ 366 ((void)(__bl = m0_be_list_next(__head, __descr, obj)), true); \ 369 #define m0_be_list_endfor ;(void)__bl; } while (0) 371 #define m0_be_list_forall(name, var, head, ...) \ 375 m0_be_list_for(name, head, var) { \ 376 if (!({ __VA_ARGS__ ; })) \ 378 } m0_be_list_endfor; \
M0_INTERNAL void * m0_be_list_tail(struct m0_be_list *blist, const struct m0_be_list_descr *descr)
M0_INTERNAL void m0_be_list_del(struct m0_be_list *blist, const struct m0_be_list_descr *descr, struct m0_be_tx *tx, void *obj)
M0_INTERNAL void * m0_be_list_head(struct m0_be_list *blist, const struct m0_be_list_descr *descr)
m0_be_list_format_version
M0_INTERNAL void m0_be_list_create(struct m0_be_list *blist, const struct m0_be_list_descr *descr, struct m0_be_tx *tx)
M0_INTERNAL void m0_be_list_add(struct m0_be_list *blist, const struct m0_be_list_descr *descr, struct m0_be_tx *tx, void *obj)
enum m0_be_list_op M0_XCA_DOMAIN
M0_INTERNAL void * m0_be_list_next(struct m0_be_list *blist, const struct m0_be_list_descr *descr, const void *obj)
size_t bld_container_size
M0_INTERNAL void m0_be_list_add_tail(struct m0_be_list *blist, const struct m0_be_list_descr *descr, struct m0_be_tx *tx, void *obj)
M0_INTERNAL void m0_be_tlink_create(void *obj, const struct m0_be_list_descr *descr, struct m0_be_tx *tx)
struct m0_be_list_link * bll_prev
M0_INTERNAL void * m0_be_list_prev(struct m0_be_list *blist, const struct m0_be_list_descr *descr, const void *obj)
M0_INTERNAL void m0_be_list_add_before(struct m0_be_list *blist, const struct m0_be_list_descr *descr, struct m0_be_tx *tx, void *obj, void *obj_new)
M0_INTERNAL void m0_be_tlink_destroy(void *obj, const struct m0_be_list_descr *descr, struct m0_be_tx *tx)
M0_INTERNAL void m0_be_list_add_after(struct m0_be_list *blist, const struct m0_be_list_descr *descr, struct m0_be_tx *tx, void *obj, void *obj_new)
struct m0_be_list_link * blh_head
M0_INTERNAL bool m0_be_list_is_empty(struct m0_be_list *blist, const struct m0_be_list_descr *descr)
int bld_link_magic_offset
struct m0_format_header bl_format_header
struct m0_format_footer bl_format_footer
struct m0_be_list_link * blh_tail
struct m0_be_list_head bl_head
static struct m0_be_ut_backend be
M0_INTERNAL void m0_be_list_credit(enum m0_be_list_op optype, m0_bcount_t nr, struct m0_be_tx_credit *accum)
M0_INTERNAL void m0_be_list_destroy(struct m0_be_list *blist, const struct m0_be_list_descr *descr, struct m0_be_tx *tx)
struct m0_be_list_link * bll_next