Permalink
Browse files

* atomic.h (ATOMIC_OR): _InterlockedOr is unavailable in VC6.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 03c618d commit 2a8a9d1def49b2673814e2307520fd02f9d536dd @nobu nobu committed Jul 9, 2011
Showing with 17 additions and 2 deletions.
  1. +3 −1 ChangeLog
  2. +14 −1 atomic.h
View
@@ -1,4 +1,6 @@
-Sat Jul 9 16:54:35 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Jul 9 16:56:01 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * atomic.h (ATOMIC_OR): _InterlockedOr is unavailable in VC6.
* numeric.c (ULLONG_MAX): fallback definition.
View
@@ -2,7 +2,7 @@
#define RUBY_ATOMIC_H
#ifdef _WIN32
-#ifdef _MSC_VER
+#if defined _MSC_VER && _MSC_VER > 1200
#pragma intrinsic(_InterlockedOr)
#endif
typedef LONG rb_atomic_t;
@@ -12,6 +12,19 @@ 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
+# 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)
+{
+#ifdef _M_IX86
+ __asm mov eax, var;
+ __asm mov ecx, val;
+ __asm lock or [eax], ecx;
+#else
+#error unsupported architecture
+#endif
+}
#else
# define ATOMIC_OR(var, val) _InterlockedOr(&(var), (val))
#endif

0 comments on commit 2a8a9d1

Please sign in to comment.