]> git.buserror.net Git - polintos/scott/priv.git/blob - include/c/lowlevel/arch-x86-common/barriers-fence.h
minor doc updates
[polintos/scott/priv.git] / include / c / lowlevel / arch-x86-common / barriers-fence.h
1 // Memory and I/O barriers.  These are not privileged.
2
3 #ifndef _LL_ARCH_X86C_BARRIERS_FENCE_H
4 #define _LL_ARCH_X86C_BARRIERS_FENCE_H
5
6 #include <lowlevel/types.h>
7
8 static inline void ll_membar()
9 {
10         asm volatile("mfence" : : : "memory");
11 }
12
13 static inline void ll_membar_load_after_load()
14 {
15         asm volatile("lfence" : : : "memory");
16 }
17
18 static inline void ll_membar_load_after_store()
19 {
20         ll_membar();
21 }
22
23 static inline void ll_membar_load_after_any()
24 {
25         ll_membar();
26 }
27
28 static inline void ll_membar_any_after_load()
29 {
30         ll_membar();
31 }
32
33 static inline void ll_membar_store_after_load()
34 {
35         ll_membar();
36 }
37
38 static inline void ll_membar_store_after_store()
39 {
40         asm volatile("sfence" : : : "memory");
41 }
42
43 static inline void ll_membar_store_after_any()
44 {
45         ll_membar();
46 }
47
48 static inline void ll_membar_any_after_store()
49 {
50         ll_membar();
51 }
52
53 static inline void ll_smp_membar()
54 {
55         if (_LL_SMP)
56                 ll_membar();
57         else
58                 ll_barrier();
59 }
60
61 static inline void ll_smp_membar_load_after_load()
62 {
63         if (_LL_SMP)
64                 ll_membar_load_after_load();
65         else
66                 ll_barrier();
67 }
68
69 static inline void ll_smp_membar_load_after_store()
70 {
71         ll_smp_membar();
72 }
73
74 static inline void ll_smp_membar_load_after_any()
75 {
76         ll_smp_membar();
77 }
78
79 static inline void ll_smp_membar_any_after_load()
80 {
81         ll_smp_membar();
82 }
83
84 static inline void ll_smp_membar_store_after_load()
85 {
86         ll_membar();
87 }
88
89 static inline void ll_smp_membar_store_after_store()
90 {
91         if (_LL_SMP)
92                 ll_membar_store_after_store();
93         else
94                 ll_barrier();
95 }
96
97 static inline void ll_smp_membar_store_after_any()
98 {
99         ll_smp_membar();
100 }
101
102 static inline void ll_smp_membar_any_after_store()
103 {
104         ll_smp_membar();
105 }
106
107 #endif