1 #ifndef LTTNG_REF_INTERNAL_H
2 #define LTTNG_REF_INTERNAL_H
5 * LTTng - Non thread-safe reference counting
7 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 * SPDX-License-Identifier: LGPL-2.1-only
14 typedef void (*lttng_release_func
)(void *);
18 lttng_release_func release
;
22 void lttng_ref_init(struct lttng_ref
*ref
, lttng_release_func release
)
26 ref
->release
= release
;
30 void lttng_ref_get(struct lttng_ref
*ref
)
35 LTTNG_ASSERT(ref
->count
);
39 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 */