2 * LTTng - Non thread-safe reference counting
4 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 * SPDX-License-Identifier: LGPL-2.1-only
10 #ifndef LTTNG_REF_INTERNAL_H
11 #define LTTNG_REF_INTERNAL_H
13 #include <common/macros.hpp>
15 #include <urcu/urcu.h>
17 using lttng_release_func = void (*)(void *);
21 lttng_release_func release;
24 static inline void lttng_ref_init(struct lttng_ref *ref, lttng_release_func release)
28 ref->release = release;
31 static inline void lttng_ref_get(struct lttng_ref *ref)
36 LTTNG_ASSERT(ref->count);
39 static inline void lttng_ref_put(struct lttng_ref *ref)
42 /* Underflow check. */
43 LTTNG_ASSERT(ref->count);
44 if (caa_unlikely((--ref->count) == 0)) {
49 #endif /* LTTNG_REF_INTERNAL_H */