diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-arm26/atomic.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/asm-arm26/atomic.h')
-rw-r--r-- | include/asm-arm26/atomic.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/include/asm-arm26/atomic.h b/include/asm-arm26/atomic.h new file mode 100644 index 000000000000..4a88235c0e76 --- /dev/null +++ b/include/asm-arm26/atomic.h | |||
@@ -0,0 +1,93 @@ | |||
1 | /* | ||
2 | * linux/include/asm-arm26/atomic.h | ||
3 | * | ||
4 | * Copyright (c) 1996 Russell King. | ||
5 | * Modified for arm26 by Ian Molton | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | * Changelog: | ||
12 | * 25-11-2004 IM Updated for 2.6.9 | ||
13 | * 27-06-1996 RMK Created | ||
14 | * 13-04-1997 RMK Made functions atomic! | ||
15 | * 07-12-1997 RMK Upgraded for v2.1. | ||
16 | * 26-08-1998 PJB Added #ifdef __KERNEL__ | ||
17 | * | ||
18 | * FIXME - its probably worth seeing what these compile into... | ||
19 | */ | ||
20 | #ifndef __ASM_ARM_ATOMIC_H | ||
21 | #define __ASM_ARM_ATOMIC_H | ||
22 | |||
23 | #include <linux/config.h> | ||
24 | |||
25 | #ifdef CONFIG_SMP | ||
26 | #error SMP is NOT supported | ||
27 | #endif | ||
28 | |||
29 | typedef struct { volatile int counter; } atomic_t; | ||
30 | |||
31 | #define ATOMIC_INIT(i) { (i) } | ||
32 | |||
33 | #ifdef __KERNEL__ | ||
34 | #include <asm/system.h> | ||
35 | |||
36 | #define atomic_read(v) ((v)->counter) | ||
37 | #define atomic_set(v,i) (((v)->counter) = (i)) | ||
38 | |||
39 | static inline int atomic_add_return(int i, atomic_t *v) | ||
40 | { | ||
41 | unsigned long flags; | ||
42 | int val; | ||
43 | |||
44 | local_irq_save(flags); | ||
45 | val = v->counter; | ||
46 | v->counter = val += i; | ||
47 | local_irq_restore(flags); | ||
48 | |||
49 | return val; | ||
50 | } | ||
51 | |||
52 | static inline int atomic_sub_return(int i, atomic_t *v) | ||
53 | { | ||
54 | unsigned long flags; | ||
55 | int val; | ||
56 | |||
57 | local_irq_save(flags); | ||
58 | val = v->counter; | ||
59 | v->counter = val -= i; | ||
60 | local_irq_restore(flags); | ||
61 | |||
62 | return val; | ||
63 | } | ||
64 | |||
65 | static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) | ||
66 | { | ||
67 | unsigned long flags; | ||
68 | |||
69 | local_irq_save(flags); | ||
70 | *addr &= ~mask; | ||
71 | local_irq_restore(flags); | ||
72 | } | ||
73 | |||
74 | #define atomic_add(i, v) (void) atomic_add_return(i, v) | ||
75 | #define atomic_inc(v) (void) atomic_add_return(1, v) | ||
76 | #define atomic_sub(i, v) (void) atomic_sub_return(i, v) | ||
77 | #define atomic_dec(v) (void) atomic_sub_return(1, v) | ||
78 | |||
79 | #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0) | ||
80 | #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0) | ||
81 | #define atomic_inc_return(v) (atomic_add_return(1, v)) | ||
82 | #define atomic_dec_return(v) (atomic_sub_return(1, v)) | ||
83 | |||
84 | #define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0) | ||
85 | |||
86 | /* Atomic operations are already serializing on ARM26 */ | ||
87 | #define smp_mb__before_atomic_dec() barrier() | ||
88 | #define smp_mb__after_atomic_dec() barrier() | ||
89 | #define smp_mb__before_atomic_inc() barrier() | ||
90 | #define smp_mb__after_atomic_inc() barrier() | ||
91 | |||
92 | #endif | ||
93 | #endif | ||