cpu: Atomicity cleanups.

2000-04-24  Nathan Myers  <ncm@cantrip.org>

	* config/cpu: Atomicity cleanups.
	* config/cpu/alpha/bits: New directory.
	* config/cpu/arm/bits: New directory.
	* config/cpu/generic/bits: New directory.
	* config/cpu/i386/bits: New directory.
	* config/cpu/powerpc/bits: New directory.
	* config/cpu/sparc/sparc32/bits: New directory.
	* config/cpu/sparc/sparc32/bits: New directory.
	* config/cpu/*/bits: Move atomicity.h files to here.

From-SVN: r33438
This commit is contained in:
Nathan Myers 2000-04-26 02:51:12 +00:00 committed by Benjamin Kosnik
parent 369edff185
commit f17d6c73de
7 changed files with 159 additions and 190 deletions

View File

@ -17,22 +17,16 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#ifndef _ATOMICITY_H #ifndef _BITS_ATOMICITY_H
#define _ATOMICITY_H 1 #define _BITS_ATOMICITY_H 1
#ifdef _GLIBCPP_HAVE_INTTYPES_H typedef int _Atomic_word;
#include <inttypes.h>
#else
typedef unsigned int uint32_t;
typedef int int32_t;
#endif
static inline _Atomic_word
static inline int
__attribute__ ((unused)) __attribute__ ((unused))
exchange_and_add (volatile uint32_t *mem, int val) __exchange_and_add (volatile _Atomic_word* __mem, int __val)
{ {
register int result, tmp; register int __result, __tmp;
__asm__ __volatile__ ( __asm__ __volatile__ (
"/* Inline exchange & add */\n" "/* Inline exchange & add */\n"
@ -47,17 +41,17 @@ exchange_and_add (volatile uint32_t *mem, int val)
".previous\n\t" ".previous\n\t"
"mb\n\t" "mb\n\t"
"/* End exchange & add */" "/* End exchange & add */"
: "=&r"(result), "=&r"(tmp), "=m"(*mem) : "=&r"(__result), "=&r"(__tmp), "=m"(*__mem)
: "m" (*mem), "r"(val)); : "m" (*__mem), "r"(__val));
return result; return __result;
} }
static inline void static inline void
__attribute__ ((unused)) __attribute__ ((unused))
atomic_add (volatile uint32_t *mem, int val) __atomic_add (volatile _Atomic_word* __mem, int __val)
{ {
register int result; register _Atomic_word __result;
__asm__ __volatile__ ( __asm__ __volatile__ (
"/* Inline exchange & add */\n" "/* Inline exchange & add */\n"
@ -72,15 +66,15 @@ atomic_add (volatile uint32_t *mem, int val)
".previous\n\t" ".previous\n\t"
"mb\n\t" "mb\n\t"
"/* End exchange & add */" "/* End exchange & add */"
: "=&r"(result), "=m"(*mem) : "=&r"(__result), "=m"(*__mem)
: "m" (*mem), "r"(val)); : "m" (*__mem), "r"(__val));
} }
static inline long static inline intint
__attribute__ ((unused)) __attribute__ ((unused))
compare_and_swap (volatile long int *p, long int oldval, long int newval) __compare_and_swap (volatile long *__p, long __oldval, long __newval)
{ {
long int ret; int __ret;
__asm__ __volatile__ ( __asm__ __volatile__ (
"/* Inline compare & swap */\n" "/* Inline compare & swap */\n"
@ -98,16 +92,10 @@ compare_and_swap (volatile long int *p, long int oldval, long int newval)
"3:\t" "3:\t"
"mb\n\t" "mb\n\t"
"/* End compare & swap */" "/* End compare & swap */"
: "=&r"(ret), "=m"(*p) : "=&r"(__ret), "=m"(*__p)
: "r"(oldval), "r"(newval), "m"(*p)); : "r"(__oldval), "r"(__newval), "m"(*__p));
return ret; return __ret;
} }
#endif /* atomicity.h */ #endif /* atomicity.h */

View File

