]> gitweb.factorcode.org Git - factor.git/blob - vm/atomic-cl-64.hpp
xmode.marker: more correct faster update-match-group
[factor.git] / vm / atomic-cl-64.hpp
1 #define FACTOR_FORCE_INLINE __forceinline
2
3 namespace factor {
4 namespace atomic {
5 __forceinline static bool cas(volatile cell* ptr, cell old_val, cell new_val) {
6   return InterlockedCompareExchange64(reinterpret_cast<volatile LONG64*>(ptr),
7                                       (LONG64)old_val, (LONG64)new_val) ==
8          (LONG64)old_val;
9 }
10 __forceinline static bool cas(volatile fixnum* ptr, fixnum old_val,
11                               fixnum new_val) {
12   return InterlockedCompareExchange64(reinterpret_cast<volatile LONG64*>(ptr),
13                                       (LONG64)old_val, (LONG64)new_val) ==
14          (LONG64)old_val;
15 }
16
17 __forceinline static cell fetch_add(volatile cell* ptr, cell val) {
18   return (cell)InterlockedExchangeAdd64(
19       reinterpret_cast<volatile LONG64*>(ptr), (LONG64)val);
20 }
21 __forceinline static fixnum fetch_add(volatile fixnum* ptr, fixnum val) {
22   return (fixnum)InterlockedExchangeAdd64(
23       reinterpret_cast<volatile LONG64*>(ptr), (LONG64)val);
24 }
25
26 __forceinline static cell fetch_subtract(volatile cell* ptr, cell val) {
27   return (cell)InterlockedExchangeAdd64(
28       reinterpret_cast<volatile LONG64*>(ptr), -(LONG64)val);
29 }
30 __forceinline static fixnum fetch_subtract(volatile fixnum* ptr, fixnum val) {
31   return (fixnum)InterlockedExchangeAdd64(
32       reinterpret_cast<volatile LONG64*>(ptr), -(LONG64)val);
33 }
34
35 __forceinline static void fence() { MemoryBarrier(); }
36 }
37 }
38
39 #include "atomic.hpp"