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

Unified Diff: third_party/re2/util/mutex.h

Issue 1530113002: Revert of Update re2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « third_party/re2/util/logging.cc ('k') | third_party/re2/util/pcre.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/re2/util/mutex.h
diff --git a/third_party/re2/util/mutex.h b/third_party/re2/util/mutex.h
index b479e481ff1a1d8f8d09f8814ccec37022f22f73..e321fae7360e036dfb7eee510e61cdb9d6e760c1 100644
--- a/third_party/re2/util/mutex.h
+++ b/third_party/re2/util/mutex.h
@@ -10,40 +10,19 @@
#ifndef RE2_UTIL_MUTEX_H_
#define RE2_UTIL_MUTEX_H_
-#include <stdlib.h>
-
-#if !defined(_WIN32)
-#include <unistd.h> // For POSIX options
-#endif
-
namespace re2 {
-#if !defined(_WIN32)
- // Possible values of POSIX options:
- // -1 means not supported,
- // 0 means maybe supported (query at runtime),
- // >0 means supported.
-# if defined(_POSIX_THREADS) && _POSIX_THREADS > 0
-# define HAVE_PTHREAD 1
-# else
-# define HAVE_PTHREAD 0
-# endif
-# if defined(_POSIX_READER_WRITER_LOCKS) && _POSIX_READER_WRITER_LOCKS > 0
-# define HAVE_RWLOCK 1
-# else
-# define HAVE_RWLOCK 0
-# endif
-#else
-# define HAVE_PTHREAD 0
-# define HAVE_RWLOCK 0
+#ifndef WIN32
+#define HAVE_PTHREAD 1
+#define HAVE_RWLOCK 1
#endif
#if defined(NO_THREADS)
typedef int MutexType; // to keep a lock-count
-#elif HAVE_PTHREAD && HAVE_RWLOCK
+#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
// Needed for pthread_rwlock_*. If it causes problems, you could take it
- // out, but then you'd have to set HAVE_RWLOCK to 0 (at least on linux --
- // it *does* cause problems for FreeBSD, or MacOSX, but isn't needed
+ // out, but then you'd have to unset HAVE_RWLOCK (at least on linux -- it
+ // *does* cause problems for FreeBSD, or MacOSX, but isn't needed
// for locking there.)
# ifdef __linux__
# undef _XOPEN_SOURCE
@@ -51,12 +30,12 @@
# endif
# include <pthread.h>
typedef pthread_rwlock_t MutexType;
-#elif HAVE_PTHREAD
+#elif defined(HAVE_PTHREAD)
# include <pthread.h>
typedef pthread_mutex_t MutexType;
-#elif defined(_WIN32)
+#elif defined(WIN32)
# ifndef WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN // We only need minimal includes
+# define WIN32_LEAN_AND_MEAN // We only need minimal includes
# endif
# ifdef GMUTEX_TRYLOCK
// We need Windows NT or later for TryEnterCriticalSection(). If you
@@ -125,8 +104,9 @@
void Mutex::ReaderLock() { assert(++mutex_ > 0); }
void Mutex::ReaderUnlock() { assert(mutex_-- > 0); }
-#elif HAVE_PTHREAD && HAVE_RWLOCK
-
+#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
+
+#include <stdlib.h> // for abort()
#define SAFE_PTHREAD(fncall) do { if ((fncall) != 0) abort(); } while (0)
Mutex::Mutex() { SAFE_PTHREAD(pthread_rwlock_init(&mutex_, NULL)); }
@@ -139,8 +119,9 @@
#undef SAFE_PTHREAD
-#elif HAVE_PTHREAD
-
+#elif defined(HAVE_PTHREAD)
+
+#include <stdlib.h> // for abort()
#define SAFE_PTHREAD(fncall) do { if ((fncall) != 0) abort(); } while (0)
Mutex::Mutex() { SAFE_PTHREAD(pthread_mutex_init(&mutex_, NULL)); }
@@ -152,7 +133,7 @@
void Mutex::ReaderUnlock() { Unlock(); }
#undef SAFE_PTHREAD
-#elif defined(_WIN32)
+#elif defined(WIN32)
Mutex::Mutex() { InitializeCriticalSection(&mutex_); }
Mutex::~Mutex() { DeleteCriticalSection(&mutex_); }
@@ -209,7 +190,7 @@
#define WriterMutexLock(x) COMPILE_ASSERT(0, wmutex_lock_decl_missing_var_name)
// Provide safe way to declare and use global, linker-initialized mutex. Sigh.
-#if HAVE_PTHREAD
+#ifdef HAVE_PTHREAD
#define GLOBAL_MUTEX(name) \
static pthread_mutex_t (name) = PTHREAD_MUTEX_INITIALIZER
« no previous file with comments | « third_party/re2/util/logging.cc ('k') | third_party/re2/util/pcre.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698