bungeman 2014-07-25 15:11:03 -07:00 committed by Commit bot
parent 048f422ec6
commit 1ef960b01b
2 changed files with 8 additions and 8 deletions

View File

@ -89,11 +89,13 @@ private:
#define SK_BASE_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER, SkDEBUGCODE(0) }
// Using POD-style initialization prevents the generation of a static initializer.
//
// Without magic statics there are no thread safety guarantees on initialization
// of local statics (even POD).
// As a result, it is illegal to SK_DECLARE_STATIC_MUTEX in a function.
#define SK_DECLARE_STATIC_MUTEX(name) \
static inline void SK_MACRO_APPEND_LINE(name)(){} \
static SkBaseMutex name = SK_BASE_MUTEX_INIT
// of local statics (even POD). As a result, it is illegal to use
// SK_DECLARE_STATIC_MUTEX in a function.
//
// Because SkBaseMutex is not a primitive, a static SkBaseMutex cannot be
// initialized in a class with this macro.
#define SK_DECLARE_STATIC_MUTEX(name) namespace {} static SkBaseMutex name = SK_BASE_MUTEX_INIT
#endif

View File

@ -74,8 +74,6 @@ class SkMutex : public SkBaseMutex { };
// Windows currently provides no documented means of POD initializing a CRITICAL_SECTION.
// As a result, it is illegal to SK_DECLARE_STATIC_MUTEX in a function.
#define SK_DECLARE_STATIC_MUTEX(name) \
static inline void SK_MACRO_APPEND_LINE(name)(){} \
static SkBaseMutex name
#define SK_DECLARE_STATIC_MUTEX(name) namespace{} static SkBaseMutex name
#endif