diff options
author | serg@serg.mylan <> | 2006-06-29 15:39:53 +0200 |
---|---|---|
committer | serg@serg.mylan <> | 2006-06-29 15:39:53 +0200 |
commit | 5e2777b445ce35de7aec44ef41408d8f185b66a5 (patch) | |
tree | 6caa01d28f4377fb975fe7fcfb08fd25f8c8437e /include/atomic | |
parent | d4bdf2f447bba85660845ed1b5b9b7c3c0e355c4 (diff) | |
download | mariadb-git-5e2777b445ce35de7aec44ef41408d8f185b66a5.tar.gz |
support for xadd emulation, workaround for Darwin
Diffstat (limited to 'include/atomic')
-rw-r--r-- | include/atomic/nolock.h | 6 | ||||
-rw-r--r-- | include/atomic/x86-gcc.h | 18 | ||||
-rw-r--r-- | include/atomic/x86-msvc.h | 2 |
3 files changed, 17 insertions, 9 deletions
diff --git a/include/atomic/nolock.h b/include/atomic/nolock.h index 458cb3e4f66..1151a334b06 100644 --- a/include/atomic/nolock.h +++ b/include/atomic/nolock.h @@ -15,11 +15,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #if defined(__i386__) || defined(_M_IX86) + #ifdef MY_ATOMIC_MODE_DUMMY # define LOCK "" #else -# define LOCK "lock " +# define LOCK "lock" #endif + #ifdef __GNUC__ #include "x86-gcc.h" #elif defined(_MSC_VER) @@ -27,7 +29,7 @@ #endif #endif -#ifdef make_atomic_add_body +#ifdef make_atomic_cas_body typedef struct { } my_atomic_rwlock_t; #define my_atomic_rwlock_destroy(name) diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h index df6fcdc5ad2..5a72f318a61 100644 --- a/include/atomic/x86-gcc.h +++ b/include/atomic/x86-gcc.h @@ -20,19 +20,25 @@ architectures support double-word (128-bit) cas. */ -#define MY_ATOMIC_MODE "gcc-x86" ## LOCK +#ifdef MY_ATOMIC_NO_XADD +#define MY_ATOMIC_MODE "gcc-x86" LOCK "-no-xadd" +#else +#define MY_ATOMIC_MODE "gcc-x86" LOCK +#endif /* fix -ansi errors while maintaining readability */ #ifndef asm #define asm __asm__ #endif +#ifndef MY_ATOMIC_NO_XADD #define make_atomic_add_body(S) \ - asm volatile (LOCK "xadd %0, %1;" : "+r" (v) , "+m" (*a)) + asm volatile (LOCK "; xadd %0, %1;" : "+r" (v) , "+m" (*a)) +#endif #define make_atomic_swap_body(S) \ - asm volatile ("xchg %0, %1;" : "+r" (v) , "+m" (*a)) + asm volatile ("; xchg %0, %1;" : "+r" (v) , "+m" (*a)) #define make_atomic_cas_body(S) \ - asm volatile (LOCK "cmpxchg %3, %0; setz %2;" \ + asm volatile (LOCK "; cmpxchg %3, %0; setz %2;" \ : "+m" (*a), "+a" (*cmp), "=q" (ret): "r" (set)) #ifdef MY_ATOMIC_MODE_DUMMY @@ -45,9 +51,9 @@ */ #define make_atomic_load_body(S) \ ret=0; \ - asm volatile (LOCK "cmpxchg %2, %0" \ + asm volatile (LOCK "; cmpxchg %2, %0" \ : "+m" (*a), "+a" (ret): "r" (ret)) #define make_atomic_store_body(S) \ - asm volatile ("xchg %0, %1;" : "+m" (*a) : "r" (v)) + asm volatile ("; xchg %0, %1;" : "+m" (*a) : "r" (v)) #endif diff --git a/include/atomic/x86-msvc.h b/include/atomic/x86-msvc.h index a7e14d0e926..d4024a854fb 100644 --- a/include/atomic/x86-msvc.h +++ b/include/atomic/x86-msvc.h @@ -26,7 +26,7 @@ #ifndef _atomic_h_cleanup_ #define _atomic_h_cleanup_ "atomic/x86-msvc.h" -#define MY_ATOMIC_MODE "msvc-x86" ## LOCK +#define MY_ATOMIC_MODE "msvc-x86" LOCK #define make_atomic_add_body(S) \ _asm { \ |