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
6 * Copyright (C) 2001 Hiroyuki Kondo, Hirokazu Takata, and Hitoshi Yamamoto
7 * Copyright (C) 2004, 2006 Hirokazu Takata <takata at linux-m32r.org>
9 #ifndef _ASM_M32R_BARRIER_H
10 #define _ASM_M32R_BARRIER_H
12 #define nop() __asm__ __volatile__ ("nop" : : )
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()
26 * read_barrier_depends - Flush all pending reads that subsequents reads
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
37 * These ordering constraints are respected by both the local CPU
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"):
53 * read_barrier_depends();
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":
68 * read_barrier_depends();
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.
78 #define read_barrier_depends() do { } while (0)
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)
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)
94 #endif /* _ASM_M32R_BARRIER_H */