From 7c360a10075cb465f635f897a42fa3d899311f3e Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 9 Dec 2005 14:11:44 +0000 Subject: [PATCH] Removed the x86 specific __compare_and_swap() implementation and added a generic implementation using atomic_test_and_set(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15444 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../posix/glibc/include/bits/libc-lock.h | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) 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 {