util: Remove u_atomic.h's GCC inline assembly.
GCC >= 4.1 support the __sync_* intrinsics. That seems like a sufficiently old baseline. Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
This commit is contained in:
parent
972f8458f1
commit
2879a77a37
|
@ -21,133 +21,11 @@
|
|||
#define PIPE_ATOMIC_MSVC_INTRINSIC
|
||||
#elif defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 401)
|
||||
#define PIPE_ATOMIC_GCC_INTRINSIC
|
||||
#elif (defined(__GNUC__) && defined(__i386__))
|
||||
#define PIPE_ATOMIC_ASM_GCC_X86
|
||||
#elif (defined(__GNUC__) && defined(__x86_64__))
|
||||
#define PIPE_ATOMIC_ASM_GCC_X86_64
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(PIPE_ATOMIC_ASM_GCC_X86_64)
|
||||
#define PIPE_ATOMIC "GCC x86_64 assembly"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define p_atomic_set(_v, _i) (*(_v) = (_i))
|
||||
#define p_atomic_read(_v) (*(_v))
|
||||
|
||||
static inline boolean
|
||||
p_atomic_dec_zero(int32_t *v)
|
||||
{
|
||||
unsigned char c;
|
||||
|
||||
__asm__ __volatile__("lock; decl %0; sete %1":"+m"(*v), "=qm"(c)
|
||||
::"memory");
|
||||
|
||||
return c != 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
p_atomic_inc(int32_t *v)
|
||||
{
|
||||
__asm__ __volatile__("lock; incl %0":"+m"(*v));
|
||||
}
|
||||
|
||||
static inline void
|
||||
p_atomic_dec(int32_t *v)
|
||||
{
|
||||
__asm__ __volatile__("lock; decl %0":"+m"(*v));
|
||||
}
|
||||
|
||||
static inline int32_t
|
||||
p_atomic_inc_return(int32_t *v)
|
||||
{
|
||||
return __sync_add_and_fetch(v, 1);
|
||||
}
|
||||
|
||||
static inline int32_t
|
||||
p_atomic_dec_return(int32_t *v)
|
||||
{
|
||||
return __sync_sub_and_fetch(v, 1);
|
||||
}
|
||||
|
||||
static inline int32_t
|
||||
p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
|
||||
{
|
||||
return __sync_val_compare_and_swap(v, old, _new);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PIPE_ATOMIC_ASM_GCC_X86_64 */
|
||||
|
||||
|
||||
#if defined(PIPE_ATOMIC_ASM_GCC_X86)
|
||||
|
||||
#define PIPE_ATOMIC "GCC x86 assembly"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define p_atomic_set(_v, _i) (*(_v) = (_i))
|
||||
#define p_atomic_read(_v) (*(_v))
|
||||
|
||||
static inline boolean
|
||||
p_atomic_dec_zero(int32_t *v)
|
||||
{
|
||||
unsigned char c;
|
||||
|
||||
__asm__ __volatile__("lock; decl %0; sete %1":"+m"(*v), "=qm"(c)
|
||||
::"memory");
|
||||
|
||||
return c != 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
p_atomic_inc(int32_t *v)
|
||||
{
|
||||
__asm__ __volatile__("lock; incl %0":"+m"(*v));
|
||||
}
|
||||
|
||||
static inline void
|
||||
p_atomic_dec(int32_t *v)
|
||||
{
|
||||
__asm__ __volatile__("lock; decl %0":"+m"(*v));
|
||||
}
|
||||
|
||||
static inline int32_t
|
||||
p_atomic_inc_return(int32_t *v)
|
||||
{
|
||||
return __sync_add_and_fetch(v, 1);
|
||||
}
|
||||
|
||||
static inline int32_t
|
||||
p_atomic_dec_return(int32_t *v)
|
||||
{
|
||||
return __sync_sub_and_fetch(v, 1);
|
||||
}
|
||||
|
||||
static inline int32_t
|
||||
p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
|
||||
{
|
||||
return __sync_val_compare_and_swap(v, old, _new);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Implementation using GCC-provided synchronization intrinsics
|
||||
*/
|
||||
#if defined(PIPE_ATOMIC_GCC_INTRINSIC)
|
||||
|
|
Loading…
Reference in New Issue