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

Side by Side 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, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/ports/SkMutex_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkMutex_pthread_DEFINED 8 #ifndef SkMutex_pthread_DEFINED
9 #define SkMutex_pthread_DEFINED 9 #define SkMutex_pthread_DEFINED
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 default: 82 default:
83 SkDebugf("pthread error [%d] unknown\n", status); 83 SkDebugf("pthread error [%d] unknown\n", status);
84 break; 84 break;
85 } 85 }
86 } 86 }
87 }; 87 };
88 88
89 #define SK_BASE_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER, SkDEBUGCODE(0) } 89 #define SK_BASE_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER, SkDEBUGCODE(0) }
90 90
91 // Using POD-style initialization prevents the generation of a static initialize r. 91 // Using POD-style initialization prevents the generation of a static initialize r.
92 //
92 // Without magic statics there are no thread safety guarantees on initialization 93 // Without magic statics there are no thread safety guarantees on initialization
93 // of local statics (even POD). 94 // of local statics (even POD). As a result, it is illegal to use
94 // As a result, it is illegal to SK_DECLARE_STATIC_MUTEX in a function. 95 // SK_DECLARE_STATIC_MUTEX in a function.
95 #define SK_DECLARE_STATIC_MUTEX(name) \ 96 //
96 static inline void SK_MACRO_APPEND_LINE(name)(){} \ 97 // Because SkBaseMutex is not a primitive, a static SkBaseMutex cannot be
97 static SkBaseMutex name = SK_BASE_MUTEX_INIT 98 // initialized in a class with this macro.
99 #define SK_DECLARE_STATIC_MUTEX(name) namespace {} static SkBaseMutex name = SK_ BASE_MUTEX_INIT
98 100
99 #endif 101 #endif
OLDNEW
« 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