aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-01 03:40:37 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-01 03:40:37 +0000
commite62214be87a53045dbec187c66e208bc303e0f60 (patch)
treeb54682d2c3083ac92a1e7318fc20cd818fa40dca
parent740a1706c8a5428b8763efb430afdd17f80190e8 (diff)
downloadruby-e62214be87a53045dbec187c66e208bc303e0f60.tar.gz
move atomic logic from mjit.c from ruby_atomic.h
This macro shall be shared among other files, not just for mjit.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--mjit.c10
-rw-r--r--ruby_atomic.h4
2 files changed, 5 insertions, 9 deletions
diff --git a/mjit.c b/mjit.c
index fe1d21af67..58fe0cb1d1 100644
--- a/mjit.c
+++ b/mjit.c
@@ -140,15 +140,7 @@ typedef intptr_t pid_t;
#endif
/* Atomically set function pointer if possible. */
-#ifdef _WIN32
-# ifdef InterlockedExchangePointer
-# define MJIT_ATOMIC_SET(var, val) InterlockedExchangePointer((void **)&(var), (void *)val)
-# else
-# define MJIT_ATOMIC_SET(var, val) (void)((var) = (val))
-# endif
-#else
-# define MJIT_ATOMIC_SET(var, val) ATOMIC_SET(var, val)
-#endif
+#define MJIT_ATOMIC_SET(var, val) ATOMIC_PTR_EXCHANGE(var, val)
/* A copy of MJIT portion of MRI options since MJIT initialization. We
need them as MJIT threads still can work when the most MRI data were
diff --git a/ruby_atomic.h b/ruby_atomic.h
index ba25758a28..1b395cd23f 100644
--- a/ruby_atomic.h
+++ b/ruby_atomic.h
@@ -90,6 +90,10 @@ rb_w32_atomic_cas(volatile rb_atomic_t *var, rb_atomic_t oldval, rb_atomic_t new
# define ATOMIC_SIZE_EXCHANGE(var, val) InterlockedExchange((LONG *)&(var), (val))
# endif
+# ifdef InterlockedExchangePointer
+# define ATOMIC_PTR_EXCHANGE(var, val) InterlockedExchangePointer((PVOID volatile *)&(var), (PVOID)(val))
+# endif /* See below for definitions of other situations */
+
#elif defined(__sun) && defined(HAVE_ATOMIC_H)
#include <atomic.h>
typedef unsigned int rb_atomic_t;