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:
@@ -5,8 +5,9 @@
|
|||||||
#ifndef _BITS_LIBC_LOCK_H
|
#ifndef _BITS_LIBC_LOCK_H
|
||||||
#define _BITS_LIBC_LOCK_H 1
|
#define _BITS_LIBC_LOCK_H 1
|
||||||
|
|
||||||
#include <OS.h>
|
|
||||||
#include <Errors.h>
|
#include <Errors.h>
|
||||||
|
#include <OS.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
/* Helper definitions and prototypes. */
|
/* Helper definitions and prototypes. */
|
||||||
@@ -15,24 +16,13 @@
|
|||||||
|
|
||||||
extern char _single_threaded;
|
extern char _single_threaded;
|
||||||
|
|
||||||
#ifdef __INTEL__
|
|
||||||
|
|
||||||
// ToDo: this does not belong here!
|
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
__compare_and_swap (volatile int32 *p, int oldval, int newval)
|
__compare_and_swap (volatile int32 *p, int oldval, int newval)
|
||||||
{
|
{
|
||||||
char ret;
|
int32 readval = atomic_test_and_set(p, newval, oldval);
|
||||||
long int readval;
|
return (readval == oldval ? 1 : 0);
|
||||||
|
|
||||||
__asm__ __volatile__ ("lock; cmpxchgl %3, %1; sete %0"
|
|
||||||
: "=q" (ret), "=m" (*p), "=a" (readval)
|
|
||||||
: "r" (newval), "m" (*p), "a" (oldval));
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Mutex type. */
|
/* Mutex type. */
|
||||||
typedef struct __libc_lock_t {
|
typedef struct __libc_lock_t {
|
||||||
|
|||||||
Reference in New Issue
Block a user