diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1999-06-13 16:29:25 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1999-06-13 16:29:25 +0000 |
commit | db7d4daea91e105e3859cf461d7e53b9b77454b2 (patch) | |
tree | 9bb65b95440af09e8aca63abe56970dd3360cc57 /include/asm-sparc/atomic.h | |
parent | 9c1c01ead627bdda9211c9abd5b758d6c687d8ac (diff) |
Merge with Linux 2.2.8.
Diffstat (limited to 'include/asm-sparc/atomic.h')
-rw-r--r-- | include/asm-sparc/atomic.h | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/include/asm-sparc/atomic.h b/include/asm-sparc/atomic.h index b74eebb46..5b96e139b 100644 --- a/include/asm-sparc/atomic.h +++ b/include/asm-sparc/atomic.h @@ -9,16 +9,22 @@ #ifdef __SMP__ /* This is a temporary measure. -DaveM */ typedef struct { volatile int counter; } atomic_t; +#define ATOMIC_INIT(i) { (i << 8) } #else typedef struct { int counter; } atomic_t; +#define ATOMIC_INIT(i) { (i) } #endif -#define ATOMIC_INIT(i) { (i << 8) } - #ifdef __KERNEL__ #include <asm/system.h> #include <asm/psr.h> +#ifndef __SMP__ + +#define atomic_read(v) ((v)->counter) +#define atomic_set(v, i) (((v)->counter) = i) + +#else /* We do the bulk of the actual work out of line in two common * routines in assembler, see arch/sparc/lib/atomic.S for the * "fun" details. @@ -35,14 +41,16 @@ typedef struct { int counter; } atomic_t; static __inline__ int atomic_read(atomic_t *v) { - int val; + int ret = v->counter; + + while(ret & 0xff) + ret = v->counter; - __asm__ __volatile__("sra %1, 0x8, %0" - : "=r" (val) - : "r" (v->counter)); - return val; + return ret >> 8; } + #define atomic_set(v, i) (((v)->counter) = ((i) << 8)) +#endif /* Make sure gcc doesn't try to be clever and move things around * on us. We need to use _exactly_ the address the user gave us, |