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 | 10 | * |
3282a76b MD |
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
12 | * of this software and associated documentation files (the "Software"), to deal | |
13 | * in the Software without restriction, including without limitation the rights | |
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
15 | * copies of the Software, and to permit persons to whom the Software is | |
16 | * furnished to do so, subject to the following conditions: | |
7e30abe3 | 17 | * |
3282a76b MD |
18 | * The above copyright notice and this permission notice shall be included in |
19 | * all copies or substantial portions of the Software. | |
7e30abe3 MD |
20 | */ |
21 | ||
22 | #include <urcu/compiler.h> | |
23 | #include <urcu/arch.h> | |
24 | ||
25 | /* | |
5481ddb3 | 26 | * Identify a shared load. A cmm_smp_rmc() or cmm_smp_mc() should come before the load. |
7e30abe3 | 27 | */ |
f5ee48a3 | 28 | #define _CMM_LOAD_SHARED(p) CMM_ACCESS_ONCE(p) |
7e30abe3 MD |
29 | |
30 | /* | |
31 | * Load a data from shared memory, doing a cache flush if required. | |
32 | */ | |
6cf3827c | 33 | #define CMM_LOAD_SHARED(p) \ |
7e30abe3 | 34 | ({ \ |
5481ddb3 | 35 | cmm_smp_rmc(); \ |
6cf3827c | 36 | _CMM_LOAD_SHARED(p); \ |
7e30abe3 MD |
37 | }) |
38 | ||
39 | /* | |
5481ddb3 | 40 | * Identify a shared store. A cmm_smp_wmc() or cmm_smp_mc() should follow the store. |
7e30abe3 | 41 | */ |
f5ee48a3 | 42 | #define _CMM_STORE_SHARED(x, v) ({ CMM_ACCESS_ONCE(x) = (v); }) |
7e30abe3 MD |
43 | |
44 | /* | |
45 | * Store v into x, where x is located in shared memory. Performs the required | |
46 | * cache flush after writing. Returns v. | |
47 | */ | |
6cf3827c | 48 | #define CMM_STORE_SHARED(x, v) \ |
7e30abe3 | 49 | ({ \ |
6cf3827c | 50 | typeof(x) _v = _CMM_STORE_SHARED(x, v); \ |
5481ddb3 | 51 | cmm_smp_wmc(); \ |
f152776d | 52 | _v; \ |
7e30abe3 MD |
53 | }) |
54 | ||
55 | #endif /* _URCU_SYSTEM_H */ |