Win32: Fix pre-defined macros for platforms
Use `_WIN64` for word-size, `_M_AMD64` for CPU-specific feature.
This commit is contained in:
parent
aa36e44c05
commit
c77f736bc1
@ -424,7 +424,7 @@ rbimpl_atomic_size_add(volatile size_t *ptr, size_t val)
|
|||||||
#elif defined(HAVE_GCC_SYNC_BUILTINS)
|
#elif defined(HAVE_GCC_SYNC_BUILTINS)
|
||||||
__sync_add_and_fetch(ptr, val);
|
__sync_add_and_fetch(ptr, val);
|
||||||
|
|
||||||
#elif defined(_WIN32) && defined(_M_AMD64)
|
#elif defined(_WIN64)
|
||||||
/* Ditto for `InterlockeExchangedAdd`. */
|
/* Ditto for `InterlockeExchangedAdd`. */
|
||||||
InterlockedExchangeAdd64(ptr, val);
|
InterlockedExchangeAdd64(ptr, val);
|
||||||
|
|
||||||
@ -476,13 +476,15 @@ rbimpl_atomic_size_inc(volatile size_t *ptr)
|
|||||||
#elif defined(HAVE_GCC_ATOMIC_BUILTINS) || defined(HAVE_GCC_SYNC_BUILTINS)
|
#elif defined(HAVE_GCC_ATOMIC_BUILTINS) || defined(HAVE_GCC_SYNC_BUILTINS)
|
||||||
rbimpl_atomic_size_add(ptr, 1);
|
rbimpl_atomic_size_add(ptr, 1);
|
||||||
|
|
||||||
#elif defined(_WIN32) && defined(_M_AMD64)
|
#elif defined(_WIN64)
|
||||||
InterlockedIncrement64(ptr);
|
InterlockedIncrement64(ptr);
|
||||||
|
|
||||||
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
|
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
|
||||||
atomic_inc_ulong(ptr);
|
atomic_inc_ulong(ptr);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
RBIMPL_STATIC_ASSERT(size_of_size_t, sizeof *ptr == sizeof(rb_atomic_t));
|
||||||
|
|
||||||
rbimpl_atomic_size_add(ptr, 1);
|
rbimpl_atomic_size_add(ptr, 1);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -558,7 +560,7 @@ rbimpl_atomic_size_sub(volatile size_t *ptr, size_t val)
|
|||||||
#elif defined(HAVE_GCC_SYNC_BUILTINS)
|
#elif defined(HAVE_GCC_SYNC_BUILTINS)
|
||||||
__sync_sub_and_fetch(ptr, val);
|
__sync_sub_and_fetch(ptr, val);
|
||||||
|
|
||||||
#elif defined(_WIN32) && defined(_M_AMD64)
|
#elif defined(_WIN64)
|
||||||
const ssize_t neg = -1;
|
const ssize_t neg = -1;
|
||||||
InterlockedExchangeAdd64(ptr, neg * val);
|
InterlockedExchangeAdd64(ptr, neg * val);
|
||||||
|
|
||||||
@ -610,13 +612,15 @@ rbimpl_atomic_size_dec(volatile size_t *ptr)
|
|||||||
#elif defined(HAVE_GCC_ATOMIC_BUILTINS) || defined(HAVE_GCC_SYNC_BUILTINS)
|
#elif defined(HAVE_GCC_ATOMIC_BUILTINS) || defined(HAVE_GCC_SYNC_BUILTINS)
|
||||||
rbimpl_atomic_size_sub(ptr, 1);
|
rbimpl_atomic_size_sub(ptr, 1);
|
||||||
|
|
||||||
#elif defined(_WIN32) && defined(_M_AMD64)
|
#elif defined(_WIN64)
|
||||||
InterlockedDecrement64(ptr);
|
InterlockedDecrement64(ptr);
|
||||||
|
|
||||||
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
|
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
|
||||||
atomic_dec_ulong(ptr);
|
atomic_dec_ulong(ptr);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
RBIMPL_STATIC_ASSERT(size_of_size_t, sizeof *ptr == sizeof(rb_atomic_t));
|
||||||
|
|
||||||
rbimpl_atomic_size_sub(ptr, 1);
|
rbimpl_atomic_size_sub(ptr, 1);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -708,7 +712,7 @@ rbimpl_atomic_size_exchange(volatile size_t *ptr, size_t val)
|
|||||||
#elif defined(HAVE_GCC_SYNC_BUILTINS)
|
#elif defined(HAVE_GCC_SYNC_BUILTINS)
|
||||||
return __sync_lock_test_and_set(ptr, val);
|
return __sync_lock_test_and_set(ptr, val);
|
||||||
|
|
||||||
#elif defined(_WIN32) && defined(_M_AMD64)
|
#elif defined(_WIN64)
|
||||||
return InterlockedExchange64(ptr, val);
|
return InterlockedExchange64(ptr, val);
|
||||||
|
|
||||||
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
|
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
|
||||||
@ -858,7 +862,7 @@ rbimpl_atomic_size_cas(volatile size_t *ptr, size_t oldval, size_t newval)
|
|||||||
#elif defined(HAVE_GCC_SYNC_BUILTINS)
|
#elif defined(HAVE_GCC_SYNC_BUILTINS)
|
||||||
return __sync_val_compare_and_swap(ptr, oldval, newval);
|
return __sync_val_compare_and_swap(ptr, oldval, newval);
|
||||||
|
|
||||||
#elif defined(_WIN32) && defined(_M_AMD64)
|
#elif defined(_WIN64)
|
||||||
return InterlockedCompareExchange64(ptr, newval, oldval);
|
return InterlockedCompareExchange64(ptr, newval, oldval);
|
||||||
|
|
||||||
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
|
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
# include <alloca.h>
|
# include <alloca.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) && defined(_WIN64)
|
#if defined(_MSC_VER) && defined(_M_AMD64)
|
||||||
# include <intrin.h>
|
# include <intrin.h>
|
||||||
# pragma intrinsic(_umul128)
|
# pragma intrinsic(_umul128)
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user