@@ -27,23 +27,22 @@ this is not part of original thpool, thats me hacking it to work on windows
27
27
#endif
28
28
#include <stdbool.h>
29
29
30
- typedef volatile LONG atomic_int ;
31
- typedef atomic_int atomic_bool ;
30
+ typedef volatile intptr_t atomic_int ;
32
31
33
- static void atomic_store (atomic_int * ptr , LONG val ) {
34
- InterlockedExchange (ptr , val );
32
+ static void atomic_store (atomic_int * ptr , intptr_t val ) {
33
+ InterlockedExchange64 (ptr , val );
35
34
}
36
- static LONG atomic_load (atomic_int * ptr ) {
37
- return InterlockedCompareExchange (ptr , 0 , 0 );
35
+ static intptr_t atomic_load (atomic_int * ptr ) {
36
+ return InterlockedCompareExchange64 (ptr , 0 , 0 );
38
37
}
39
- static LONG atomic_fetch_add (atomic_int * ptr , LONG inc ) {
40
- return InterlockedExchangeAdd (ptr , inc );
38
+ static intptr_t atomic_fetch_add (atomic_int * ptr , intptr_t inc ) {
39
+ return InterlockedExchangeAdd64 (ptr , inc );
41
40
}
42
- static LONG atomic_fetch_sub (atomic_int * ptr , LONG dec ) {
41
+ static intptr_t atomic_fetch_sub (atomic_int * ptr , intptr_t dec ) {
43
42
return atomic_fetch_add (ptr , - (dec ));
44
43
}
45
- static bool atomic_compare_exchange_strong (atomic_int * ptr , atomic_int * expected , int desired ) {
46
- int old_value = InterlockedCompareExchange (( LONG * ) ptr , desired , * expected );
44
+ static bool atomic_compare_exchange_strong (atomic_int * ptr , atomic_int * expected , intptr_t desired ) {
45
+ intptr_t old_value = InterlockedCompareExchange64 ( ptr , desired , * expected );
47
46
bool success = (old_value == * expected );
48
47
if (!success ) {
49
48
* expected = old_value ;
0 commit comments