Skip to content

Reference count

void refcount_init(refcount_t *rc, unsigned int val);

refcount_init referenced types:

bool refcount_inc(refcount_t *rc);

refcount_inc referenced types:

bool refcount_inc_not_zero(refcount_t *rc);

refcount_inc_not_zero referenced types:

uint32_t refcount_read(refcount_t *rc);

refcount_read referenced types:

bool refcount_dec_and_test(refcount_t *rc);

refcount_dec_and_test referenced types:

#define REFCOUNT_GENERATE_GET_FOR_STRUCT_WITH_FAILURE_COND( \ __struct, __refcount_member, __failure_member, __failure_state) \ static inline bool __struct##_get(struct __struct *obj) { \ uint32_t old; \ while (true) { \ old = atomic_load_explicit(&obj->__refcount_member, \ memory_order_acquire); \ \ /* panic if refcount is zero (possible UAF) */
#define REFCOUNT_ASSERT_ZERO(rc) (kassert(atomic_load(&rc) == 0))