mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
Improve atomics
This commit is contained in:
parent
a102c64341
commit
1d34db8497
@ -1,6 +1,17 @@
|
||||
#include "../types.h"
|
||||
|
||||
u32 atomicIncrement32(u32* p);
|
||||
u32 atomicDecrement32(u32* p);
|
||||
u64 atomicIncrement64(u64* p);
|
||||
u64 atomicDecrement64(u64* p);
|
||||
static inline u32 atomicIncrement32(u32* p) {
|
||||
return __atomic_fetch_add(p, 1, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
static inline u32 atomicDecrement32(u32* p) {
|
||||
return __atomic_sub_fetch(p, 1, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
static inline u64 atomicIncrement64(u64* p) {
|
||||
return __atomic_fetch_add(p, 1, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
static inline u64 atomicDecrement64(u64* p) {
|
||||
return __atomic_sub_fetch(p, 1, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
#include "types.h"
|
||||
|
||||
u32 atomicIncrement32(u32* p) {
|
||||
return __sync_fetch_and_add(p, 1);
|
||||
}
|
||||
|
||||
u32 atomicDecrement32(u32* p) {
|
||||
return __sync_sub_and_fetch(p, 1);
|
||||
}
|
||||
|
||||
u64 atomicIncrement64(u64* p) {
|
||||
return __sync_fetch_and_add(p, 1);
|
||||
}
|
||||
|
||||
u64 atomicDecrement64(u64* p) {
|
||||
return __sync_sub_and_fetch(p, 1);
|
||||
}
|
Loading…
Reference in New Issue
Block a user