root/include/asm-alpha/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

   1 #ifndef __ARCH_I386_ATOMIC__
   2 #define __ARCH_I386_ATOMIC__
   3 
   4 /*
   5  * Atomic operations that C can't guarantee us.  Useful for
   6  * resource counting etc..
   7  */
   8 
   9 /*
  10  * Make sure gcc doesn't try to be clever and move things around
  11  * on us. We need to use _exactly_ the address the user gave us,
  12  * not some alias that contains the same information.
  13  */
  14 #define __atomic_fool_gcc(x) (*(struct { int a[100]; } *)x)
  15 
  16 typedef int atomic_t;
  17 
  18 extern __inline__ void atomic_add(atomic_t i, atomic_t * v)
     /* [previous][next][first][last][top][bottom][index][help] */
  19 {
  20         unsigned long temp;
  21         __asm__ __volatile__(
  22                 "\n1:\t"
  23                 "ldl_l %0,%1\n\t"
  24                 "addl %0,%2,%0\n\t"
  25                 "stl_c %0,%1\n\t"
  26                 "beq %0,1b\n"
  27                 "2:"
  28                 :"=&r" (temp),
  29                  "=m" (__atomic_fool_gcc(v))
  30                 :"Ir" (i),
  31                  "m" (__atomic_fool_gcc(v)));
  32 }
  33 
  34 extern __inline__ void atomic_sub(atomic_t i, atomic_t * v)
     /* [previous][next][first][last][top][bottom][index][help] */
  35 {
  36         unsigned long temp;
  37         __asm__ __volatile__(
  38                 "\n1:\t"
  39                 "ldl_l %0,%1\n\t"
  40                 "subl %0,%2,%0\n\t"
  41                 "stl_c %0,%1\n\t"
  42                 "beq %0,1b\n"
  43                 "2:"
  44                 :"=&r" (temp),
  45                  "=m" (__atomic_fool_gcc(v))
  46                 :"Ir" (i),
  47                  "m" (__atomic_fool_gcc(v)));
  48 }
  49 
  50 #define atomic_inc(v) atomic_add(1,(v))
  51 #define atomic_dec(v) atomic_sub(1,(v))
  52 
  53 #endif

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