diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-01-30 07:31:26 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:31:26 -0500 |
commit | 8ee5797a91bdb713b4031741b33bd035f9c43870 (patch) | |
tree | 1ce447909c7b2d43f88631180b72d67bd02d6f83 | |
parent | 992b95920a311db3267659ea17160e4812a05830 (diff) |
x86: introduce asm helpers in local_{32|64}.h
Handle the use of long on X86_32 and quad on X86_64
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | include/asm-x86/asm.h | 12 | ||||
-rw-r--r-- | include/asm-x86/local_32.h | 18 | ||||
-rw-r--r-- | include/asm-x86/local_64.h | 18 |
3 files changed, 30 insertions, 18 deletions
diff --git a/include/asm-x86/asm.h b/include/asm-x86/asm.h index 8661ae75488a..1a6980a60fc6 100644 --- a/include/asm-x86/asm.h +++ b/include/asm-x86/asm.h | |||
@@ -8,6 +8,12 @@ | |||
8 | # define _ASM_ALIGN " .balign 4 " | 8 | # define _ASM_ALIGN " .balign 4 " |
9 | # define _ASM_MOV_UL " movl " | 9 | # define _ASM_MOV_UL " movl " |
10 | 10 | ||
11 | # define _ASM_INC " incl " | ||
12 | # define _ASM_DEC " decl " | ||
13 | # define _ASM_ADD " addl " | ||
14 | # define _ASM_SUB " subl " | ||
15 | # define _ASM_XADD " xaddl " | ||
16 | |||
11 | #else | 17 | #else |
12 | /* 64 bits */ | 18 | /* 64 bits */ |
13 | 19 | ||
@@ -15,6 +21,12 @@ | |||
15 | # define _ASM_ALIGN " .balign 8 " | 21 | # define _ASM_ALIGN " .balign 8 " |
16 | # define _ASM_MOV_UL " movq " | 22 | # define _ASM_MOV_UL " movq " |
17 | 23 | ||
24 | # define _ASM_INC " incq " | ||
25 | # define _ASM_DEC " decq " | ||
26 | # define _ASM_ADD " addq " | ||
27 | # define _ASM_SUB " subq " | ||
28 | # define _ASM_XADD " xaddq " | ||
29 | |||
18 | #endif /* CONFIG_X86_32 */ | 30 | #endif /* CONFIG_X86_32 */ |
19 | 31 | ||
20 | #endif /* _ASM_X86_ASM_H */ | 32 | #endif /* _ASM_X86_ASM_H */ |
diff --git a/include/asm-x86/local_32.h b/include/asm-x86/local_32.h index 33d9c7bf463c..c219fe56b3df 100644 --- a/include/asm-x86/local_32.h +++ b/include/asm-x86/local_32.h | |||
@@ -4,21 +4,21 @@ | |||
4 | static inline void local_inc(local_t *l) | 4 | static inline void local_inc(local_t *l) |
5 | { | 5 | { |
6 | __asm__ __volatile__( | 6 | __asm__ __volatile__( |
7 | "incl %0" | 7 | _ASM_INC "%0" |
8 | :"+m" (l->a.counter)); | 8 | :"+m" (l->a.counter)); |
9 | } | 9 | } |
10 | 10 | ||
11 | static inline void local_dec(local_t *l) | 11 | static inline void local_dec(local_t *l) |
12 | { | 12 | { |
13 | __asm__ __volatile__( | 13 | __asm__ __volatile__( |
14 | "decl %0" | 14 | _ASM_DEC "%0" |
15 | :"+m" (l->a.counter)); | 15 | :"+m" (l->a.counter)); |
16 | } | 16 | } |
17 | 17 | ||
18 | static inline void local_add(long i, local_t *l) | 18 | static inline void local_add(long i, local_t *l) |
19 | { | 19 | { |
20 | __asm__ __volatile__( | 20 | __asm__ __volatile__( |
21 | "addl %1,%0" | 21 | _ASM_ADD "%1,%0" |
22 | :"+m" (l->a.counter) | 22 | :"+m" (l->a.counter) |
23 | :"ir" (i)); | 23 | :"ir" (i)); |
24 | } | 24 | } |
@@ -26,7 +26,7 @@ static inline void local_add(long i, local_t *l) | |||
26 | static inline void local_sub(long i, local_t *l) | 26 | static inline void local_sub(long i, local_t *l) |
27 | { | 27 | { |
28 | __asm__ __volatile__( | 28 | __asm__ __volatile__( |
29 | "subl %1,%0" | 29 | _ASM_SUB "%1,%0" |
30 | :"+m" (l->a.counter) | 30 | :"+m" (l->a.counter) |
31 | :"ir" (i)); | 31 | :"ir" (i)); |
32 | } | 32 | } |
@@ -45,7 +45,7 @@ static inline int local_sub_and_test(long i, local_t *l) | |||
45 | unsigned char c; | 45 | unsigned char c; |
46 | 46 | ||
47 | __asm__ __volatile__( | 47 | __asm__ __volatile__( |
48 | "subl %2,%0; sete %1" | 48 | _ASM_SUB "%2,%0; sete %1" |
49 | :"+m" (l->a.counter), "=qm" (c) | 49 | :"+m" (l->a.counter), "=qm" (c) |
50 | :"ir" (i) : "memory"); | 50 | :"ir" (i) : "memory"); |
51 | return c; | 51 | return c; |
@@ -64,7 +64,7 @@ static inline int local_dec_and_test(local_t *l) | |||
64 | unsigned char c; | 64 | unsigned char c; |
65 | 65 | ||
66 | __asm__ __volatile__( | 66 | __asm__ __volatile__( |
67 | "decl %0; sete %1" | 67 | _ASM_DEC "%0; sete %1" |
68 | :"+m" (l->a.counter), "=qm" (c) | 68 | :"+m" (l->a.counter), "=qm" (c) |
69 | : : "memory"); | 69 | : : "memory"); |
70 | return c != 0; | 70 | return c != 0; |
@@ -83,7 +83,7 @@ static inline int local_inc_and_test(local_t *l) | |||
83 | unsigned char c; | 83 | unsigned char c; |
84 | 84 | ||
85 | __asm__ __volatile__( | 85 | __asm__ __volatile__( |
86 | "incl %0; sete %1" | 86 | _ASM_INC "%0; sete %1" |
87 | :"+m" (l->a.counter), "=qm" (c) | 87 | :"+m" (l->a.counter), "=qm" (c) |
88 | : : "memory"); | 88 | : : "memory"); |
89 | return c != 0; | 89 | return c != 0; |
@@ -103,7 +103,7 @@ static inline int local_add_negative(long i, local_t *l) | |||
103 | unsigned char c; | 103 | unsigned char c; |
104 | 104 | ||
105 | __asm__ __volatile__( | 105 | __asm__ __volatile__( |
106 | "addl %2,%0; sets %1" | 106 | _ASM_ADD "%2,%0; sets %1" |
107 | :"+m" (l->a.counter), "=qm" (c) | 107 | :"+m" (l->a.counter), "=qm" (c) |
108 | :"ir" (i) : "memory"); | 108 | :"ir" (i) : "memory"); |
109 | return c; | 109 | return c; |
@@ -127,7 +127,7 @@ static inline long local_add_return(long i, local_t *l) | |||
127 | /* Modern 486+ processor */ | 127 | /* Modern 486+ processor */ |
128 | __i = i; | 128 | __i = i; |
129 | __asm__ __volatile__( | 129 | __asm__ __volatile__( |
130 | "xaddl %0, %1;" | 130 | _ASM_XADD "%0, %1;" |
131 | :"+r" (i), "+m" (l->a.counter) | 131 | :"+r" (i), "+m" (l->a.counter) |
132 | : : "memory"); | 132 | : : "memory"); |
133 | return i + __i; | 133 | return i + __i; |
diff --git a/include/asm-x86/local_64.h b/include/asm-x86/local_64.h index 50e99eddd628..d685cd7e014f 100644 --- a/include/asm-x86/local_64.h +++ b/include/asm-x86/local_64.h | |||
@@ -4,21 +4,21 @@ | |||
4 | static inline void local_inc(local_t *l) | 4 | static inline void local_inc(local_t *l) |
5 | { | 5 | { |
6 | __asm__ __volatile__( | 6 | __asm__ __volatile__( |
7 | "incq %0" | 7 | _ASM_INC "%0" |
8 | :"+m" (l->a.counter)); | 8 | :"+m" (l->a.counter)); |
9 | } | 9 | } |
10 | 10 | ||
11 | static inline void local_dec(local_t *l) | 11 | static inline void local_dec(local_t *l) |
12 | { | 12 | { |
13 | __asm__ __volatile__( | 13 | __asm__ __volatile__( |
14 | "decq %0" | 14 | _ASM_DEC "%0" |
15 | :"+m" (l->a.counter)); | 15 | :"+m" (l->a.counter)); |
16 | } | 16 | } |
17 | 17 | ||
18 | static inline void local_add(long i, local_t *l) | 18 | static inline void local_add(long i, local_t *l) |
19 | { | 19 | { |
20 | __asm__ __volatile__( | 20 | __asm__ __volatile__( |
21 | "addq %1,%0" | 21 | _ASM_ADD "%1,%0" |
22 | :"+m" (l->a.counter) | 22 | :"+m" (l->a.counter) |
23 | :"ir" (i)); | 23 | :"ir" (i)); |
24 | } | 24 | } |
@@ -26,7 +26,7 @@ static inline void local_add(long i, local_t *l) | |||
26 | static inline void local_sub(long i, local_t *l) | 26 | static inline void local_sub(long i, local_t *l) |
27 | { | 27 | { |
28 | __asm__ __volatile__( | 28 | __asm__ __volatile__( |
29 | "subq %1,%0" | 29 | _ASM_SUB "%1,%0" |
30 | :"+m" (l->a.counter) | 30 | :"+m" (l->a.counter) |
31 | :"ir" (i)); | 31 | :"ir" (i)); |
32 | } | 32 | } |
@@ -45,7 +45,7 @@ static inline int local_sub_and_test(long i, local_t *l) | |||
45 | unsigned char c; | 45 | unsigned char c; |
46 | 46 | ||
47 | __asm__ __volatile__( | 47 | __asm__ __volatile__( |
48 | "subq %2,%0; sete %1" | 48 | _ASM_SUB "%2,%0; sete %1" |
49 | :"+m" (l->a.counter), "=qm" (c) | 49 | :"+m" (l->a.counter), "=qm" (c) |
50 | :"ir" (i) : "memory"); | 50 | :"ir" (i) : "memory"); |
51 | return c; | 51 | return c; |
@@ -64,7 +64,7 @@ static inline int local_dec_and_test(local_t *l) | |||
64 | unsigned char c; | 64 | unsigned char c; |
65 | 65 | ||
66 | __asm__ __volatile__( | 66 | __asm__ __volatile__( |
67 | "decq %0; sete %1" | 67 | _ASM_DEC "%0; sete %1" |
68 | :"+m" (l->a.counter), "=qm" (c) | 68 | :"+m" (l->a.counter), "=qm" (c) |
69 | : : "memory"); | 69 | : : "memory"); |
70 | return c != 0; | 70 | return c != 0; |
@@ -83,7 +83,7 @@ static inline int local_inc_and_test(local_t *l) | |||
83 | unsigned char c; | 83 | unsigned char c; |
84 | 84 | ||
85 | __asm__ __volatile__( | 85 | __asm__ __volatile__( |
86 | "incq %0; sete %1" | 86 | _ASM_INC "%0; sete %1" |
87 | :"+m" (l->a.counter), "=qm" (c) | 87 | :"+m" (l->a.counter), "=qm" (c) |
88 | : : "memory"); | 88 | : : "memory"); |
89 | return c != 0; | 89 | return c != 0; |
@@ -103,7 +103,7 @@ static inline int local_add_negative(long i, local_t *l) | |||
103 | unsigned char c; | 103 | unsigned char c; |
104 | 104 | ||
105 | __asm__ __volatile__( | 105 | __asm__ __volatile__( |
106 | "addq %2,%0; sets %1" | 106 | _ASM_ADD "%2,%0; sets %1" |
107 | :"+m" (l->a.counter), "=qm" (c) | 107 | :"+m" (l->a.counter), "=qm" (c) |
108 | :"ir" (i) : "memory"); | 108 | :"ir" (i) : "memory"); |
109 | return c; | 109 | return c; |
@@ -120,7 +120,7 @@ static inline long local_add_return(long i, local_t *l) | |||
120 | { | 120 | { |
121 | long __i = i; | 121 | long __i = i; |
122 | __asm__ __volatile__( | 122 | __asm__ __volatile__( |
123 | "xaddq %0, %1;" | 123 | _ASM_XADD "%0, %1;" |
124 | :"+r" (i), "+m" (l->a.counter) | 124 | :"+r" (i), "+m" (l->a.counter) |
125 | : : "memory"); | 125 | : : "memory"); |
126 | return i + __i; | 126 | return i + __i; |