try fix windows compile errors: undefined c11 atomic_flag_*()
This commit is contained in:
parent
6b515403c8
commit
cba49ad48b
1 changed files with 12 additions and 4 deletions
16
ggml.c
16
ggml.c
|
@ -33,19 +33,27 @@
|
|||
typedef volatile LONG atomic_int;
|
||||
typedef atomic_int atomic_bool;
|
||||
|
||||
static void atomic_store(atomic_int* ptr, LONG val) {
|
||||
static inline void atomic_store(atomic_int* ptr, LONG val) {
|
||||
InterlockedExchange(ptr, val);
|
||||
}
|
||||
static LONG atomic_load(atomic_int* ptr) {
|
||||
static inline LONG atomic_load(atomic_int* ptr) {
|
||||
return InterlockedCompareExchange(ptr, 0, 0);
|
||||
}
|
||||
static LONG atomic_fetch_add(atomic_int* ptr, LONG inc) {
|
||||
static inline LONG atomic_fetch_add(atomic_int* ptr, LONG inc) {
|
||||
return InterlockedExchangeAdd(ptr, inc);
|
||||
}
|
||||
static LONG atomic_fetch_sub(atomic_int* ptr, LONG dec) {
|
||||
static inline LONG atomic_fetch_sub(atomic_int* ptr, LONG dec) {
|
||||
return atomic_fetch_add(ptr, -(dec));
|
||||
}
|
||||
|
||||
static inline LONG atomic_flag_test_and_set(atomic_int* ptr) {
|
||||
return InterlockedCompareExchange(ptr, 1, 0);
|
||||
}
|
||||
|
||||
static inline LONG atomic_flag_test_clear(atomic_int* ptr) {
|
||||
return InterlockedExchange(ptr, 0)
|
||||
}
|
||||
|
||||
typedef HANDLE pthread_t;
|
||||
|
||||
typedef DWORD thread_ret_t;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue