26 #ifndef __MOTR_LIB_LOCKERS_H__ 27 #define __MOTR_LIB_LOCKERS_H__ 87 #define M0_LOCKERS_DECLARE(scope, name, max) \ 88 M0_LOCKERS__DECLARE(scope, name, name, max) 90 #define M0_LOCKERS__DECLARE(scope, name, amb, max) \ 93 enum { M0_LOCKERS_ ## name ## _max = (max) }; \ 95 struct name ## _lockers { \ 96 struct m0_lockers __base; \ 97 void *__slots[(max)]; \ 100 M0_BASSERT(offsetof(struct name ## _lockers, __slots[0]) == \ 101 offsetof(struct m0_lockers, loc_slots[0])); \ 103 scope void name ## _lockers_init(struct amb *par); \ 104 scope void name ## _lockers_fini(struct amb *par); \ 105 scope int name ## _lockers_allot(void); \ 106 scope void name ## _lockers_free(int key); \ 107 scope void name ## _lockers_set(struct amb *par, int key, void *data); \ 108 scope void * name ## _lockers_get(const struct amb *par, int key); \ 109 scope void name ## _lockers_clear(struct amb *par, int key); \ 110 scope bool name ## _lockers_is_empty(const struct amb *par, int key) 163 #define M0_LOCKERS_DEFINE(scope, name, field) \ 164 M0_LOCKERS__DEFINE(scope, name, name, field) 166 #define M0_LOCKERS__DEFINE(scope, name, amb, field) \ 167 scope bool __ ## name ## _inuse [M0_LOCKERS_ ## name ## _max]; \ 168 scope struct m0_lockers_type name ## _lockers_type = { \ 169 .lot_max = ARRAY_SIZE(M0_FIELD_VALUE(struct name ## _lockers, \ 171 .lot_inuse = __ ## name ## _inuse \ 174 scope void name ## _lockers_init(struct amb *par) \ 176 m0_lockers_init(&name ## _lockers_type, &par->field.__base); \ 179 scope void name ## _lockers_fini(struct amb *par) \ 181 m0_lockers_fini(&name ## _lockers_type, &par->field.__base); \ 184 scope int name ## _lockers_allot(void) \ 186 return m0_lockers_allot(&name ## _lockers_type); \ 189 scope void name ## _lockers_free(int key) \ 191 m0_lockers_free(&name ## _lockers_type, key); \ 194 scope void name ## _lockers_set(struct amb *par, int key, void *data) \ 196 m0_lockers_set(&name ## _lockers_type, \ 197 &par->field.__base, key, data); \ 200 scope void * name ## _lockers_get(const struct amb *par, int key) \ 202 return m0_lockers_get(&name ## _lockers_type, \ 203 &par->field.__base, key); \ 206 scope void name ## _lockers_clear(struct amb *par, int key) \ 208 m0_lockers_clear(&name ## _lockers_type, &par->field.__base, key); \ 211 scope bool name ## _lockers_is_empty(const struct amb *par, int key) \ 213 return m0_lockers_is_empty(&name ## _lockers_type, \ 214 &par->field.__base, key); \ 217 struct __ ## type ## _semicolon_catcher
M0_INTERNAL void m0_lockers_fini(struct m0_lockers_type *lt, struct m0_lockers *lockers)
M0_INTERNAL void * m0_lockers_get(const struct m0_lockers_type *lt, const struct m0_lockers *lockers, uint32_t key)
M0_INTERNAL int m0_lockers_allot(struct m0_lockers_type *lt)
M0_INTERNAL void m0_lockers_clear(const struct m0_lockers_type *lt, struct m0_lockers *lockers, uint32_t key)
M0_INTERNAL bool m0_lockers_is_empty(const struct m0_lockers_type *lt, const struct m0_lockers *lockers, uint32_t key)
M0_INTERNAL void m0_lockers_set(const struct m0_lockers_type *lt, struct m0_lockers *lockers, uint32_t key, void *data)
M0_INTERNAL void m0_lockers_init(const struct m0_lockers_type *lt, struct m0_lockers *lockers)
M0_INTERNAL void m0_lockers_free(struct m0_lockers_type *lt, int key)