summaryrefslogtreecommitdiff
path: root/ruby_atomic.h
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2019-12-02 14:58:43 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2019-12-26 20:45:12 +0900
commit0958e19ffb047781fe1506760c7cbd8d7fe74e57 (patch)
treeca20d9181667d746c6df55c63f595980e9a77fbc /ruby_atomic.h
parent863dbb21d8912c73e84fed47f2d3a1ac5d8275d4 (diff)
downloadruby-0958e19ffb047781fe1506760c7cbd8d7fe74e57.tar.gz
add several __has_something macro
With these macros implemented we can write codes just like we can assume the compiler being clang. MSC_VERSION_SINCE is defined to implement those macros, but turned out to be handy for other places. The -fdeclspec compiler flag is necessary for clang to properly handle __has_declspec().
Diffstat (limited to 'ruby_atomic.h')
-rw-r--r--ruby_atomic.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/ruby_atomic.h b/ruby_atomic.h
index 1b395cd23f..4a6723a92e 100644
--- a/ruby_atomic.h
+++ b/ruby_atomic.h
@@ -38,7 +38,7 @@ typedef unsigned int rb_atomic_t; /* Anything OK */
# define RUBY_ATOMIC_GENERIC_MACRO 1
#elif defined _WIN32
-#if defined _MSC_VER && _MSC_VER > 1200
+#if MSC_VERSION_SINCE(1300)
#pragma intrinsic(_InterlockedOr)
#endif
typedef LONG rb_atomic_t;
@@ -48,7 +48,7 @@ typedef LONG rb_atomic_t;
# define ATOMIC_DEC(var) InterlockedDecrement(&(var))
#if defined __GNUC__
# define ATOMIC_OR(var, val) __asm__("lock\n\t" "orl\t%1, %0" : "=m"(var) : "Ir"(val))
-#elif defined _MSC_VER && _MSC_VER <= 1200
+#elif MSC_VERSION_BEFORE(1300)
# define ATOMIC_OR(var, val) rb_w32_atomic_or(&(var), (val))
static inline void
rb_w32_atomic_or(volatile rb_atomic_t *var, rb_atomic_t val)
@@ -66,7 +66,7 @@ rb_w32_atomic_or(volatile rb_atomic_t *var, rb_atomic_t val)
#endif
# define ATOMIC_EXCHANGE(var, val) InterlockedExchange(&(var), (val))
# define ATOMIC_CAS(var, oldval, newval) InterlockedCompareExchange(&(var), (newval), (oldval))
-# if defined _MSC_VER && _MSC_VER <= 1200
+# if MSC_VERSION_BEFORE(1300)
static inline rb_atomic_t
rb_w32_atomic_cas(volatile rb_atomic_t *var, rb_atomic_t oldval, rb_atomic_t newval)
{