From ad2e18be3ea149cde6ed9f58bb22a02f29a5fe5d Mon Sep 17 00:00:00 2001 From: Jeff Lucovsky Date: Thu, 10 Sep 2020 07:47:46 -0400 Subject: [PATCH] atomics: Add "decl and init with value" function This commit adds an interface to declare and initialize an atomic with a specific value. This can help with situations where there's no defined initialization path to set things up. --- src/util-atomic.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/util-atomic.h b/src/util-atomic.h index b654a9f093..5f23571430 100644 --- a/src/util-atomic.h +++ b/src/util-atomic.h @@ -78,6 +78,12 @@ #define SC_ATOMIC_DECL_AND_INIT(type, name) \ _Atomic(type) (name ## _sc_atomic__) = 0 +/** + * \brief wrapper for declaring an atomic variable and initializing it + * to a specific value + **/ +#define SC_ATOMIC_DECL_AND_INIT_WITH_VAL(type, name, val) _Atomic(type)(name##_sc_atomic__) = val + /** * \brief wrapper for initializing an atomic variable. **/ @@ -291,6 +297,12 @@ #define SC_ATOMIC_EXTERN(type, name) \ extern type name ## _sc_atomic__ +/** + * \brief wrapper for declaring an atomic variable and initializing it + * to a specific value + **/ +#define SC_ATOMIC_DECL_AND_INIT_WITH_VAL(type, name, val) type name##_sc_atomic__ = val + /** * \brief wrapper for declaring an atomic variable and initializing it. **/