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