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.
pull/5407/head
Jeff Lucovsky 5 years ago committed by Victor Julien
parent 8395a9201e
commit ad2e18be3e

@ -78,6 +78,12 @@
#define SC_ATOMIC_DECL_AND_INIT(type, name) \ #define SC_ATOMIC_DECL_AND_INIT(type, name) \
_Atomic(type) (name ## _sc_atomic__) = 0 _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. * \brief wrapper for initializing an atomic variable.
**/ **/
@ -291,6 +297,12 @@
#define SC_ATOMIC_EXTERN(type, name) \ #define SC_ATOMIC_EXTERN(type, name) \
extern type name ## _sc_atomic__ 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. * \brief wrapper for declaring an atomic variable and initializing it.
**/ **/

Loading…
Cancel
Save