@ -17,21 +17,16 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#ifndef _ATOMICITY_H #ifndef _BITS_ATOMICITY_H
#define _ATOMICITY_H 1 #define _BITS_ATOMICITY_H 1
#ifdef _GLIBCPP_HAVE_INTTYPES_H typedef int _Atomic_word;
#include <inttypes.h>
#else
typedef unsigned int uint32_t;
typedef int int32_t;
#endif
static inline int static inline _Atomic_word
__attribute__ ((unused)) __attribute__ ((unused))
exchange_and_add (volatile uint32_t *mem, int val) __exchange_and_add (volatile _Atomic_word* __mem, int __val)
{ {
int tmp, tmp2, result; _Atomic_word __tmp, __tmp2, __result;
__asm__ ("\ __asm__ ("\
0: ldr %0,[%3] 0: ldr %0,[%3]
add %1,%0,%4 add %1,%0,%4
@ -39,15 +34,17 @@ exchange_and_add (volatile uint32_t *mem, int val)
cmp %0,%2 cmp %0,%2
swpne %1,%2,[%3] swpne %1,%2,[%3]
bne 0b bne 0b
" : "=&r"(result), "=&r"(tmp), "=&r"(tmp2) : "r" (mem), "r"(val) : "cc", "memory"); " : "=&r"(__result), "=&r"(__tmp), "=&r"(__tmp2)
return result; : "r" (__mem), "r"(__val)
: "cc", "memory");
return __result;
} }
static inline void static inline void
__attribute__ ((unused)) __attribute__ ((unused))
atomic_add (volatile uint32_t *mem, int val) __atomic_add (volatile _Atomic_word *__mem, int __val)
{ {
int tmp, tmp2, tmp3; _Atomic_word __tmp, __tmp2, __tmp3;
__asm__ ("\ __asm__ ("\
0: ldr %0,[%3] 0: ldr %0,[%3]
add %1,%0,%4 add %1,%0,%4
@ -55,14 +52,17 @@ atomic_add (volatile uint32_t *mem, int val)
cmp %0,%2 cmp %0,%2
swpne %1,%2,[%3] swpne %1,%2,[%3]
bne 0b bne 0b
" : "=&r"(tmp), "=&r"(tmp2), "=&r"(tmp3) : "r" (mem), "r"(val) : "cc", "memory"); " : "=&r"(__tmp), "=&r"(__tmp2), "=&r"(__tmp3)
: "r" (__mem), "r"(__val)
: "cc", "memory");
} }
static inline int static inline int
__attribute__ ((unused)) __attribute__ ((unused))
compare_and_swap (volatile long int *p, long int oldval, long int newval) __compare_and_swap (volatile long *__p, long __oldval, long __newval)
{ {
int result, tmp; int __result;
long __tmp;
__asm__ ("\ __asm__ ("\
0: ldr %1,[%2] 0: ldr %1,[%2]
mov %0,#0 mov %0,#0
@ -74,25 +74,29 @@ compare_and_swap (volatile long int *p, long int oldval, long int newval)
bne 0b bne 0b
mov %0,#1 mov %0,#1
1: 1:
" : "=&r"(result), "=&r"(tmp) : "r" (p), "r" (newval), "r" (oldval) : "cc", "memory"); " : "=&r"(__result), "=&r"(__tmp)
: "r" (__p), "r" (__newval), "r" (__oldval)
: "cc", "memory");
return __result;
} }
static inline long int static inline long
__attribute__ ((unused)) __attribute__ ((unused))
always_swap (volatile long int *p, long int newval) __always_swap (volatile long *__p, long __newval)
{ {
long int result; long __result;
__asm__ ("\ __asm__ ("\
swp %0,%2,[%1] swp %0,%2,[%1]
" : "=&r"(result) : "r"(p), "r"(newval) : "memory"); " : "=&r"(__result) : "r"(__p), "r"(__newval) : "memory");
return result; return __result;
} }
static inline int static inline int
__attribute__ ((unused)) __attribute__ ((unused))
test_and_set (volatile long int *p, long int newval) __test_and_set (volatile long *__p, long __newval)
{ {
int result, tmp, tmp2, tmp3; int __result;
long __tmp;
__asm__ ("\ __asm__ ("\
0: ldr %0,[%2] 0: ldr %0,[%2]
cmp %0,#0 cmp %0,#0
@ -102,8 +106,10 @@ test_and_set (volatile long int *p, long int newval)
swpne %0,%1,[%2] swpne %0,%1,[%2]
bne 0b bne 0b
1: 1:
" : "=&r"(result), "=r" (tmp) : "r"(p), "r"(newval) : "cc", "memory"); " : "=&r"(__result), "=r" (__tmp)
return result; : "r"(__p), "r"(__newval)
: "cc", "memory");
return __result;
} }
#endif /* atomicity.h */ #endif /* atomicity.h */

