Commit 7eef40d4 authored by Alexandre Julliard's avatar Alexandre Julliard

libport: Get rid of interlocked functions.

parent 2633a5c1
...@@ -352,133 +352,6 @@ int usleep (unsigned int useconds); ...@@ -352,133 +352,6 @@ int usleep (unsigned int useconds);
extern int mkstemps(char *template, int suffix_len); extern int mkstemps(char *template, int suffix_len);
/* Interlocked functions */
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
static inline int interlocked_cmpxchg( int *dest, int xchg, int compare )
{
int ret;
__asm__ __volatile__( "lock; cmpxchgl %2,(%1)"
: "=a" (ret) : "r" (dest), "r" (xchg), "0" (compare) : "memory" );
return ret;
}
static inline void *interlocked_cmpxchg_ptr( void **dest, void *xchg, void *compare )
{
void *ret;
#ifdef __x86_64__
__asm__ __volatile__( "lock; cmpxchgq %2,(%1)"
: "=a" (ret) : "r" (dest), "r" (xchg), "0" (compare) : "memory" );
#else
__asm__ __volatile__( "lock; cmpxchgl %2,(%1)"
: "=a" (ret) : "r" (dest), "r" (xchg), "0" (compare) : "memory" );
#endif
return ret;
}
static inline int interlocked_xchg( int *dest, int val )
{
int ret;
__asm__ __volatile__( "lock; xchgl %0,(%1)"
: "=r" (ret) : "r" (dest), "0" (val) : "memory" );
return ret;
}
static inline void *interlocked_xchg_ptr( void **dest, void *val )
{
void *ret;
#ifdef __x86_64__
__asm__ __volatile__( "lock; xchgq %0,(%1)"
: "=r" (ret) :"r" (dest), "0" (val) : "memory" );
#else
__asm__ __volatile__( "lock; xchgl %0,(%1)"
: "=r" (ret) : "r" (dest), "0" (val) : "memory" );
#endif
return ret;
}
static inline int interlocked_xchg_add( int *dest, int incr )
{
int ret;
__asm__ __volatile__( "lock; xaddl %0,(%1)"
: "=r" (ret) : "r" (dest), "0" (incr) : "memory" );
return ret;
}
#ifdef __x86_64__
static inline unsigned char interlocked_cmpxchg128( __int64 *dest, __int64 xchg_high,
__int64 xchg_low, __int64 *compare )
{
unsigned char ret;
__asm__ __volatile__( "lock cmpxchg16b %0; setz %b2"
: "=m" (dest[0]), "=m" (dest[1]), "=r" (ret),
"=a" (compare[0]), "=d" (compare[1])
: "m" (dest[0]), "m" (dest[1]), "3" (compare[0]), "4" (compare[1]),
"c" (xchg_high), "b" (xchg_low) );
return ret;
}
#endif
#else /* __GNUC__ */
#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
static inline int interlocked_cmpxchg( int *dest, int xchg, int compare )
{
return __sync_val_compare_and_swap( dest, compare, xchg );
}
static inline int interlocked_xchg_add( int *dest, int incr )
{
return __sync_fetch_and_add( dest, incr );
}
static inline int interlocked_xchg( int *dest, int val )
{
int ret;
do ret = *dest; while (!__sync_bool_compare_and_swap( dest, ret, val ));
return ret;
}
#else
extern int interlocked_cmpxchg( int *dest, int xchg, int compare );
extern int interlocked_xchg_add( int *dest, int incr );
extern int interlocked_xchg( int *dest, int val );
#endif
#if (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) && __SIZEOF_POINTER__ == 4) \
|| (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) && __SIZEOF_POINTER__ == 8)
static inline void *interlocked_cmpxchg_ptr( void **dest, void *xchg, void *compare )
{
return __sync_val_compare_and_swap( dest, compare, xchg );
}
static inline void *interlocked_xchg_ptr( void **dest, void *val )
{
void *ret;
do ret = *dest; while (!__sync_bool_compare_and_swap( dest, ret, val ));
return ret;
}
#else
extern void *interlocked_cmpxchg_ptr( void **dest, void *xchg, void *compare );
extern void *interlocked_xchg_ptr( void **dest, void *val );
#endif
#if defined(__x86_64__) || defined(__aarch64__) || defined(_WIN64)
extern unsigned char interlocked_cmpxchg128( __int64 *dest, __int64 xchg_high,
__int64 xchg_low, __int64 *compare );
#endif
#endif /* __GNUC__ */
#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
static inline __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int64 compare )
{
return __sync_val_compare_and_swap( dest, compare, xchg );
}
#else
extern __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int64 compare );
#endif
#else /* NO_LIBWINE_PORT */ #else /* NO_LIBWINE_PORT */
#define __WINE_NOT_PORTABLE(func) func##_is_not_portable func##_is_not_portable #define __WINE_NOT_PORTABLE(func) func##_is_not_portable func##_is_not_portable
...@@ -487,11 +360,6 @@ extern __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int64 compa ...@@ -487,11 +360,6 @@ extern __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int64 compa
#define fstatvfs __WINE_NOT_PORTABLE(fstatvfs) #define fstatvfs __WINE_NOT_PORTABLE(fstatvfs)
#define getopt_long __WINE_NOT_PORTABLE(getopt_long) #define getopt_long __WINE_NOT_PORTABLE(getopt_long)
#define getopt_long_only __WINE_NOT_PORTABLE(getopt_long_only) #define getopt_long_only __WINE_NOT_PORTABLE(getopt_long_only)
#define interlocked_cmpxchg __WINE_NOT_PORTABLE(interlocked_cmpxchg)
#define interlocked_cmpxchg_ptr __WINE_NOT_PORTABLE(interlocked_cmpxchg_ptr)
#define interlocked_xchg __WINE_NOT_PORTABLE(interlocked_xchg)
#define interlocked_xchg_ptr __WINE_NOT_PORTABLE(interlocked_xchg_ptr)
#define interlocked_xchg_add __WINE_NOT_PORTABLE(interlocked_xchg_add)
#define lstat __WINE_NOT_PORTABLE(lstat) #define lstat __WINE_NOT_PORTABLE(lstat)
#define pread __WINE_NOT_PORTABLE(pread) #define pread __WINE_NOT_PORTABLE(pread)
#define pwrite __WINE_NOT_PORTABLE(pwrite) #define pwrite __WINE_NOT_PORTABLE(pwrite)
......
...@@ -5,7 +5,6 @@ C_SRCS = \ ...@@ -5,7 +5,6 @@ C_SRCS = \
ffs.c \ ffs.c \
fstatvfs.c \ fstatvfs.c \
getopt.c \ getopt.c \
interlocked.c \
isfinite.c \ isfinite.c \
isinf.c \ isinf.c \
isnan.c \ isnan.c \
......
...@@ -278,7 +278,7 @@ static char *get_temp_buffer( size_t size ) ...@@ -278,7 +278,7 @@ static char *get_temp_buffer( size_t size )
char *ret; char *ret;
int idx; int idx;
idx = interlocked_xchg_add( &pos, 1 ) % ARRAY_SIZE(list); idx = pos++ % ARRAY_SIZE(list);
if ((ret = realloc( list[idx], size ))) list[idx] = ret; if ((ret = realloc( list[idx], size ))) list[idx] = ret;
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment