From 9d61ddfddb3151e7de24f30386f9099f7be330c2 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Tue, 1 May 2018 22:11:13 +0200 Subject: [PATCH] reflock: remove _sync_sub_and_fetch() --- src/reflock.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/reflock.c b/src/reflock.c index a8a51f9..3c3db68 100644 --- a/src/reflock.c +++ b/src/reflock.c @@ -50,12 +50,6 @@ static inline uint32_t _sync_add_and_fetch(volatile uint32_t* target, return InterlockedAdd((volatile long*) target, value); } -static inline uint32_t _sync_sub_and_fetch(volatile uint32_t* target, - uint32_t value) { - uint32_t add_value = -(int32_t) value; - return _sync_add_and_fetch(target, add_value); -} - static inline uint32_t _sync_fetch_and_set(volatile uint32_t* target, uint32_t value) { static_assert(sizeof(*target) == sizeof(long), ""); @@ -69,7 +63,7 @@ void reflock_ref(reflock_t* reflock) { } void reflock_unref(reflock_t* reflock) { - uint32_t state = _sync_sub_and_fetch(&reflock->state, _REF); + uint32_t state = _sync_add_and_fetch(&reflock->state, -(int32_t) _REF); uint32_t ref_count = state & _REF_MASK; uint32_t destroy = state & _DESTROY_MASK;