]> gitweb.factorcode.org Git - factor.git/commitdiff
VM: Refactor atomic-* to Factor style
authorErik Charlebois <erikcharlebois@gmail.com>
Sun, 12 May 2013 01:43:04 +0000 (21:43 -0400)
committerErik Charlebois <erikcharlebois@gmail.com>
Sun, 12 May 2013 17:24:40 +0000 (13:24 -0400)
vm/atomic-cl-32.hpp
vm/atomic-cl-64.hpp
vm/atomic-gcc.hpp

index f50be98fd4f7a67e9135f3a3ef85a7f85ef379d3..a4b6af8a4f32942a34bf0d2acea114f8736b17a9 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 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 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 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 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"
index 408a8fb29a0367ef9e4c99a5cf5d4922c0816300..615f7f3b7ac5aaa048dc18aa3659718daa226be4 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 InterlockedCompareExchange64(
-                               reinterpret_cast<volatile LONG64 *>(ptr),
-                               (LONG64)old_val,
-                               (LONG64)new_val) == (LONG64)old_val;
-               }
-               __forceinline static bool cas(volatile fixnum *ptr, fixnum old_val, fixnum new_val)
-               {
-                       return InterlockedCompareExchange64(
-                               reinterpret_cast<volatile LONG64 *>(ptr),
-                               (LONG64)old_val,
-                               (LONG64)new_val) == (LONG64)old_val;
-               }
+namespace atomic {
+__forceinline static bool cas(volatile cell* ptr, cell old_val, cell new_val) {
+  return InterlockedCompareExchange64(reinterpret_cast<volatile LONG64*>(ptr),
+                                      (LONG64) old_val, (LONG64) new_val) ==
+         (LONG64) old_val;
+}
+__forceinline static bool cas(volatile fixnum* ptr, fixnum old_val,
+                              fixnum new_val) {
+  return InterlockedCompareExchange64(reinterpret_cast<volatile LONG64*>(ptr),
+                                      (LONG64) old_val, (LONG64) new_val) ==
+         (LONG64) old_val;
+}
 
-               __forceinline static cell fetch_add(volatile cell *ptr, cell val)
-               {
-                       return (cell)InterlockedExchangeAdd64(
-                               reinterpret_cast<volatile LONG64 *>(ptr), (LONG64)val);
-               }
-               __forceinline static fixnum fetch_add(volatile fixnum *ptr, fixnum val)
-               {
-                       return (fixnum)InterlockedExchangeAdd64(
-                               reinterpret_cast<volatile LONG64 *>(ptr), (LONG64)val);
-               }
+__forceinline static cell fetch_add(volatile cell* ptr, cell val) {
+  return (cell) InterlockedExchangeAdd64(
+      reinterpret_cast<volatile LONG64*>(ptr), (LONG64) val);
+}
+__forceinline static fixnum fetch_add(volatile fixnum* ptr, fixnum val) {
+  return (fixnum) InterlockedExchangeAdd64(
+      reinterpret_cast<volatile LONG64*>(ptr), (LONG64) val);
+}
 
-               __forceinline static cell fetch_subtract(volatile cell *ptr, cell val)
-               {
-                       return (cell)InterlockedExchangeAdd64(
-                               reinterpret_cast<volatile LONG64 *>(ptr), -(LONG64)val);
-               }
-               __forceinline static fixnum fetch_subtract(volatile fixnum *ptr, fixnum val)
-               {
-                       return (fixnum)InterlockedExchangeAdd64(
-                               reinterpret_cast<volatile LONG64 *>(ptr), -(LONG64)val);
-               }
+__forceinline static cell fetch_subtract(volatile cell* ptr, cell val) {
+  return (cell) InterlockedExchangeAdd64(
+      reinterpret_cast<volatile LONG64*>(ptr), -(LONG64) val);
+}
+__forceinline static fixnum fetch_subtract(volatile fixnum* ptr, fixnum val) {
+  return (fixnum) InterlockedExchangeAdd64(
+      reinterpret_cast<volatile LONG64*>(ptr), -(LONG64) val);
+}
 
-               __forceinline static void fence()
-               {
-                       MemoryBarrier();
-               }
-       }
+__forceinline static void fence() { MemoryBarrier(); }
+}
 }
 
 #include "atomic.hpp"
index 2ddf9dbc4161a1bab45cbc2f0319cb87e9e951aa..5716bdc60cbb5e278e8e0899b8535d06fd7cde96 100644 (file)
@@ -1,45 +1,39 @@
 #define FACTOR_FORCE_INLINE __attribute__((always_inline)) inline
 namespace factor {
-       namespace atomic {
-               __attribute__((always_inline))
-               inline static bool cas(volatile cell *ptr, cell old_val, cell new_val)
-               {
-                       return __sync_bool_compare_and_swap(ptr, old_val, new_val);
-               }
-               __attribute__((always_inline))
-               inline static bool cas(volatile fixnum *ptr, fixnum old_val, fixnum new_val)
-               {
-                       return __sync_bool_compare_and_swap(ptr, old_val, new_val);
-               }
+namespace atomic {
+__attribute__((always_inline)) inline static bool cas(volatile cell* ptr,
+                                                      cell old_val,
+                                                      cell new_val) {
+  return __sync_bool_compare_and_swap(ptr, old_val, new_val);
+}
+__attribute__((always_inline)) inline static bool cas(volatile fixnum* ptr,
+                                                      fixnum old_val,
+                                                      fixnum new_val) {
+  return __sync_bool_compare_and_swap(ptr, old_val, new_val);
+}
 
-               __attribute__((always_inline))
-               inline static cell fetch_add(volatile cell *ptr, cell val)
-               {
-                       return __sync_fetch_and_add(ptr, val);
-               }
-               __attribute__((always_inline))
-               inline static fixnum fetch_add(volatile fixnum *ptr, fixnum val)
-               {
-                       return __sync_fetch_and_add(ptr, val);
-               }
+__attribute__((always_inline)) inline static cell fetch_add(volatile cell* ptr,
+                                                            cell val) {
+  return __sync_fetch_and_add(ptr, val);
+}
+__attribute__((always_inline)) inline static fixnum fetch_add(
+    volatile fixnum* ptr, fixnum val) {
+  return __sync_fetch_and_add(ptr, val);
+}
 
-               __attribute__((always_inline))
-               inline static cell fetch_subtract(volatile cell *ptr, cell val)
-               {
-                       return __sync_fetch_and_sub(ptr, val);
-               }
-               __attribute__((always_inline))
-               inline static fixnum fetch_subtract(volatile fixnum *ptr, fixnum val)
-               {
-                       return __sync_fetch_and_sub(ptr, val);
-               }
+__attribute__((always_inline)) inline static cell fetch_subtract(
+    volatile cell* ptr, cell val) {
+  return __sync_fetch_and_sub(ptr, val);
+}
+__attribute__((always_inline)) inline static fixnum fetch_subtract(
+    volatile fixnum* ptr, fixnum val) {
+  return __sync_fetch_and_sub(ptr, val);
+}
 
-               __attribute__((always_inline))
-               inline static void fence()
-               {
-                       __sync_synchronize();
-               }
-       }
+__attribute__((always_inline)) inline static void fence() {
+  __sync_synchronize();
+}
+}
 }
 
 #include "atomic.hpp"