x86/efi: Enforce CONFIG_RELOCATABLE for EFI boot stub
[linux/fpc-iii.git] / arch / m32r / include / asm / barrier.h
blob6976621efd3f5d1c313498535827cc93dcd142e4
1 /*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
6 * Copyright (C) 2001 Hiroyuki Kondo, Hirokazu Takata, and Hitoshi Yamamoto
7 * Copyright (C) 2004, 2006 Hirokazu Takata <takata at linux-m32r.org>
8 */
9 #ifndef _ASM_M32R_BARRIER_H
10 #define _ASM_M32R_BARRIER_H
12 #define nop() __asm__ __volatile__ ("nop" : : )
15 * Memory barrier.
17 * mb() prevents loads and stores being reordered across this point.
18 * rmb() prevents loads being reordered across this point.
19 * wmb() prevents stores being reordered across this point.
21 #define mb() barrier()
22 #define rmb() mb()
23 #define wmb() mb()
25 /**
26 * read_barrier_depends - Flush all pending reads that subsequents reads
27 * depend on.
29 * No data-dependent reads from memory-like regions are ever reordered
30 * over this barrier. All reads preceding this primitive are guaranteed
31 * to access memory (but not necessarily other CPUs' caches) before any
32 * reads following this primitive that depend on the data return by
33 * any of the preceding reads. This primitive is much lighter weight than
34 * rmb() on most CPUs, and is never heavier weight than is
35 * rmb().
37 * These ordering constraints are respected by both the local CPU
38 * and the compiler.
40 * Ordering is not guaranteed by anything other than these primitives,
41 * not even by data dependencies. See the documentation for
42 * memory_barrier() for examples and URLs to more information.
44 * For example, the following code would force ordering (the initial
45 * value of "a" is zero, "b" is one, and "p" is "&a"):
47 * <programlisting>
48 * CPU 0 CPU 1
50 * b = 2;
51 * memory_barrier();
52 * p = &b; q = p;
53 * read_barrier_depends();
54 * d = *q;
55 * </programlisting>
58 * because the read of "*q" depends on the read of "p" and these
59 * two reads are separated by a read_barrier_depends(). However,
60 * the following code, with the same initial values for "a" and "b":
62 * <programlisting>
63 * CPU 0 CPU 1
65 * a = 2;
66 * memory_barrier();
67 * b = 3; y = b;
68 * read_barrier_depends();
69 * x = a;
70 * </programlisting>
72 * does not enforce ordering, since there is no data dependency between
73 * the read of "a" and the read of "b". Therefore, on some CPUs, such
74 * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()
75 * in cases like this where there are no data dependencies.
76 **/
78 #define read_barrier_depends() do { } while (0)
80 #ifdef CONFIG_SMP
81 #define smp_mb() mb()
82 #define smp_rmb() rmb()
83 #define smp_wmb() wmb()
84 #define smp_read_barrier_depends() read_barrier_depends()
85 #define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
86 #else
87 #define smp_mb() barrier()
88 #define smp_rmb() barrier()
89 #define smp_wmb() barrier()
90 #define smp_read_barrier_depends() do { } while (0)
91 #define set_mb(var, value) do { var = value; barrier(); } while (0)
92 #endif
94 #endif /* _ASM_M32R_BARRIER_H */