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
This commit is contained in:
Ingo Weinhold 2005-12-09 14:11:44 +00:00
parent 0799002097
commit 7c360a1007

View File

@ -5,8 +5,9 @@
#ifndef _BITS_LIBC_LOCK_H
#define _BITS_LIBC_LOCK_H 1
#include <OS.h>
#include <Errors.h>
#include <OS.h>
#include <SupportDefs.h>
/* 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 {