diff options
-rw-r--r-- | include/asm-generic/local.h | 13 | ||||
-rw-r--r-- | include/asm-i386/local.h | 6 | ||||
-rw-r--r-- | include/asm-x86_64/local.h | 10 |
3 files changed, 18 insertions, 11 deletions
diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h index de4614840c2c..9291c24f5819 100644 --- a/include/asm-generic/local.h +++ b/include/asm-generic/local.h | |||
@@ -7,8 +7,15 @@ | |||
7 | #include <asm/atomic.h> | 7 | #include <asm/atomic.h> |
8 | #include <asm/types.h> | 8 | #include <asm/types.h> |
9 | 9 | ||
10 | /* An unsigned long type for operations which are atomic for a single | 10 | /* |
11 | * CPU. Usually used in combination with per-cpu variables. */ | 11 | * A signed long type for operations which are atomic for a single CPU. |
12 | * Usually used in combination with per-cpu variables. | ||
13 | * | ||
14 | * This is the default implementation, which uses atomic_long_t. Which is | ||
15 | * rather pointless. The whole point behind local_t is that some processors | ||
16 | * can perform atomic adds and subtracts in a manner which is atomic wrt IRQs | ||
17 | * running on this CPU. local_t allows exploitation of such capabilities. | ||
18 | */ | ||
12 | 19 | ||
13 | /* Implement in terms of atomics. */ | 20 | /* Implement in terms of atomics. */ |
14 | 21 | ||
@@ -20,7 +27,7 @@ typedef struct | |||
20 | 27 | ||
21 | #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) } | 28 | #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) } |
22 | 29 | ||
23 | #define local_read(l) ((unsigned long)atomic_long_read(&(l)->a)) | 30 | #define local_read(l) atomic_long_read(&(l)->a) |
24 | #define local_set(l,i) atomic_long_set((&(l)->a),(i)) | 31 | #define local_set(l,i) atomic_long_set((&(l)->a),(i)) |
25 | #define local_inc(l) atomic_long_inc(&(l)->a) | 32 | #define local_inc(l) atomic_long_inc(&(l)->a) |
26 | #define local_dec(l) atomic_long_dec(&(l)->a) | 33 | #define local_dec(l) atomic_long_dec(&(l)->a) |
diff --git a/include/asm-i386/local.h b/include/asm-i386/local.h index 0177da80dde3..e67fa08260fe 100644 --- a/include/asm-i386/local.h +++ b/include/asm-i386/local.h | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | typedef struct | 6 | typedef struct |
7 | { | 7 | { |
8 | volatile unsigned long counter; | 8 | volatile long counter; |
9 | } local_t; | 9 | } local_t; |
10 | 10 | ||
11 | #define LOCAL_INIT(i) { (i) } | 11 | #define LOCAL_INIT(i) { (i) } |
@@ -29,7 +29,7 @@ static __inline__ void local_dec(local_t *v) | |||
29 | :"m" (v->counter)); | 29 | :"m" (v->counter)); |
30 | } | 30 | } |
31 | 31 | ||
32 | static __inline__ void local_add(unsigned long i, local_t *v) | 32 | static __inline__ void local_add(long i, local_t *v) |
33 | { | 33 | { |
34 | __asm__ __volatile__( | 34 | __asm__ __volatile__( |
35 | "addl %1,%0" | 35 | "addl %1,%0" |
@@ -37,7 +37,7 @@ static __inline__ void local_add(unsigned long i, local_t *v) | |||
37 | :"ir" (i), "m" (v->counter)); | 37 | :"ir" (i), "m" (v->counter)); |
38 | } | 38 | } |
39 | 39 | ||
40 | static __inline__ void local_sub(unsigned long i, local_t *v) | 40 | static __inline__ void local_sub(long i, local_t *v) |
41 | { | 41 | { |
42 | __asm__ __volatile__( | 42 | __asm__ __volatile__( |
43 | "subl %1,%0" | 43 | "subl %1,%0" |
diff --git a/include/asm-x86_64/local.h b/include/asm-x86_64/local.h index bf148037d4e5..cd17945bf218 100644 --- a/include/asm-x86_64/local.h +++ b/include/asm-x86_64/local.h | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | typedef struct | 6 | typedef struct |
7 | { | 7 | { |
8 | volatile unsigned long counter; | 8 | volatile long counter; |
9 | } local_t; | 9 | } local_t; |
10 | 10 | ||
11 | #define LOCAL_INIT(i) { (i) } | 11 | #define LOCAL_INIT(i) { (i) } |
@@ -13,7 +13,7 @@ typedef struct | |||
13 | #define local_read(v) ((v)->counter) | 13 | #define local_read(v) ((v)->counter) |
14 | #define local_set(v,i) (((v)->counter) = (i)) | 14 | #define local_set(v,i) (((v)->counter) = (i)) |
15 | 15 | ||
16 | static __inline__ void local_inc(local_t *v) | 16 | static inline void local_inc(local_t *v) |
17 | { | 17 | { |
18 | __asm__ __volatile__( | 18 | __asm__ __volatile__( |
19 | "incq %0" | 19 | "incq %0" |
@@ -21,7 +21,7 @@ static __inline__ void local_inc(local_t *v) | |||
21 | :"m" (v->counter)); | 21 | :"m" (v->counter)); |
22 | } | 22 | } |
23 | 23 | ||
24 | static __inline__ void local_dec(local_t *v) | 24 | static inline void local_dec(local_t *v) |
25 | { | 25 | { |
26 | __asm__ __volatile__( | 26 | __asm__ __volatile__( |
27 | "decq %0" | 27 | "decq %0" |
@@ -29,7 +29,7 @@ static __inline__ void local_dec(local_t *v) | |||
29 | :"m" (v->counter)); | 29 | :"m" (v->counter)); |
30 | } | 30 | } |
31 | 31 | ||
32 | static __inline__ void local_add(unsigned int i, local_t *v) | 32 | static inline void local_add(long i, local_t *v) |
33 | { | 33 | { |
34 | __asm__ __volatile__( | 34 | __asm__ __volatile__( |
35 | "addq %1,%0" | 35 | "addq %1,%0" |
@@ -37,7 +37,7 @@ static __inline__ void local_add(unsigned int i, local_t *v) | |||
37 | :"ir" (i), "m" (v->counter)); | 37 | :"ir" (i), "m" (v->counter)); |
38 | } | 38 | } |
39 | 39 | ||
40 | static __inline__ void local_sub(unsigned int i, local_t *v) | 40 | static inline void local_sub(long i, local_t *v) |
41 | { | 41 | { |
42 | __asm__ __volatile__( | 42 | __asm__ __volatile__( |
43 | "subq %1,%0" | 43 | "subq %1,%0" |