View File

@ -17,41 +17,35 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#ifndef _ATOMICITY_H #ifndef _BITS_ATOMICITY_H
#define _ATOMICITY_H 1 #define _BITS_ATOMICITY_H 1
#ifdef _GLIBCPP_HAVE_INTTYPES_H typedef int _Atomic_word;
#include <inttypes.h>
#else
typedef unsigned int uint32_t;
typedef int int32_t;
#endif
static inline _Atomic_word
static inline int
__attribute__ ((unused)) __attribute__ ((unused))
exchange_and_add (uint32_t *mem, int val) __exchange_and_add (_Atomic_word* __mem, int __val)
{ {
int result = *mem; _Atomic_word __result = *__mem;
*mem += val; *__mem += __val;
return result; return __result;
} }
static inline void static inline void
__attribute__ ((unused)) __attribute__ ((unused))
atomic_add (uint32_t *mem, int val) __atomic_add (_Atomic_word* __mem, int __val)
{ {
*mem += val; *__mem += __val;
} }
static inline int static inline int
__attribute__ ((unused)) __attribute__ ((unused))
compare_and_swap (long int *p, long int oldval, long int newval) __compare_and_swap (long *__p, long __oldval, long __newval)
{ {
if (*p != oldval) if (*__p != __oldval)
return 0; return 0;
*p = newval; *__p = __newval;
return 1; return 1;
} }

View File

@ -17,46 +17,42 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#ifndef _ATOMICITY_H #ifndef _BITS_ATOMICITY_H
#define _ATOMICITY_H 1 #define _BITS_ATOMICITY_H 1
#ifdef _GLIBCPP_HAVE_INTTYPES_H typedef int _Atomic_word;
#include <inttypes.h>
#else
typedef unsigned int uint32_t;
typedef int int32_t;
#endif
static inline _Atomic_word
static inline int
__attribute__ ((unused)) __attribute__ ((unused))
exchange_and_add (volatile uint32_t *mem, int val) __exchange_and_add (volatile _Atomic_word *__mem, int __val)
{ {
register int result; register _Atomic_word __result;
__asm__ __volatile__ ("lock; xaddl %0,%2" __asm__ __volatile__ ("lock; xaddl %0,%2"
: "=r" (result) : "0" (val), "m" (*mem) : "memory"); : "=r" (__result)
return result; : "0" (__val), "m" (*__mem)
: "memory");
return __result;
} }
static inline void static inline void
__attribute__ ((unused)) __attribute__ ((unused))
atomic_add (volatile uint32_t *mem, int val) __atomic_add (volatile _Atomic_word* __mem, int __val)
{ {
__asm__ __volatile__ ("lock; addl %0,%1" __asm__ __volatile__ ("lock; addl %0,%1"
: : "ir" (val), "m" (*mem) : "memory"); : : "ir" (__val), "m" (*__mem) : "memory");
} }
static inline char static inline char
__attribute__ ((unused)) __attribute__ ((unused))
compare_and_swap (volatile long int *p, long int oldval, long int newval) __compare_and_swap (volatile long* __p, long __oldval, long __newval)
{ {
char ret; char __ret;
long int readval; long __readval;
__asm__ __volatile__ ("lock; cmpxchgl %3, %1; sete %0" __asm__ __volatile__ ("lock; cmpxchgl %3, %1; sete %0"
: "=q" (ret), "=m" (*p), "=a" (readval) : "=q" (__ret), "=m" (*__p), "=a" (__readval)
: "r" (newval), "m" (*p), "a" (oldval)); : "r" (__newval), "m" (*__p), "a" (__oldval));
return ret; return __ret;
} }
#endif /* atomicity.h */ #endif /* atomicity.h */

View File

