root/include/asm-sparc/atomic.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. atomic_add
  2. atomic_sub
  3. atomic_sub_and_test
  4. atomic_inc
  5. atomic_dec
  6. atomic_dec_and_test

   1 /* atomic.h: These really suck for now.
   2  *
   3  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
   4  */
   5 
   6 #ifndef __ARCH_SPARC_ATOMIC__
   7 #define __ARCH_SPARC_ATOMIC__
   8 
   9 #ifdef __SMP__
  10 #include <asm/smp.h>
  11 #include <asm/smp_lock.h>
  12 #endif
  13 
  14 typedef int atomic_t;
  15 
  16 static __inline__ void atomic_add(atomic_t i, atomic_t *v)
     /* [previous][next][first][last][top][bottom][index][help] */
  17 {
  18         unsigned long flags;
  19 
  20         save_flags(flags); cli();
  21         *v += i;
  22         restore_flags(flags);
  23 }
  24 
  25 static __inline__ void atomic_sub(atomic_t i, atomic_t *v)
     /* [previous][next][first][last][top][bottom][index][help] */
  26 {
  27         unsigned long flags;
  28 
  29         save_flags(flags); cli();
  30         *v -= i;
  31         restore_flags(flags);
  32 }
  33 
  34 static __inline__ int atomic_sub_and_test(atomic_t i, atomic_t *v)
     /* [previous][next][first][last][top][bottom][index][help] */
  35 {
  36         unsigned long flags, result;
  37 
  38         save_flags(flags); cli();
  39         *v -= i;
  40         result = (*v == 0);
  41         restore_flags(flags);
  42         return result;
  43 }
  44 
  45 static __inline__ void atomic_inc(atomic_t *v)
     /* [previous][next][first][last][top][bottom][index][help] */
  46 {
  47         atomic_add(1, v);
  48 }
  49 
  50 static __inline__ void atomic_dec(atomic_t *v)
     /* [previous][next][first][last][top][bottom][index][help] */
  51 {
  52         atomic_sub(1, v);
  53 }
  54 
  55 static __inline__ int atomic_dec_and_test(atomic_t *v)
     /* [previous][next][first][last][top][bottom][index][help] */
  56 {
  57         return atomic_sub_and_test(1, v);
  58 }
  59 
  60 #endif /* !(__ARCH_SPARC_ATOMIC__) */

/* [previous][next][first][last][top][bottom][index][help] */