ultimatepp/uppsrc/Core/Global.h
mdelfede 263ff5f895 changed svn layout
git-svn-id: svn://ultimatepp.org/upp/trunk@281 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2008-06-07 22:31:27 +00:00

43 lines
931 B
C

#define GLOBAL_VP(type, name, param) \
name() \
{ \
static type x param; \
return x; \
}
#define GLOBAL_VARP(type, name, param) \
type& GLOBAL_VP(type, name, param)
#define GLOBAL_V(type, name) GLOBAL_VP(type, name, init_)
#define GLOBAL_VAR(type, name) type& GLOBAL_V(type, name)
#define GLOBAL_VP_INIT(type, name, param) \
name() \
{ \
static type x param; \
return x; \
} \
INITBLOCK { name(); }
#define GLOBAL_VARP_INIT(type, name, param) \
type& GLOBAL_VP_INIT(type, name, param)
#define GLOBAL_V_INIT(type, name) GLOBAL_VP_INIT(type, name, init_)
#define GLOBAL_VAR_INIT(type, name) type& GLOBAL_V_INIT(type, name)
// DEPRECATED! (USE ONCELOCK_)
#define INIT_LOCKV(init, code) \
if(!init) { \
static StaticCriticalSection cs; \
CriticalSection::Lock __(cs); \
if(!init) { \
init = true; \
code \
} \
}
// DEPRECATED! (USE ONCELOCK)
#define INIT_LOCK(code) \
static bool init; \
INIT_LOCKV(init, code)