diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1997-01-07 02:33:00 +0000 |
---|---|---|
committer | <ralf@linux-mips.org> | 1997-01-07 02:33:00 +0000 |
commit | beb116954b9b7f3bb56412b2494b562f02b864b1 (patch) | |
tree | 120e997879884e1b9d93b265221b939d2ef1ade1 /include/asm-m68k/atomic.h | |
parent | 908d4681a1dc3792ecafbe64265783a86c4cccb6 (diff) |
Import of Linux/MIPS 2.1.14
Diffstat (limited to 'include/asm-m68k/atomic.h')
-rw-r--r-- | include/asm-m68k/atomic.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/include/asm-m68k/atomic.h b/include/asm-m68k/atomic.h new file mode 100644 index 000000000..8ea909203 --- /dev/null +++ b/include/asm-m68k/atomic.h @@ -0,0 +1,42 @@ +#ifndef __ARCH_M68K_ATOMIC__ +#define __ARCH_M68K_ATOMIC__ + +/* + * Atomic operations that C can't guarantee us. Useful for + * resource counting etc.. + */ + +/* + * We do not have SMP m68k systems, so we don't have to deal with that. + */ + +typedef int atomic_t; + +static __inline__ void atomic_add(atomic_t i, atomic_t *v) +{ + __asm__ __volatile__("addl %1,%0" : : "m" (*v), "id" (i)); +} + +static __inline__ void atomic_sub(atomic_t i, atomic_t *v) +{ + __asm__ __volatile__("subl %1,%0" : : "m" (*v), "id" (i)); +} + +static __inline__ void atomic_inc(atomic_t *v) +{ + __asm__ __volatile__("addql #1,%0" : : "m" (*v)); +} + +static __inline__ void atomic_dec(atomic_t *v) +{ + __asm__ __volatile__("subql #1,%0" : : "m" (*v)); +} + +static __inline__ int atomic_dec_and_test(atomic_t *v) +{ + char c; + __asm__ __volatile__("subql #1,%1; seq %0" : "=d" (c) : "m" (*v)); + return c != 0; +} + +#endif /* __ARCH_M68K_ATOMIC __ */ |