@ -17,16 +17,10 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#ifndef _ATOMICITY_H #ifndef _BITS_ATOMICITY_H
#define _ATOMICITY_H 1 #define _BITS_ATOMICITY_H 1
#ifdef _GLIBCPP_HAVE_INTTYPES_H
#include <inttypes.h>
#else
typedef unsigned int uint32_t;
typedef int int32_t;
#endif
typedef int _Atomic_word;
#if BROKEN_PPC_ASM_CR0 #if BROKEN_PPC_ASM_CR0
# define __ATOMICITY_INLINE /* nothing */ # define __ATOMICITY_INLINE /* nothing */
@ -34,38 +28,38 @@ typedef int int32_t;
# define __ATOMICITY_INLINE inline # define __ATOMICITY_INLINE inline
#endif #endif
static __ATOMICITY_INLINE int static __ATOMICITY_INLINE _Atomic_word
__attribute__ ((unused)) __attribute__ ((unused))
exchange_and_add (volatile uint32_t *mem, int val) __exchange_and_add (volatile _Atomic_word* __mem, int __val)
{ {
int tmp, result; _Atomic_word __tmp, __result;
__asm__ ("\ __asm__ ("\
0: lwarx %0,0,%2 0: lwarx %0,0,%2
add%I3 %1,%0,%3 add%I3 %1,%0,%3
stwcx. %1,0,%2 stwcx. %1,0,%2
bne- 0b bne- 0b
" : "=&b"(result), "=&r"(tmp) : "r" (mem), "Ir"(val) : "cr0", "memory"); " : "=&b"(__result), "=&r"(__tmp) : "r" (__mem), "Ir"(__val) : "cr0", "memory");
return result; return __result;
} }
static __ATOMICITY_INLINE void static __ATOMICITY_INLINE void
__attribute__ ((unused)) __attribute__ ((unused))
atomic_add (volatile uint32_t *mem, int val) __atomic_add (volatile _Atomic_word *__mem, int __val)
{ {
int tmp; _Atomic_word __tmp;
__asm__ ("\ __asm__ ("\
0: lwarx %0,0,%1 0: lwarx %0,0,%1
add%I2 %0,%0,%2 add%I2 %0,%0,%2
stwcx. %0,0,%1 stwcx. %0,0,%1
bne- 0b bne- 0b
" : "=&b"(tmp) : "r" (mem), "Ir"(val) : "cr0", "memory"); " : "=&b"(__tmp) : "r" (__mem), "Ir"(__val) : "cr0", "memory");
} }
static __ATOMICITY_INLINE int static __ATOMICITY_INLINE int
__attribute__ ((unused)) __attribute__ ((unused))
compare_and_swap (volatile long int *p, long int oldval, long int newval) __compare_and_swap (volatile long *p, long int __oldval, long int __newval)
{ {
int result; int __result;
__asm__ ("\ __asm__ ("\
0: lwarx %0,0,%1 0: lwarx %0,0,%1
sub%I2c. %0,%0,%2 sub%I2c. %0,%0,%2
@ -74,28 +68,30 @@ compare_and_swap (volatile long int *p, long int oldval, long int newval)
stwcx. %3,0,%1 stwcx. %3,0,%1
bne- 0b bne- 0b
1: 1:
" : "=&b"(result) : "r"(p), "Ir"(oldval), "r"(newval) : "cr0", "memory"); " : "=&b"(__result)
return result >> 5; : "r"(__p), "Ir"(__oldval), "r"(__newval)
: "cr0", "memory");
return __result >> 5;
} }
static __ATOMICITY_INLINE long int static __ATOMICITY_INLINE long
__attribute__ ((unused)) __attribute__ ((unused))
always_swap (volatile long int *p, long int newval) __always_swap (volatile long *__p, long int __newval)
{ {
long int result; long __result;
__asm__ ("\ __asm__ ("\
0: lwarx %0,0,%1 0: lwarx %0,0,%1
stwcx. %2,0,%1 stwcx. %2,0,%1
bne- 0b bne- 0b
" : "=&r"(result) : "r"(p), "r"(newval) : "cr0", "memory"); " : "=&r"(__result) : "r"(__p), "r"(__newval) : "cr0", "memory");
return result; return __result;
} }
static __ATOMICITY_INLINE int static __ATOMICITY_INLINE int
__attribute__ ((unused)) __attribute__ ((unused))
test_and_set (volatile long int *p, long int newval) __test_and_set (volatile long *__p, long int __newval)
{ {
int result; int __result;
__asm__ ("\ __asm__ ("\
0: lwarx %0,0,%1 0: lwarx %0,0,%1
cmpwi %0,0 cmpwi %0,0
@ -103,8 +99,8 @@ test_and_set (volatile long int *p, long int newval)
stwcx. %2,0,%1 stwcx. %2,0,%1
bne- 0b bne- 0b
1: 1:
" : "=&r"(result) : "r"(p), "r"(newval) : "cr0", "memory"); " : "=&r"(__result) : "r"(__p), "r"(__newval) : "cr0", "memory");
return result; return __result;
} }
#endif /* atomicity.h */ #endif /* atomicity.h */

