| 1 | /* SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) |
| 2 | * |
| 3 | * wrapper/atomic.h |
| 4 | * |
| 5 | * wrapper around linux/atomic.h. |
| 6 | * |
| 7 | * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 8 | */ |
| 9 | |
| 10 | #ifndef _LTTNG_WRAPPER_ATOMIC_H |
| 11 | #define _LTTNG_WRAPPER_ATOMIC_H |
| 12 | |
| 13 | #include <linux/version.h> |
| 14 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) |
| 15 | #include <linux/atomic.h> |
| 16 | #else |
| 17 | #include <asm/atomic.h> |
| 18 | #endif |
| 19 | |
| 20 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) |
| 21 | static inline void lttng_smp_mb__before_atomic(void) |
| 22 | { |
| 23 | smp_mb__before_atomic(); |
| 24 | } |
| 25 | |
| 26 | static inline void lttng_smp_mb__after_atomic(void) |
| 27 | { |
| 28 | smp_mb__after_atomic(); |
| 29 | } |
| 30 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) */ |
| 31 | static inline void lttng_smp_mb__before_atomic(void) |
| 32 | { |
| 33 | smp_mb__before_atomic_inc(); |
| 34 | } |
| 35 | |
| 36 | static inline void lttng_smp_mb__after_atomic(void) |
| 37 | { |
| 38 | smp_mb__after_atomic_inc(); |
| 39 | } |
| 40 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) */ |
| 41 | |
| 42 | #endif /* _LTTNG_WRAPPER_ATOMIC_H */ |