25 #ifndef __MOTR_LIB_TLIST_H__ 26 #define __MOTR_LIB_TLIST_H__ 29 #include "lib/list_xc.h" 231 #define M0_TL_DESCR(name, ambient_type, link_field, link_magic_field, \ 232 link_magic, head_magic) \ 235 .td_link_offset = offsetof(ambient_type, link_field), \ 236 .td_link_magic_offset = offsetof(ambient_type, link_magic_field), \ 237 .td_link_magic = link_magic, \ 238 .td_head_magic = head_magic, \ 239 .td_container_size = sizeof(ambient_type) \ 242 M0_BASSERT(M0_HAS_TYPE(M0_FIELD_VALUE(ambient_type, link_field), \ 244 M0_BASSERT(M0_HAS_TYPE(M0_FIELD_VALUE(ambient_type, link_magic_field), \ 284 bool (*
check)(
const void *,
void *),
435 #define m0_tlist_for(descr, head, obj) \ 438 const struct m0_tl *__head = (head); \ 440 for (obj = m0_tlist_head(descr, __head); \ 442 ((void)(__tl = m0_tlist_next(descr, __head, obj)), true); \ 448 #define m0_tlist_endfor ;(void)__tl; } while (0) 458 #define m0_tlist_forall(descr, var, head, ...) \ 462 m0_tlist_for(descr, head, var) { \ 463 if (!({ __VA_ARGS__ ; })) \ 469 #define M0_TL_DESCR_DECLARE(name, scope) \ 470 scope const struct m0_tl_descr name ## _tl 495 #define M0_TL_DECLARE(name, scope, amb_type) \ 497 scope void name ## _tlist_init(struct m0_tl *head); \ 498 scope void name ## _tlist_fini(struct m0_tl *head); \ 499 scope void name ## _tlink_init(amb_type *amb); \ 500 scope bool name ## _tlist_invariant(const struct m0_tl *head); \ 501 scope bool name ## _tlist_invariant_ext(const struct m0_tl *head, \ 502 bool (*check)(const amb_type *, \ 504 scope bool name ## _tlist_is_empty(const struct m0_tl *list); \ 505 scope void name ## _tlink_init_at(amb_type *amb, struct m0_tl *head); \ 506 scope void name ## _tlink_init_at_tail(amb_type *amb, struct m0_tl *head);\ 507 scope void name ## _tlink_fini(amb_type *amb); \ 508 scope void name ## _tlink_del_fini(amb_type *amb); \ 509 scope bool name ## _tlist_is_empty(const struct m0_tl *list); \ 510 scope bool name ## _tlink_is_in (const amb_type *amb); \ 511 scope bool name ## _tlist_contains(const struct m0_tl *list, \ 512 const amb_type *amb); \ 513 scope size_t name ## _tlist_length(const struct m0_tl *list); \ 514 scope void name ## _tlist_add(struct m0_tl *list, amb_type *amb); \ 515 scope void name ## _tlist_add_tail(struct m0_tl *list, amb_type *amb); \ 516 scope void name ## _tlist_add_after(amb_type *amb, amb_type *next); \ 517 scope void name ## _tlist_add_before(amb_type *amb, amb_type *next); \ 518 scope void name ## _tlist_del(amb_type *amb); \ 519 scope void name ## _tlist_remove(amb_type *amb); \ 520 scope void name ## _tlist_move(struct m0_tl *list, amb_type *amb); \ 521 scope void name ## _tlist_move_tail(struct m0_tl *list, amb_type *amb); \ 522 scope amb_type *name ## _tlist_head(const struct m0_tl *list); \ 523 scope amb_type *name ## _tlist_pop(const struct m0_tl *list); \ 524 scope amb_type *name ## _tlist_tail(const struct m0_tl *list); \ 525 scope amb_type *name ## _tlist_next(const struct m0_tl *list, \ 526 const amb_type *amb); \ 527 scope amb_type *name ## _tlist_prev(const struct m0_tl *list, \ 530 #define __AUN __attribute__((unused)) 535 #define M0_TL_DESCR_DEFINE(name, hname, scope, amb_type, amb_link_field, \ 536 amb_magic_field, amb_magic, head_magic) \ 537 scope const struct m0_tl_descr name ## _tl = M0_TL_DESCR(hname, \ 550 #define M0_TL_DEFINE(name, scope, amb_type) \ 552 scope __AUN void name ## _tlist_init(struct m0_tl *head) \ 554 m0_tlist_init(&name ## _tl, head); \ 557 scope __AUN void name ## _tlist_fini(struct m0_tl *head) \ 559 m0_tlist_fini(&name ## _tl, head); \ 562 scope __AUN void name ## _tlink_init(amb_type *amb) \ 564 m0_tlink_init(&name ## _tl, amb); \ 567 scope __AUN void name ## _tlink_init_at(amb_type *amb, struct m0_tl *head) \ 569 m0_tlink_init_at(&name ## _tl, amb, head); \ 572 scope __AUN void name ## _tlink_init_at_tail(amb_type *amb, struct m0_tl *head) \ 574 m0_tlink_init_at_tail(&name ## _tl, amb, head); \ 577 scope __AUN void name ## _tlink_fini(amb_type *amb) \ 579 m0_tlink_fini(&name ## _tl, amb); \ 582 scope __AUN void name ## _tlink_del_fini(amb_type *amb) \ 584 m0_tlink_del_fini(&name ## _tl, amb); \ 587 scope __AUN bool name ## _tlist_invariant(const struct m0_tl *list) \ 589 return m0_tlist_invariant(&name ## _tl, list); \ 592 scope __AUN bool name ## _tlist_invariant_ext(const struct m0_tl *list, \ 593 bool (*check)(const amb_type *,\ 594 void *), void *datum) \ 596 return m0_tlist_invariant_ext(&name ## _tl, list, \ 597 (bool (*)(const void *, void *))check, datum); \ 600 scope __AUN bool name ## _tlist_is_empty(const struct m0_tl *list) \ 602 return m0_tlist_is_empty(&name ## _tl, list); \ 605 scope __AUN bool name ## _tlink_is_in (const amb_type *amb) \ 607 return m0_tlink_is_in(&name ## _tl, amb); \ 610 scope __AUN bool name ## _tlist_contains(const struct m0_tl *list, \ 611 const amb_type *amb) \ 613 return m0_tlist_contains(&name ## _tl, list, amb); \ 616 scope __AUN size_t name ## _tlist_length(const struct m0_tl *list) \ 618 return m0_tlist_length(&name ## _tl, list); \ 621 scope __AUN void name ## _tlist_add(struct m0_tl *list, amb_type *amb) \ 623 m0_tlist_add(&name ## _tl, list, amb); \ 626 scope __AUN void name ## _tlist_add_tail(struct m0_tl *list, amb_type *amb) \ 628 m0_tlist_add_tail(&name ## _tl, list, amb); \ 631 scope __AUN void name ## _tlist_add_after(amb_type *amb, amb_type *next) \ 633 m0_tlist_add_after(&name ## _tl, amb, next); \ 636 scope __AUN void name ## _tlist_add_before(amb_type *amb, amb_type *next) \ 638 m0_tlist_add_before(&name ## _tl, amb, next); \ 641 scope __AUN void name ## _tlist_del(amb_type *amb) \ 643 m0_tlist_del(&name ## _tl, amb); \ 646 scope __AUN void name ## _tlist_remove(amb_type *amb) \ 648 m0_tlist_remove(&name ## _tl, amb); \ 651 scope __AUN void name ## _tlist_move(struct m0_tl *list, amb_type *amb) \ 653 m0_tlist_move(&name ## _tl, list, amb); \ 656 scope __AUN void name ## _tlist_move_tail(struct m0_tl *list, amb_type *amb) \ 658 m0_tlist_move_tail(&name ## _tl, list, amb); \ 661 scope __AUN amb_type *name ## _tlist_head(const struct m0_tl *list) \ 663 return (amb_type *)m0_tlist_head(&name ## _tl, list); \ 666 scope __AUN amb_type *name ## _tlist_pop(const struct m0_tl *list) \ 668 return (amb_type *)m0_tlist_pop(&name ## _tl, list); \ 671 scope __AUN amb_type *name ## _tlist_tail(const struct m0_tl *list) \ 673 return (amb_type *)m0_tlist_tail(&name ## _tl, list); \ 676 scope __AUN amb_type *name ## _tlist_next(const struct m0_tl *list, \ 677 const amb_type *amb) \ 679 return (amb_type *)m0_tlist_next(&name ## _tl, list, amb); \ 682 scope __AUN amb_type *name ## _tlist_prev(const struct m0_tl *list, \ 683 const amb_type *amb) \ 685 return (amb_type *)m0_tlist_prev(&name ## _tl, list, amb); \ 688 struct __ ## name ## _terminate_me_with_a_semicolon { ; } 695 #define m0_tl_for(name, head, obj) m0_tlist_for(& name ## _tl, head, obj) 700 #define m0_tl_endfor m0_tlist_endfor 708 #define m0_tl_teardown(name, head, obj) \ 709 while (((obj) = name ## _tlist_pop(head)) != NULL) 735 #define m0_tl_forall(name, var, head, ...) \ 737 typeof (name ## _tlist_head(NULL)) var; \ 739 m0_tl_for(name, head, var) { \ 740 if (!({ __VA_ARGS__ ; })) \ 757 #define m0_tl_find(name, var, head, ...) \ 759 typeof (name ## _tlist_head(NULL)) var; \ 761 m0_tl_for(name, head, var) { \ 762 if (({ __VA_ARGS__ ; })) \ 774 #define m0_tl_exists(name, var, head, ...) \ 775 (!m0_tl_forall(name, var, head, !({ __VA_ARGS__ ; }))) 791 #define m0_tl_reduce(name, var, head, init, exp) \ 793 typeof (name ## _tlist_head(NULL)) var; \ 794 typeof(init) __accum = (init); \ 796 m0_tl_for(name, head, var) { \ 797 __accum = __accum exp; \ 818 #define m0_tl_fold(name, var, accum, head, init, exp) \ 820 typeof (name ## _tlist_head(NULL)) var; \ 821 typeof(init) accum = (init); \ 823 m0_tl_for(name, head, var) { \
static struct m0_list list
void * m0_tlist_head(const struct m0_tl_descr *d, const struct m0_tl *list)
M0_INTERNAL void m0_tlist_add_before(const struct m0_tl_descr *d, void *obj, void *new)
M0_INTERNAL void m0_tlist_add(const struct m0_tl_descr *d, struct m0_tl *list, void *obj)
M0_INTERNAL void m0_tlist_init(const struct m0_tl_descr *d, struct m0_tl *list)
M0_INTERNAL void m0_tlist_fini(const struct m0_tl_descr *d, struct m0_tl *list)
M0_INTERNAL bool m0_tlist_is_empty(const struct m0_tl_descr *d, const struct m0_tl *list)
M0_INTERNAL void m0_tlist_del(const struct m0_tl_descr *d, void *obj)
M0_INTERNAL void * m0_tlist_prev(const struct m0_tl_descr *d, const struct m0_tl *list, const void *obj)
M0_INTERNAL void m0_tlink_fini(const struct m0_tl_descr *d, void *obj)
void * m0_tlist_next(const struct m0_tl_descr *d, const struct m0_tl *list, const void *obj)
M0_INTERNAL void m0_tlist_remove(const struct m0_tl_descr *d, void *obj)
M0_INTERNAL void m0_tlist_move_tail(const struct m0_tl_descr *d, struct m0_tl *list, void *obj)
M0_INTERNAL size_t m0_tlist_length(const struct m0_tl_descr *d, const struct m0_tl *list)
M0_INTERNAL void m0_tlink_init(const struct m0_tl_descr *d, void *obj)
M0_INTERNAL bool m0_tlink_is_in(const struct m0_tl_descr *d, const void *obj)
M0_INTERNAL void m0_tlink_init_at_tail(const struct m0_tl_descr *d, void *obj, struct m0_tl *list)
M0_INTERNAL bool m0_tlist_invariant(const struct m0_tl_descr *d, const struct m0_tl *list)
struct m0_list_link t_link
M0_INTERNAL void m0_tlink_init_at(const struct m0_tl_descr *d, void *obj, struct m0_tl *list)
void check(struct workload *w)
M0_INTERNAL void * m0_tlist_pop(const struct m0_tl_descr *d, const struct m0_tl *list)
struct m0_tl_descr M0_XCA_DOMAIN(be)
M0_INTERNAL void m0_tlist_move(const struct m0_tl_descr *d, struct m0_tl *list, void *obj)
M0_INTERNAL void m0_tlist_add_after(const struct m0_tl_descr *d, void *obj, void *new)
M0_INTERNAL void * m0_tlist_tail(const struct m0_tl_descr *d, const struct m0_tl *list)
M0_INTERNAL bool m0_tlist_contains(const struct m0_tl_descr *d, const struct m0_tl *list, const void *obj)
M0_INTERNAL bool m0_tlink_invariant(const struct m0_tl_descr *d, const void *obj)
M0_INTERNAL void m0_tlist_add_tail(const struct m0_tl_descr *d, struct m0_tl *list, void *obj)
static struct m0_be_ut_backend be
M0_INTERNAL bool m0_tlist_invariant_ext(const struct m0_tl_descr *d, const struct m0_tl *list, bool(*check)(const void *, void *), void *datum)
M0_INTERNAL void m0_tlink_del_fini(const struct m0_tl_descr *d, void *obj)