]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
atomics: Add "decl and init with value" function
authorJeff Lucovsky <jeff@lucovsky.org>
Thu, 10 Sep 2020 11:47:46 +0000 (07:47 -0400)
committerVictor Julien <victor@inliniac.net>
Thu, 10 Sep 2020 18:41:12 +0000 (20:41 +0200)
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

index b654a9f093240c781dfb67f43c1610c349533874..5f23571430107c6603f523f6afc0374e3dbbf13a 100644 (file)
 #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.
  **/
 #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.
  **/