View File

@ -17,88 +17,82 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#ifndef _ATOMICITY_H #ifndef _BITS_ATOMICITY_H
#define _ATOMICITY_H 1 #define _BITS_ATOMICITY_H 1
#ifdef _GLIBCPP_HAVE_INTTYPES_H
#include <inttypes.h>
#else
typedef unsigned int uint32_t;
typedef int int32_t;
#endif
typedef int _Atomic_word;
static int static int
__attribute__ ((unused)) __attribute__ ((unused))
exchange_and_add (volatile uint32_t *mem, int val) __exchange_and_add (volatile _Atomic_word* __mem, int __val)
{ {
static unsigned char lock; static unsigned char __lock;
int result, tmp; _Atomic_word __result, __tmp;
__asm__ __volatile__("1: ldstub [%1], %0\n\t" __asm__ __volatile__("1: ldstub [%1], %0\n\t"
" cmp %0, 0\n\t" " cmp %0, 0\n\t"
" bne 1b\n\t" " bne 1b\n\t"
" nop" " nop"
: "=&r" (tmp) : "=&r" (__tmp)
: "r" (&lock) : "r" (&__lock)
: "memory"); : "memory");
result = *mem; __result = *__mem;
*mem += val; *__mem += __val;
__asm__ __volatile__("stb %%g0, [%0]" __asm__ __volatile__("stb %%g0, [%0]"
: /* no outputs */ : /* no outputs */
: "r" (&lock) : "r" (&__lock)
: "memory"); : "memory");
return result; return __result;
} }
static void static void
__attribute__ ((unused)) __attribute__ ((unused))
atomic_add (volatile uint32_t *mem, int val) __atomic_add (volatile _Atomic_word* __mem, int __val)
{ {
static unsigned char lock; static unsigned char __lock;
int tmp; _Atomic_word __tmp;
__asm__ __volatile__("1: ldstub [%1], %0\n\t" __asm__ __volatile__("1: ldstub [%1], %0\n\t"
" cmp %0, 0\n\t" " cmp %0, 0\n\t"
" bne 1b\n\t" " bne 1b\n\t"
" nop" " nop"
: "=&r" (tmp) : "=&r" (__tmp)
: "r" (&lock) : "r" (&__lock)
: "memory"); : "memory");
*mem += val; *__mem += __val;
__asm__ __volatile__("stb %%g0, [%0]" __asm__ __volatile__("stb %%g0, [%0]"
: /* no outputs */ : /* no outputs */
: "r" (&lock) : "r" (&__lock)
: "memory"); : "memory");
} }
static int static int
__attribute__ ((unused)) __attribute__ ((unused))
compare_and_swap (volatile long int *p, long int oldval, long int newval) __compare_and_swap (volatile long *__p, long __oldval, long __newval)
{ {
static unsigned char lock; static unsigned char __lock;
int ret, tmp; long __ret, __tmp;
__asm__ __volatile__("1: ldstub [%1], %0\n\t" __asm__ __volatile__("1: ldstub [%1], %0\n\t"
" cmp %0, 0\n\t" " cmp %0, 0\n\t"
" bne 1b\n\t" " bne 1b\n\t"
" nop" " nop"
: "=&r" (tmp) : "=&r" (__tmp)
: "r" (&lock) : "r" (&__lock)
: "memory"); : "memory");
if (*p != oldval) if (*__p != __oldval)
ret = 0; __ret = 0;
else else
{ {
*p = newval; *__p = __newval;
ret = 1; __ret = 1;
} }
__asm__ __volatile__("stb %%g0, [%0]" __asm__ __volatile__("stb %%g0, [%0]"
: /* no outputs */ : /* no outputs */
: "r" (&lock) : "r" (&__lock)
: "memory"); : "memory");
return ret; return __ret;
} }
#endif /* atomicity.h */ #endif /* atomicity.h */

