| Index: third_party/re2/util/mutex.h
|
| diff --git a/third_party/re2/util/mutex.h b/third_party/re2/util/mutex.h
|
| index 4bb6fecc54002fc7b099a1f8c1ecdc33b49d077b..e321fae7360e036dfb7eee510e61cdb9d6e760c1 100644
|
| --- a/third_party/re2/util/mutex.h
|
| +++ b/third_party/re2/util/mutex.h
|
| @@ -76,7 +76,7 @@ class Mutex {
|
| MutexType mutex_;
|
|
|
| // Catch the error of writing Mutex when intending MutexLock.
|
| - Mutex(Mutex *ignored) {}
|
| + Mutex(Mutex *ignored);
|
| // Disallow "evil" constructors
|
| Mutex(const Mutex&);
|
| void operator=(const Mutex&);
|
| @@ -189,6 +189,27 @@ class WriterMutexLock {
|
| #define ReaderMutexLock(x) COMPILE_ASSERT(0, rmutex_lock_decl_missing_var_name)
|
| #define WriterMutexLock(x) COMPILE_ASSERT(0, wmutex_lock_decl_missing_var_name)
|
|
|
| +// Provide safe way to declare and use global, linker-initialized mutex. Sigh.
|
| +#ifdef HAVE_PTHREAD
|
| +
|
| +#define GLOBAL_MUTEX(name) \
|
| + static pthread_mutex_t (name) = PTHREAD_MUTEX_INITIALIZER
|
| +#define GLOBAL_MUTEX_LOCK(name) \
|
| + pthread_mutex_lock(&(name))
|
| +#define GLOBAL_MUTEX_UNLOCK(name) \
|
| + pthread_mutex_unlock(&(name))
|
| +
|
| +#else
|
| +
|
| +#define GLOBAL_MUTEX(name) \
|
| + static Mutex name
|
| +#define GLOBAL_MUTEX_LOCK(name) \
|
| + name.Lock()
|
| +#define GLOBAL_MUTEX_UNLOCK(name) \
|
| + name.Unlock()
|
| +
|
| +#endif
|
| +
|
| } // namespace re2
|
|
|
| #endif /* #define RE2_UTIL_MUTEX_H_ */
|
|
|