Skip to content

Commit

Permalink
x86: introduce asm helpers in local_{32|64}.h
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Harvey Harrison authored and Ingo Molnar committed Jan 30, 2008
1 parent 992b959 commit 8ee5797
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
12 changes: 12 additions & 0 deletions include/asm-x86/asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,25 @@
# define _ASM_ALIGN " .balign 4 "
# define _ASM_MOV_UL " movl "

# define _ASM_INC " incl "
# define _ASM_DEC " decl "
# define _ASM_ADD " addl "
# define _ASM_SUB " subl "
# define _ASM_XADD " xaddl "

#else
/* 64 bits */

# define _ASM_PTR " .quad "
# define _ASM_ALIGN " .balign 8 "
# define _ASM_MOV_UL " movq "

# define _ASM_INC " incq "
# define _ASM_DEC " decq "
# define _ASM_ADD " addq "
# define _ASM_SUB " subq "
# define _ASM_XADD " xaddq "

#endif /* CONFIG_X86_32 */

#endif /* _ASM_X86_ASM_H */
18 changes: 9 additions & 9 deletions include/asm-x86/local_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
static inline void local_inc(local_t *l)
{
__asm__ __volatile__(
"incl %0"
_ASM_INC "%0"
:"+m" (l->a.counter));
}

static inline void local_dec(local_t *l)
{
__asm__ __volatile__(
"decl %0"
_ASM_DEC "%0"
:"+m" (l->a.counter));
}

static inline void local_add(long i, local_t *l)
{
__asm__ __volatile__(
"addl %1,%0"
_ASM_ADD "%1,%0"
:"+m" (l->a.counter)
:"ir" (i));
}

static inline void local_sub(long i, local_t *l)
{
__asm__ __volatile__(
"subl %1,%0"
_ASM_SUB "%1,%0"
:"+m" (l->a.counter)
:"ir" (i));
}
Expand All @@ -45,7 +45,7 @@ static inline int local_sub_and_test(long i, local_t *l)
unsigned char c;

__asm__ __volatile__(
"subl %2,%0; sete %1"
_ASM_SUB "%2,%0; sete %1"
:"+m" (l->a.counter), "=qm" (c)
:"ir" (i) : "memory");
return c;
Expand All @@ -64,7 +64,7 @@ static inline int local_dec_and_test(local_t *l)
unsigned char c;

__asm__ __volatile__(
"decl %0; sete %1"
_ASM_DEC "%0; sete %1"
:"+m" (l->a.counter), "=qm" (c)
: : "memory");
return c != 0;
Expand All @@ -83,7 +83,7 @@ static inline int local_inc_and_test(local_t *l)
unsigned char c;

__asm__ __volatile__(
"incl %0; sete %1"
_ASM_INC "%0; sete %1"
:"+m" (l->a.counter), "=qm" (c)
: : "memory");
return c != 0;
Expand All @@ -103,7 +103,7 @@ static inline int local_add_negative(long i, local_t *l)
unsigned char c;

__asm__ __volatile__(
"addl %2,%0; sets %1"
_ASM_ADD "%2,%0; sets %1"
:"+m" (l->a.counter), "=qm" (c)
:"ir" (i) : "memory");
return c;
Expand All @@ -127,7 +127,7 @@ static inline long local_add_return(long i, local_t *l)
/* Modern 486+ processor */
__i = i;
__asm__ __volatile__(
"xaddl %0, %1;"
_ASM_XADD "%0, %1;"
:"+r" (i), "+m" (l->a.counter)
: : "memory");
return i + __i;
Expand Down
18 changes: 9 additions & 9 deletions include/asm-x86/local_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
static inline void local_inc(local_t *l)
{
__asm__ __volatile__(
"incq %0"
_ASM_INC "%0"
:"+m" (l->a.counter));
}

static inline void local_dec(local_t *l)
{
__asm__ __volatile__(
"decq %0"
_ASM_DEC "%0"
:"+m" (l->a.counter));
}

static inline void local_add(long i, local_t *l)
{
__asm__ __volatile__(
"addq %1,%0"
_ASM_ADD "%1,%0"
:"+m" (l->a.counter)
:"ir" (i));
}

static inline void local_sub(long i, local_t *l)
{
__asm__ __volatile__(
"subq %1,%0"
_ASM_SUB "%1,%0"
:"+m" (l->a.counter)
:"ir" (i));
}
Expand All @@ -45,7 +45,7 @@ static inline int local_sub_and_test(long i, local_t *l)
unsigned char c;

__asm__ __volatile__(
"subq %2,%0; sete %1"
_ASM_SUB "%2,%0; sete %1"
:"+m" (l->a.counter), "=qm" (c)
:"ir" (i) : "memory");
return c;
Expand All @@ -64,7 +64,7 @@ static inline int local_dec_and_test(local_t *l)
unsigned char c;

__asm__ __volatile__(
"decq %0; sete %1"
_ASM_DEC "%0; sete %1"
:"+m" (l->a.counter), "=qm" (c)
: : "memory");
return c != 0;
Expand All @@ -83,7 +83,7 @@ static inline int local_inc_and_test(local_t *l)
unsigned char c;

__asm__ __volatile__(
"incq %0; sete %1"
_ASM_INC "%0; sete %1"
:"+m" (l->a.counter), "=qm" (c)
: : "memory");
return c != 0;
Expand All @@ -103,7 +103,7 @@ static inline int local_add_negative(long i, local_t *l)
unsigned char c;

__asm__ __volatile__(
"addq %2,%0; sets %1"
_ASM_ADD "%2,%0; sets %1"
:"+m" (l->a.counter), "=qm" (c)
:"ir" (i) : "memory");
return c;
Expand All @@ -120,7 +120,7 @@ static inline long local_add_return(long i, local_t *l)
{
long __i = i;
__asm__ __volatile__(
"xaddq %0, %1;"
_ASM_XADD "%0, %1;"
:"+r" (i), "+m" (l->a.counter)
: : "memory");
return i + __i;
Expand Down

0 comments on commit 8ee5797

Please sign in to comment.