diff --git a/src/system/libroot/posix/glibc/include/bits/libc-lock.h b/src/system/libroot/posix/glibc/include/bits/libc-lock.h index 3852e6ffd7..5a1b5d1811 100644 --- a/src/system/libroot/posix/glibc/include/bits/libc-lock.h +++ b/src/system/libroot/posix/glibc/include/bits/libc-lock.h @@ -5,8 +5,9 @@ #ifndef _BITS_LIBC_LOCK_H #define _BITS_LIBC_LOCK_H 1 -#include #include +#include +#include /* Helper definitions and prototypes. */ @@ -15,24 +16,13 @@ extern char _single_threaded; -#ifdef __INTEL__ - -// ToDo: this does not belong here! - static inline int __compare_and_swap (volatile int32 *p, int oldval, int newval) { - char ret; - long int readval; - - __asm__ __volatile__ ("lock; cmpxchgl %3, %1; sete %0" - : "=q" (ret), "=m" (*p), "=a" (readval) - : "r" (newval), "m" (*p), "a" (oldval)); - return ret; + int32 readval = atomic_test_and_set(p, newval, oldval); + return (readval == oldval ? 1 : 0); } -#endif - /* Mutex type. */ typedef struct __libc_lock_t {