1 Index: linux-2.6.5-7.283/include/asm-i386/atomic.h
2 ===================================================================
3 --- linux-2.6.5-7.283.orig/include/asm-i386/atomic.h
4 +++ linux-2.6.5-7.283/include/asm-i386/atomic.h
6 #define __ARCH_I386_ATOMIC__
8 #include <linux/config.h>
9 +#include <linux/bitops.h>
12 * Atomic operations that C can't guarantee us. Useful for
13 @@ -176,6 +177,47 @@ static __inline__ int atomic_add_negativ
18 + * atomic_add_return - add and return
19 + * @v: pointer of type atomic_t
20 + * @i: integer value to add
22 + * Atomically adds @i to @v and returns @i + @v
24 +static __inline__ int atomic_add_return(int i, atomic_t *v)
28 + unsigned long flags;
29 + if(unlikely(boot_cpu_data.x86==3))
32 + /* Modern 486+ processor */
34 + __asm__ __volatile__(
35 + LOCK_PREFIX "xaddl %0, %1"
36 + :"+r" (i), "+m" (v->counter)
41 +no_xadd: /* Legacy 386 processor */
42 + local_irq_save(flags);
43 + __i = atomic_read(v);
44 + atomic_set(v, i + __i);
45 + local_irq_restore(flags);
50 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
52 + return atomic_add_return(-i,v);
55 +#define atomic_inc_return(v) (atomic_add_return(1,v))
56 +#define atomic_dec_return(v) (atomic_sub_return(1,v))
58 /* These are x86-specific, used by some header files */
59 #define atomic_clear_mask(mask, addr) \
60 __asm__ __volatile__(LOCK "andl %0,%1" \
61 Index: linux-2.6.5-7.283/include/asm-x86_64/atomic.h
62 ===================================================================
63 --- linux-2.6.5-7.283.orig/include/asm-x86_64/atomic.h
64 +++ linux-2.6.5-7.283/include/asm-x86_64/atomic.h
66 #define __ARCH_X86_64_ATOMIC__
68 #include <linux/config.h>
69 +#include <linux/bitops.h>
71 /* atomic_t should be 32 bit signed type */
73 @@ -178,6 +179,31 @@ static __inline__ int atomic_add_negativ
78 + * atomic_add_return - add and return
79 + * @i: integer value to add
80 + * @v: pointer of type atomic_t
82 + * Atomically adds @i to @v and returns @i + @v
84 +static __inline__ int atomic_add_return(int i, atomic_t *v)
87 + __asm__ __volatile__(
88 + LOCK_PREFIX "xaddl %0, %1"
89 + :"+r" (i), "+m" (v->counter)
94 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
96 + return atomic_add_return(-i,v);
99 +#define atomic_inc_return(v) (atomic_add_return(1,v))
100 +#define atomic_dec_return(v) (atomic_sub_return(1,v))
102 /* These are x86-specific, used by some header files */
103 #define atomic_clear_mask(mask, addr) \
104 __asm__ __volatile__(LOCK "andl %0,%1" \