PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mb.h
Go to the documentation of this file.
1 #ifndef _MB_H
2 #define _MB_H
3 
4 /* These definitions are not yet in distros, so I have cut and pasted just
5  the needed definitions in here */
6 
7 #ifdef __powerpc__
8 #define rmb() asm volatile ("sync" : : : "memory")
9 
10 #elif defined (__s390__)
11 #define rmb() asm volatile("bcr 15,0" ::: "memory")
12 
13 #elif defined (__sh__)
14 #if defined(__SH4A__) || defined(__SH5__)
15 #define rmb() asm volatile("synco" ::: "memory")
16 #else
17 #define rmb() asm volatile("" ::: "memory")
18 #endif
19 
20 #elif defined (__hppa__)
21 #define rmb() asm volatile("" ::: "memory")
22 
23 #elif defined (__sparc__)
24 #define rmb() asm volatile("":::"memory")
25 
26 #elif defined (__alpha__)
27 #define rmb() asm volatile("mb" ::: "memory")
28 
29 #elif defined(__ia64__)
30 #define rmb() asm volatile ("mf" ::: "memory")
31 
32 #elif defined(__arm__)
33 /*
34  * Use the __kuser_memory_barrier helper in the CPU helper page. See
35  * arch/arm/kernel/entry-armv.S in the kernel source for details.
36  */
37 #define rmb() ((void(*)(void))0xffff0fa0)()
38 
39 #elif defined(__aarch64__)
40 #define rmb() asm volatile("dmb ld" ::: "memory")
41 
42 #elif defined(__mips__)
43 #define rmb() asm volatile( \
44  ".set mips2\n\t" \
45  "sync\n\t" \
46  ".set mips0" \
47  : /* no output */ \
48  : /* no input */ \
49  : "memory")
50 
51 #elif defined(__i386__)
52 #define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
53 
54 #elif defined(__x86_64)
55 
56 #if defined(__KNC__)
57 #define rmb() __sync_synchronize()
58 
59 #else
60 #define rmb() asm volatile("lfence":::"memory")
61 #endif
62 
63 #else
64 #error Need to define rmb for this architecture!
65 #error See the kernel source directory: tools/perf/perf.h file
66 #endif
67 
68 #endif