Commit | Line | Data |
---|---|---|
7e30abe3 MD |
1 | #ifndef _URCU_SYSTEM_H |
2 | #define _URCU_SYSTEM_H | |
3 | ||
4 | /* | |
5 | * system.h | |
6 | * | |
7 | * System definitions. | |
8 | * | |
6982d6d7 | 9 | * Copyright (c) 2009 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
7e30abe3 MD |
10 | * |
11 | * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED | |
12 | * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. | |
13 | * | |
14 | * Permission is hereby granted to use or copy this program | |
15 | * for any purpose, provided the above notices are retained on all copies. | |
16 | * Permission to modify the code and to distribute modified code is granted, | |
17 | * provided the above notices are retained, and a notice that the code was | |
18 | * modified is included with the above copyright notice. | |
19 | */ | |
20 | ||
21 | #include <urcu/compiler.h> | |
22 | #include <urcu/arch.h> | |
23 | ||
24 | /* | |
5481ddb3 | 25 | * Identify a shared load. A cmm_smp_rmc() or cmm_smp_mc() should come before the load. |
7e30abe3 | 26 | */ |
f5ee48a3 | 27 | #define _CMM_LOAD_SHARED(p) CMM_ACCESS_ONCE(p) |
7e30abe3 MD |
28 | |
29 | /* | |
30 | * Load a data from shared memory, doing a cache flush if required. | |
31 | */ | |
6cf3827c | 32 | #define CMM_LOAD_SHARED(p) \ |
7e30abe3 | 33 | ({ \ |
5481ddb3 | 34 | cmm_smp_rmc(); \ |
6cf3827c | 35 | _CMM_LOAD_SHARED(p); \ |
7e30abe3 MD |
36 | }) |
37 | ||
38 | /* | |
5481ddb3 | 39 | * Identify a shared store. A cmm_smp_wmc() or cmm_smp_mc() should follow the store. |
7e30abe3 | 40 | */ |
f5ee48a3 | 41 | #define _CMM_STORE_SHARED(x, v) ({ CMM_ACCESS_ONCE(x) = (v); }) |
7e30abe3 MD |
42 | |
43 | /* | |
44 | * Store v into x, where x is located in shared memory. Performs the required | |
45 | * cache flush after writing. Returns v. | |
46 | */ | |
6cf3827c | 47 | #define CMM_STORE_SHARED(x, v) \ |
7e30abe3 | 48 | ({ \ |
6cf3827c | 49 | typeof(x) _v = _CMM_STORE_SHARED(x, v); \ |
5481ddb3 | 50 | cmm_smp_wmc(); \ |
f152776d | 51 | _v; \ |
7e30abe3 MD |
52 | }) |
53 | ||
54 | #endif /* _URCU_SYSTEM_H */ |