diff options
author | Sam Ravnborg <sam@ravnborg.org> | 2008-07-18 00:55:51 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-07-18 00:55:51 -0400 |
commit | f5e706ad886b6a5eb59637830110b09ccebf01c5 (patch) | |
tree | ea043a0a28e16a2ac6395c35d737f52698a165b7 /include/asm-sparc64/atomic.h | |
parent | 5e3609f60c09f0f15f71f80c6d7933b2c7be71a6 (diff) |
sparc: join the remaining header files
With this commit all sparc64 header files are moved to asm-sparc.
The remaining files (71 files) were too different to be trivially
merged so divide them up in a _32.h and a _64.h file which
are both included from the file with no bit size.
The following script were used:
cd include
FILES=`wc -l asm-sparc64/*h | grep -v '^ 1' | cut -b 20-`
for FILE in ${FILES}; do
echo $FILE:
BASE=`echo $FILE | cut -d '.' -f 1`
FN32=${BASE}_32.h
FN64=${BASE}_64.h
GUARD=___ASM_SPARC_`echo $BASE | tr '-' '_' | tr [:lower:] [:upper:]`_H
git mv asm-sparc/$FILE asm-sparc/$FN32
git mv asm-sparc64/$FILE asm-sparc/$FN64
echo git mv done
printf "#ifndef %s\n" $GUARD > asm-sparc/$FILE
printf "#define %s\n" $GUARD >> asm-sparc/$FILE
printf "#if defined(__sparc__) && defined(__arch64__)\n" >> asm-sparc/$FILE
printf "#include <asm-sparc/%s>\n" $FN64 >> asm-sparc/$FILE
printf "#else\n" >> asm-sparc/$FILE
printf "#include <asm-sparc/%s>\n" $FN32 >> asm-sparc/$FILE
printf "#endif\n" >> asm-sparc/$FILE
printf "#endif\n" >> asm-sparc/$FILE
git add asm-sparc/$FILE
echo new file done
printf "#include <asm-sparc/%s>\n" $FILE > asm-sparc64/$FILE
git add asm-sparc64/$FILE
echo sparc64 file done
done
The guard contains three '_' to avoid conflict with existing guards.
In additing the two Kbuild files are emptied to avoid breaking
headers_* targets.
We will reintroduce the exported header files when the necessary
kbuild changes are merged.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/asm-sparc64/atomic.h')
-rw-r--r-- | include/asm-sparc64/atomic.h | 129 |
1 files changed, 1 insertions, 128 deletions
diff --git a/include/asm-sparc64/atomic.h b/include/asm-sparc64/atomic.h index 2c71ec4a3b18..f5126826ba34 100644 --- a/include/asm-sparc64/atomic.h +++ b/include/asm-sparc64/atomic.h | |||
@@ -1,128 +1 @@ | |||
1 | /* atomic.h: Thankfully the V9 is at least reasonable for this | #include <asm-sparc/atomic.h> | |
2 | * stuff. | ||
3 | * | ||
4 | * Copyright (C) 1996, 1997, 2000 David S. Miller (davem@redhat.com) | ||
5 | */ | ||
6 | |||
7 | #ifndef __ARCH_SPARC64_ATOMIC__ | ||
8 | #define __ARCH_SPARC64_ATOMIC__ | ||
9 | |||
10 | #include <linux/types.h> | ||
11 | #include <asm/system.h> | ||
12 | |||
13 | typedef struct { volatile int counter; } atomic_t; | ||
14 | typedef struct { volatile __s64 counter; } atomic64_t; | ||
15 | |||
16 | #define ATOMIC_INIT(i) { (i) } | ||
17 | #define ATOMIC64_INIT(i) { (i) } | ||
18 | |||
19 | #define atomic_read(v) ((v)->counter) | ||
20 | #define atomic64_read(v) ((v)->counter) | ||
21 | |||
22 | #define atomic_set(v, i) (((v)->counter) = i) | ||
23 | #define atomic64_set(v, i) (((v)->counter) = i) | ||
24 | |||
25 | extern void atomic_add(int, atomic_t *); | ||
26 | extern void atomic64_add(int, atomic64_t *); | ||
27 | extern void atomic_sub(int, atomic_t *); | ||
28 | extern void atomic64_sub(int, atomic64_t *); | ||
29 | |||
30 | extern int atomic_add_ret(int, atomic_t *); | ||
31 | extern int atomic64_add_ret(int, atomic64_t *); | ||
32 | extern int atomic_sub_ret(int, atomic_t *); | ||
33 | extern int atomic64_sub_ret(int, atomic64_t *); | ||
34 | |||
35 | #define atomic_dec_return(v) atomic_sub_ret(1, v) | ||
36 | #define atomic64_dec_return(v) atomic64_sub_ret(1, v) | ||
37 | |||
38 | #define atomic_inc_return(v) atomic_add_ret(1, v) | ||
39 | #define atomic64_inc_return(v) atomic64_add_ret(1, v) | ||
40 | |||
41 | #define atomic_sub_return(i, v) atomic_sub_ret(i, v) | ||
42 | #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v) | ||
43 | |||
44 | #define atomic_add_return(i, v) atomic_add_ret(i, v) | ||
45 | #define atomic64_add_return(i, v) atomic64_add_ret(i, v) | ||
46 | |||
47 | /* | ||
48 | * atomic_inc_and_test - increment and test | ||
49 | * @v: pointer of type atomic_t | ||
50 | * | ||
51 | * Atomically increments @v by 1 | ||
52 | * and returns true if the result is zero, or false for all | ||
53 | * other cases. | ||
54 | */ | ||
55 | #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0) | ||
56 | #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0) | ||
57 | |||
58 | #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0) | ||
59 | #define atomic64_sub_and_test(i, v) (atomic64_sub_ret(i, v) == 0) | ||
60 | |||
61 | #define atomic_dec_and_test(v) (atomic_sub_ret(1, v) == 0) | ||
62 | #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0) | ||
63 | |||
64 | #define atomic_inc(v) atomic_add(1, v) | ||
65 | #define atomic64_inc(v) atomic64_add(1, v) | ||
66 | |||
67 | #define atomic_dec(v) atomic_sub(1, v) | ||
68 | #define atomic64_dec(v) atomic64_sub(1, v) | ||
69 | |||
70 | #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0) | ||
71 | #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0) | ||
72 | |||
73 | #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n))) | ||
74 | #define atomic_xchg(v, new) (xchg(&((v)->counter), new)) | ||
75 | |||
76 | static inline int atomic_add_unless(atomic_t *v, int a, int u) | ||
77 | { | ||
78 | int c, old; | ||
79 | c = atomic_read(v); | ||
80 | for (;;) { | ||
81 | if (unlikely(c == (u))) | ||
82 | break; | ||
83 | old = atomic_cmpxchg((v), c, c + (a)); | ||
84 | if (likely(old == c)) | ||
85 | break; | ||
86 | c = old; | ||
87 | } | ||
88 | return c != (u); | ||
89 | } | ||
90 | |||
91 | #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) | ||
92 | |||
93 | #define atomic64_cmpxchg(v, o, n) \ | ||
94 | ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n))) | ||
95 | #define atomic64_xchg(v, new) (xchg(&((v)->counter), new)) | ||
96 | |||
97 | static inline int atomic64_add_unless(atomic64_t *v, long a, long u) | ||
98 | { | ||
99 | long c, old; | ||
100 | c = atomic64_read(v); | ||
101 | for (;;) { | ||
102 | if (unlikely(c == (u))) | ||
103 | break; | ||
104 | old = atomic64_cmpxchg((v), c, c + (a)); | ||
105 | if (likely(old == c)) | ||
106 | break; | ||
107 | c = old; | ||
108 | } | ||
109 | return c != (u); | ||
110 | } | ||
111 | |||
112 | #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) | ||
113 | |||
114 | /* Atomic operations are already serializing */ | ||
115 | #ifdef CONFIG_SMP | ||
116 | #define smp_mb__before_atomic_dec() membar_storeload_loadload(); | ||
117 | #define smp_mb__after_atomic_dec() membar_storeload_storestore(); | ||
118 | #define smp_mb__before_atomic_inc() membar_storeload_loadload(); | ||
119 | #define smp_mb__after_atomic_inc() membar_storeload_storestore(); | ||
120 | #else | ||
121 | #define smp_mb__before_atomic_dec() barrier() | ||
122 | #define smp_mb__after_atomic_dec() barrier() | ||
123 | #define smp_mb__before_atomic_inc() barrier() | ||
124 | #define smp_mb__after_atomic_inc() barrier() | ||
125 | #endif | ||
126 | |||
127 | #include <asm-generic/atomic.h> | ||
128 | #endif /* !(__ARCH_SPARC64_ATOMIC__) */ | ||