Reference atomic vars with SC_ATOMIC_EXTERN properly (considering if we support atomic operations or not)

remotes/origin/master-1.0.x
Pablo Rincon 15 years ago committed by Victor Julien
parent 5c43db85ce
commit ee34c70ad8

@ -53,6 +53,14 @@
type name ## _sc_atomic__; \
SCSpinlock name ## _sc_lock__
/**
* \brief wrapper to reference an atomic variable already declared on another file (including the spin lock)
*
*/
#define SC_ATOMIC_EXTERN(type, name) \
extern type name ## _sc_atomic__; \
extern SCSpinlock name ## _sc_lock__
/**
* \brief wrapper to declare an atomic variable including a (spin) lock
* to protect it and initialize them.
@ -199,6 +207,22 @@
#define SC_ATOMIC_DECLARE(type, name) \
type name ## _sc_atomic__
/**
* \brief wrapper for referencing an atomic variable declared on another file.
*
* \warning Only char, short, int, long, long long and their unsigned
* versions are supported.
*
* \param type Type of the variable (char, short, int, long, long long)
* \param name Name of the variable.
*
* We just declare the variable here as we rely on atomic operations
* to modify it, so no need for locks.
*
*/
#define SC_ATOMIC_EXTERN(type, name) \
extern type name ## _sc_atomic__
/**
* \brief wrapper for declaring an atomic variable and initializing it.
**/

@ -30,7 +30,8 @@
#ifndef __UTIL_MEM_H__
#define __UTIL_MEM_H__
extern unsigned int engine_stage_sc_atomic__;
#include "util-atomic.h"
SC_ATOMIC_EXTERN(unsigned int, engine_stage);
/* Use this only if you want to debug memory allocation and free()
* It will log a lot of lines more, so think that is a performance killer */

Loading…
Cancel
Save