Skip to content

Commit a96e726

Browse files
committed
Add util_atomic_decrement function
1 parent 2334fd8 commit a96e726

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/utils/utils_concurrency.h

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

102104
#define util_atomic_increment(object) \
103105
__atomic_add_fetch(object, 1, __ATOMIC_ACQ_REL)
106+
107+
#define util_atomic_decrement(object) \
108+
__atomic_sub_fetch(object, 1, __ATOMIC_ACQ_REL)
109+
104110
#define util_fetch_and_add64 __sync_fetch_and_add
105111
#endif
106112

0 commit comments

Comments
 (0)