]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/atomic-cl-32.hpp
Put brackets around ipv6 addresses in `inet6 present`
[factor.git] / vm / atomic-cl-32.hpp
index bfc3cc366f8364a68c79ca595aab0a867ad9e423..d3983ef6f4a6518eb28027910e9ff66a254215b1 100644 (file)
@@ -1,49 +1,39 @@
 #define FACTOR_FORCE_INLINE __forceinline
 
 namespace factor {
-       namespace atomic {
-               __forceinline static bool cas(volatile cell *ptr, cell old_val, cell new_val)
-               {
-                       return InterlockedCompareExchange(
-                               reinterpret_cast<volatile LONG *>(ptr),
-                               (LONG)old_val,
-                               (LONG)new_val) == (LONG)old_val;
-               }
-               __forceinline static bool cas(volatile fixnum *ptr, fixnum old_val, fixnum new_val)
-               {
-                       return InterlockedCompareExchange(
-                               reinterpret_cast<volatile LONG *>(ptr),
-                               (LONG)old_val,
-                               (LONG)new_val) == (LONG)old_val;
-               }
+namespace atomic {
+__forceinline static bool cas(volatile cell* ptr, cell old_val, cell new_val) {
+  return InterlockedCompareExchange(reinterpret_cast<volatile LONG*>(ptr),
+                                    (LONG) old_val, (LONG) new_val) ==
+         (LONG) old_val;
+}
+__forceinline static bool cas(volatile fixnum* ptr, fixnum old_val,
+                              fixnum new_val) {
+  return InterlockedCompareExchange(reinterpret_cast<volatile LONG*>(ptr),
+                                    (LONG) old_val, (LONG) new_val) ==
+         (LONG) old_val;
+}
 
-               __forceinline static cell add(volatile cell *ptr, cell val)
-               {
-                       return (cell)InterlockedAdd(
-                               reinterpret_cast<volatile LONG *>(ptr), (LONG)val);
-               }
-               __forceinline static fixnum add(volatile fixnum *ptr, fixnum val)
-               {
-                       return (fixnum)InterlockedAdd(
-                               reinterpret_cast<volatile LONG *>(ptr), (LONG)val);
-               }
+__forceinline static cell fetch_add(volatile cell* ptr, cell val) {
+  return (cell)InterlockedExchangeAdd(reinterpret_cast<volatile LONG*>(ptr),
+                                      (LONG) val);
+}
+__forceinline static fixnum fetch_add(volatile fixnum* ptr, fixnum val) {
+  return (fixnum)InterlockedExchangeAdd(reinterpret_cast<volatile LONG*>(ptr),
+                                        (LONG) val);
+}
 
-               __forceinline static cell subtract(volatile cell *ptr, cell val)
-               {
-                       return (cell)InterlockedAdd(
-                               reinterpret_cast<volatile LONG *>(ptr), -(LONG)val);
-               }
-               __forceinline static fixnum subtract(volatile fixnum *ptr, fixnum val)
-               {
-                       return (fixnum)InterlockedAdd(
-                               reinterpret_cast<volatile LONG *>(ptr), -(LONG)val);
-               }
+__forceinline static cell fetch_subtract(volatile cell* ptr, cell val) {
+  return (cell)InterlockedExchangeAdd(reinterpret_cast<volatile LONG*>(ptr),
+                                      -(LONG)val);
+}
+__forceinline static fixnum fetch_subtract(volatile fixnum* ptr, fixnum val) {
+  return (fixnum)InterlockedExchangeAdd(reinterpret_cast<volatile LONG*>(ptr),
+                                        -(LONG)val);
+}
 
-               __forceinline static void fence()
-               {
-                       MemoryBarrier();
-               }
-       }
+__forceinline static void fence() { MemoryBarrier(); }
+}
 }
 
 #include "atomic.hpp"