From 932605c01e66cdc136fd315cfb38d3dc78fea833 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 13 Jul 2020 09:57:52 +1000 Subject: [PATCH] base: heim_base_exchange_{32,64} for platforms without atomics heim_base_exchange_32() and heim_base_exchange_64() inline functions for platforms without atomics were missing (these are very inefficient but, clearly rarely used given the lack of build error reports) --- lib/base/heimbase-atomics.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/base/heimbase-atomics.h b/lib/base/heimbase-atomics.h index 4ad00e87a..043f31169 100644 --- a/lib/base/heimbase-atomics.h +++ b/lib/base/heimbase-atomics.h @@ -171,6 +171,28 @@ heim_base_exchange_pointer(void *target, void *value) return old; } +static inline uint32_t +heim_base_exchange_32(uint32_t *p, uint32_t newval) +{ + uint32_t old; + HEIMDAL_MUTEX_lock(&_heim_base_mutex); + old = *p; + *p = newval; + HEIMDAL_MUTEX_unlock(&_heim_base_mutex); + return old; +} + +static inline uint64_t +heim_base_exchange_64(uint64_t *p, uint64_t newval) +{ + uint64_t old; + HEIMDAL_MUTEX_lock(&_heim_base_mutex); + old = *p; + *p = newval; + HEIMDAL_MUTEX_unlock(&_heim_base_mutex); + return old; +} + #endif /* defined(__GNUC__) && defined(HAVE___SYNC_ADD_AND_FETCH) */ #if SIZEOF_TIME_T == 8