249 |
|
} |
250 |
|
#endif |
251 |
|
|
252 |
< |
#ifdef __i386__ |
252 |
> |
#if defined(__i386__) || defined(__x86_64__) |
253 |
|
#define HAVE_TEST_AND_SET 1 |
254 |
|
static inline int testandset(volatile int *p) |
255 |
|
{ |
256 |
< |
int ret; |
257 |
< |
long int readval; |
256 |
> |
long int ret; |
257 |
|
/* Note: the "xchg" instruction does not need a "lock" prefix */ |
258 |
< |
__asm__ __volatile__("xchgl %0, %1" |
259 |
< |
: "=r" (ret), "=m" (*p), "=a" (readval) |
258 |
> |
__asm__ __volatile__("xchgl %k0, %1" |
259 |
> |
: "=r" (ret), "=m" (*p) |
260 |
|
: "0" (1), "m" (*p) |
261 |
|
: "memory"); |
262 |
|
return ret; |