fix: asm/barrier.h was introduced in v3.4
[lttng-modules.git] / include / wrapper / barrier.h
1 /* SPDX-License-Identifier: GPL-2.0-only
2 *
3 * wrapper/barrier.h
4 *
5 * wrapper around asm/barrier.h.
6 *
7 * Copyright (C) 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 */
9
10 #ifndef _LTTNG_WRAPPER_BARRIER_H
11 #define _LTTNG_WRAPPER_BARRIER_H
12
13 #include <linux/version.h>
14 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)
15 #include <asm/barrier.h>
16 #else
17 #include <asm/system.h>
18 #endif
19
20 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)
21
22 #define lttng_smp_store_release(x, v) smp_store_release(x, v)
23 #define lttng_smp_load_acquire(x) smp_load_acquire(x)
24
25 #else
26
27 /*
28 * Acquire-release semantics act as a one-way permeable barrier when
29 * pairing a store with a release. Use a full memory barrier to emulate
30 * the acquire-release semantic with a stronger barrier on older
31 * kernels.
32 */
33
34 #define lttng_smp_store_release(x, v) \
35 do { \
36 smp_mb(); \
37 ACCESS_ONCE(*(x)) = (v); \
38 } while (0)
39
40 #define lttng_smp_load_acquire(x) \
41 ({ \
42 __typeof__(*(x)) ___ret; \
43 \
44 ___ret = ACCESS_ONCE(*(x)); \
45 smp_mb(); \
46 ___ret; \
47 })
48
49 #endif
50
51 #endif /* _LTTNG_WRAPPER_BARRIER_H */
This page took 0.029723 seconds and 4 git commands to generate.