25 #ifndef __MOTR_LIB_BOB_H__ 26 #define __MOTR_LIB_BOB_H__ 111 #define M0_BOB_DEFINE(scope, bob_type, type) \ 112 scope void type ## _bob_init(struct type *bob) \ 114 m0_bob_init(bob_type, bob); \ 117 scope void type ## _bob_fini(struct type *bob) \ 119 m0_bob_fini(bob_type, bob); \ 122 scope M0_UNUSED bool type ## _bob_check(const struct type *bob) \ 124 return m0_bob_check(bob_type, bob); \ 127 struct __ ## type ## _semicolon_catcher 129 #define M0_BOB_DECLARE(scope, type) \ 130 scope void type ## _bob_init(struct type *bob); \ 131 scope void type ## _bob_fini(struct type *bob); \ 132 scope bool type ## _bob_check(const struct type *bob) 140 #define bob_of(ptr, type, field, bt) \ 142 void *__ptr = (void *)(ptr); \ 145 M0_ASSERT(__ptr != NULL); \ 146 __amb = container_of(__ptr, type, field); \ 148 M0_ASSERT_INFO(m0_bob_check(bt, __amb), \ 149 "%s.%s [%p->%p (%s)] got: %" PRIx64 " want: %" PRIx64 \ 150 " check: %i.", (bt)->bt_name, #field, __ptr, __amb, #type, \ 151 *((uint64_t *)(((void *)__amb) + (bt)->bt_magix_offset)), \ 153 (bt)->bt_check != NULL ? (bt)->bt_check(__amb) : -1); \
M0_INTERNAL void m0_bob_init(const struct m0_bob_type *bt, void *bob)
M0_INTERNAL void m0_bob_fini(const struct m0_bob_type *bt, void *bob)
bool(* bt_check)(const void *bob)
M0_INTERNAL void m0_bob_type_tlist_init(struct m0_bob_type *bt, const struct m0_tl_descr *td)
M0_INTERNAL bool m0_bob_check(const struct m0_bob_type *bt, const void *bob)