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 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
11 * This library is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License, version 2.1 only,
13 * as published by the Free Software Foundation.
15 * This library is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this library; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 typedef void (*lttng_release_func
)(void *);
31 lttng_release_func release
;
35 void lttng_ref_init(struct lttng_ref
*ref
, lttng_release_func release
)
39 ref
->release
= release
;
43 void lttng_ref_get(struct lttng_ref
*ref
)
52 void lttng_ref_put(struct lttng_ref
*ref
)
55 /* Underflow check. */
57 if (caa_unlikely((--ref
->count
) == 0)) {
62 #endif /* LTTNG_REF_INTERNAL_H */