Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(957)

Unified Diff: src/ports/SkMutex_pthread.h

Issue 419113002: Fix thread unsafe mutex initialization. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clang 3.5 does not like unused static inlines in .cpp. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/ports/SkMutex_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkMutex_pthread.h
diff --git a/src/ports/SkMutex_pthread.h b/src/ports/SkMutex_pthread.h
index 3bf3628588cd3b66b085325697fb98f61008ae2d..9aaa0612e76911f24a14f971e1b27fa787a019cd 100644
--- a/src/ports/SkMutex_pthread.h
+++ b/src/ports/SkMutex_pthread.h
@@ -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
« no previous file with comments | « no previous file | src/ports/SkMutex_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698