1 #ifndef _LTTNG_WRAPPER_KREF_H
2 #define _LTTNG_WRAPPER_KREF_H
7 * wrapper around linux/kref.h.
9 * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; only version 2 of the License.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * This wrapper code is derived from Linux 3.19.2 include/linux/list.h
25 * and include/linux/rculist.h, hence the GPLv2 license applied to this
29 #include <linux/kref.h>
30 #include <linux/rculist.h>
31 #include <linux/version.h>
34 * lttng_kref_get: get reference count, checking for overflow.
36 * Return 1 if reference is taken, 0 otherwise (overflow).
38 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
39 static inline int lttng_kref_get(struct kref
*kref
)
44 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
45 static inline int lttng_kref_get(struct kref
*kref
)
47 return atomic_add_unless(&kref
->refcount
, 1, INT_MAX
);
49 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
51 #endif /* _LTTNG_WRAPPER_KREF_H */
This page took 0.033679 seconds and 6 git commands to generate.