uatomic/x86: Remove redundant memory barriers
[urcu.git] / include / urcu / system.h
CommitLineData
d3d3857f
MJ
1// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2//
3// SPDX-License-Identifier: MIT
4
7e30abe3
MD
5#ifndef _URCU_SYSTEM_H
6#define _URCU_SYSTEM_H
7
8/*
7e30abe3 9 * System definitions.
7e30abe3
MD
10 */
11
d1854484 12#include <urcu/config.h>
7e30abe3
MD
13#include <urcu/compiler.h>
14#include <urcu/arch.h>
15
d1854484
OD
16#ifdef CONFIG_RCU_USE_ATOMIC_BUILTINS
17
18#define CMM_LOAD_SHARED(x) \
19 __atomic_load_n(cmm_cast_volatile(&(x)), __ATOMIC_RELAXED)
20
21#define _CMM_LOAD_SHARED(x) CMM_LOAD_SHARED(x)
22
23#define CMM_STORE_SHARED(x, v) \
24 __extension__ \
25 ({ \
26 __typeof__(v) _v = (v); \
27 __atomic_store_n(cmm_cast_volatile(&(x)), _v, \
28 __ATOMIC_RELAXED); \
29 _v; \
30 })
31
32#define _CMM_STORE_SHARED(x, v) CMM_STORE_SHARED(x, v)
33
34#else
7e30abe3 35/*
d0bbd9c2
MD
36 * Identify a shared load. A cmm_smp_rmc() or cmm_smp_mc() should come
37 * before the load.
7e30abe3 38 */
f5ee48a3 39#define _CMM_LOAD_SHARED(p) CMM_ACCESS_ONCE(p)
7e30abe3
MD
40
41/*
42 * Load a data from shared memory, doing a cache flush if required.
43 */
6cf3827c 44#define CMM_LOAD_SHARED(p) \
1b85da85 45 __extension__ \
7e30abe3 46 ({ \
5481ddb3 47 cmm_smp_rmc(); \
6cf3827c 48 _CMM_LOAD_SHARED(p); \
7e30abe3
MD
49 })
50
51/*
d0bbd9c2
MD
52 * Identify a shared store. A cmm_smp_wmc() or cmm_smp_mc() should
53 * follow the store.
7e30abe3 54 */
1b85da85 55#define _CMM_STORE_SHARED(x, v) __extension__ ({ CMM_ACCESS_ONCE(x) = (v); })
7e30abe3
MD
56
57/*
d0bbd9c2
MD
58 * Store v into x, where x is located in shared memory. Performs the
59 * required cache flush after writing. Returns v.
7e30abe3 60 */
79a8e6c3 61#define CMM_STORE_SHARED(x, v) \
1b85da85 62 __extension__ \
79a8e6c3
MD
63 ({ \
64 __typeof__(x) _v = _CMM_STORE_SHARED(x, v); \
65 cmm_smp_wmc(); \
66 _v = _v; /* Work around clang "unused result" */ \
7e30abe3
MD
67 })
68
d1854484
OD
69#endif /* CONFIG_RCU_USE_ATOMIC_BUILTINS */
70
7e30abe3 71#endif /* _URCU_SYSTEM_H */
This page took 0.050956 seconds and 4 git commands to generate.