Skip to content

Commit 2f98734

Browse files
committed
Add utils_atomic_decrement function
1 parent bf1e11a commit 2f98734

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/utils/utils_concurrency.h

+5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ static __inline unsigned char utils_mssb_index(long long value) {
8383
InterlockedExchange64((LONG64 volatile *)object, (LONG64)desired)
8484
#define utils_atomic_increment(object) \
8585
InterlockedIncrement64((LONG64 volatile *)object)
86+
#define utils_atomic_decrement(object) \
87+
InterlockedDecrement64((LONG64 volatile *)object)
8688
#define utils_fetch_and_add64(ptr, value) \
8789
InterlockedExchangeAdd64((LONG64 *)(ptr), value)
8890
#else
@@ -102,7 +104,10 @@ static __inline unsigned char utils_mssb_index(long long value) {
102104

103105
#define utils_atomic_increment(object) \
104106
__atomic_add_fetch(object, 1, __ATOMIC_ACQ_REL)
107+
#define utils_atomic_decrement(object) \
108+
__atomic_sub_fetch(object, 1, __ATOMIC_ACQ_REL)
105109
#define utils_fetch_and_add64 __sync_fetch_and_add
110+
106111
#endif
107112

108113
#ifdef __cplusplus

0 commit comments

Comments
 (0)