fix: musl compilation
This commit is contained in:
parent
dee98e06e9
commit
7a6c0f23fa
1 changed files with 11 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef TREE_SITTER_ATOMIC_H_
|
||||
#define TREE_SITTER_ATOMIC_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __TINYC__
|
||||
|
|
@ -46,11 +47,19 @@ static inline size_t atomic_load(const volatile size_t *p) {
|
|||
}
|
||||
|
||||
static inline uint32_t atomic_inc(volatile uint32_t *p) {
|
||||
return __sync_add_and_fetch(p, 1U);
|
||||
#ifdef __ATOMIC_RELAXED
|
||||
return __atomic_add_fetch(p, 1U, __ATOMIC_RELAXED);
|
||||
#else
|
||||
return __sync_add_and_fetch(p, 1U);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint32_t atomic_dec(volatile uint32_t *p) {
|
||||
return __sync_sub_and_fetch(p, 1U);
|
||||
#ifdef __ATOMIC_RELAXED
|
||||
return __atomic_sub_fetch(p, 1U, __ATOMIC_RELAXED);
|
||||
#else
|
||||
return __sync_sub_and_fetch(p, 1U);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue