Skip to content

Commit b1a67f1

Browse files
committed
Add utils_atomic_decrement function
1 parent 0420d07 commit b1a67f1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/utils/utils_concurrency.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ static __inline unsigned char utils_mssb_index(long long value) {
8282
InterlockedExchange64((LONG64 volatile *)object, (LONG64)desired)
8383
#define utils_atomic_increment(object) \
8484
InterlockedIncrement64((LONG64 volatile *)object)
85+
#define utils_atomic_decrement(object) \
86+
InterlockedDecrement64((LONG64 volatile *)object)
8587
#define utils_fetch_and_add64(ptr, value) \
8688
InterlockedExchangeAdd64((LONG64 *)(ptr), value)
8789
#else
@@ -101,7 +103,10 @@ static __inline unsigned char utils_mssb_index(long long value) {
101103

102104
#define utils_atomic_increment(object) \
103105
__atomic_add_fetch(object, 1, __ATOMIC_ACQ_REL)
106+
#define utils_atomic_decrement(object) \
107+
__atomic_sub_fetch(object, 1, __ATOMIC_ACQ_REL)
104108
#define utils_fetch_and_add64 __sync_fetch_and_add
109+
105110
#endif
106111

107112
#ifdef __cplusplus

0 commit comments

Comments
 (0)