From: Jeff Lucovsky Date: Thu, 10 Sep 2020 11:47:46 +0000 (-0400) Subject: atomics: Add "decl and init with value" function X-Git-Tag: suricata-6.0.0-rc1~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad2e18be3ea149cde6ed9f58bb22a02f29a5fe5d;p=thirdparty%2Fsuricata.git 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. --- 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. **/