From f4a546a9159ff48b806fe8556cdc963fef2dcabe Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 15 Dec 2023 10:16:07 -0500 Subject: [PATCH] MT#55283 add atomic64_or/and Change-Id: Ib6dc615d339d7cdd104297c6b0c46a00e1d680e4 --- include/helpers.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/helpers.h b/include/helpers.h index 0cdf09fb2..4160efa83 100644 --- a/include/helpers.h +++ b/include/helpers.h @@ -277,6 +277,12 @@ INLINE uint64_t atomic64_get_set(atomic64 *u, uint64_t a) { return old; } while (1); } +INLINE uint64_t atomic64_or(atomic64 *u, uint64_t a) { + return g_atomic_pointer_or(&u->p, a); +} +INLINE uint64_t atomic64_and(atomic64 *u, uint64_t a) { + return g_atomic_pointer_and(&u->p, a); +} #else @@ -338,6 +344,20 @@ INLINE uint64_t atomic64_get_set(atomic64 *u, uint64_t a) { mutex_unlock(&__atomic64_mutex); return old; } +INLINE uint64_t atomic64_or(atomic64 *u, uint64_t a) { + mutex_lock(&__atomic64_mutex); + uint64_t old = u->u; + u->u |= a; + mutex_unlock(&__atomic64_mutex); + return old; +} +INLINE uint64_t atomic64_and(atomic64 *u, uint64_t a) { + mutex_lock(&__atomic64_mutex); + uint64_t old = u->u; + u->u &= a; + mutex_unlock(&__atomic64_mutex); + return old; +} #endif