View File

@ -17,22 +17,16 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#ifndef _ATOMICITY_H #ifndef _BITS_ATOMICITY_H
#define _ATOMICITY_H 1 #define _BITS_ATOMICITY_H 1
#ifdef _GLIBCPP_HAVE_INTTYPES_H typedef long _Atomic_word;
#include <inttypes.h>
#else
typedef unsigned int uint32_t;
typedef int int32_t;
#endif
static inline _Atomic_word
static inline int
__attribute__ ((unused)) __attribute__ ((unused))
exchange_and_add (volatile uint32_t *mem, int val) __exchange_and_add (volatile _Atomic_word *__mem, int __val)
{ {
uint32_t tmp1, tmp2; _Atomic_word __tmp1, __tmp2;
__asm__ __volatile__("1: lduw [%2], %0\n\t" __asm__ __volatile__("1: lduw [%2], %0\n\t"
" add %0, %3, %1\n\t" " add %0, %3, %1\n\t"
@ -40,17 +34,17 @@ exchange_and_add (volatile uint32_t *mem, int val)
" sub %0, %1, %0\n\t" " sub %0, %1, %0\n\t"
" brnz,pn %0, 1b\n\t" " brnz,pn %0, 1b\n\t"
" nop" " nop"
: "=&r" (tmp1), "=&r" (tmp2) : "=&r" (__tmp1), "=&r" (__tmp2)
: "r" (mem), "r" (val) : "r" (__mem), "r" (__val)
: "memory"); : "memory");
return tmp2; return __tmp2;
} }
static inline void static inline void
__attribute__ ((unused)) __attribute__ ((unused))
atomic_add (volatile uint32_t *mem, int val) __atomic_add (volatile _Atomic_word* __mem, int __val)
{ {
uint32_t tmp1, tmp2; _Atomic_word __tmp1, __tmp2;
__asm__ __volatile__("1: lduw [%2], %0\n\t" __asm__ __volatile__("1: lduw [%2], %0\n\t"
" add %0, %3, %1\n\t" " add %0, %3, %1\n\t"
@ -58,16 +52,17 @@ atomic_add (volatile uint32_t *mem, int val)
" sub %0, %1, %0\n\t" " sub %0, %1, %0\n\t"
" brnz,pn %0, 1b\n\t" " brnz,pn %0, 1b\n\t"
" nop" " nop"
: "=&r" (tmp1), "=&r" (tmp2) : "=&r" (__tmp1), "=&r" (__tmp2)
: "r" (mem), "r" (val) : "r" (__mem), "r" (__val)
: "memory"); : "memory");
} }
static inline int static inline int
__attribute__ ((unused)) __attribute__ ((unused))
compare_and_swap (volatile long int *p, long int oldval, long int newval) __compare_and_swap (volatile long *__p, long __oldval, long __newval)
{ {
register long int tmp, tmp2; register int __tmp,
register long __tmp2;
__asm__ __volatile__("1: ldx [%4], %0\n\t" __asm__ __volatile__("1: ldx [%4], %0\n\t"
" mov %2, %1\n\t" " mov %2, %1\n\t"
@ -79,10 +74,10 @@ compare_and_swap (volatile long int *p, long int oldval, long int newval)
" brnz,pn %0, 1b\n\t" " brnz,pn %0, 1b\n\t"
" mov 1, %0\n\t" " mov 1, %0\n\t"
"2:" "2:"
: "=&r" (tmp), "=&r" (tmp2) : "=&r" (__tmp), "=&r" (__tmp2)
: "r" (newval), "r" (oldval), "r" (p) : "r" (__newval), "r" (__oldval), "r" (__p)
: "memory"); : "memory");
return tmp; return __tmp;
} }
#endif /* atomicity.h */ #endif /* atomicity.h */