Always init pthread locks to NULL
authorJoona Kiiski <joona.kiiski@gmail.com>
Fri, 23 Jul 2010 05:45:42 +0000 (08:45 +0300)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 23 Jul 2010 06:03:39 +0000 (07:03 +0100)
This is the only way to keep Windows and POSIX behaviour in sync,
so better hardcode it.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/lock.h
src/search.cpp

index e25a223432be572bf1e07118e93100e0a058f8b5..f46f93d89f7c8da8fba069cb8f4e49058e8e4fef 100644 (file)
@@ -28,7 +28,7 @@
 
 typedef pthread_mutex_t Lock;
 
-#  define lock_init(x, y) pthread_mutex_init(x, y)
+#  define lock_init(x) pthread_mutex_init(x, NULL)
 #  define lock_grab(x) pthread_mutex_lock(x)
 #  define lock_release(x) pthread_mutex_unlock(x)
 #  define lock_destroy(x) pthread_mutex_destroy(x)
@@ -41,7 +41,7 @@ typedef pthread_mutex_t Lock;
 #undef WIN32_LEAN_AND_MEAN
 
 typedef CRITICAL_SECTION Lock;
-#  define lock_init(x, y) InitializeCriticalSection(x)
+#  define lock_init(x) InitializeCriticalSection(x)
 #  define lock_grab(x) EnterCriticalSection(x)
 #  define lock_release(x) LeaveCriticalSection(x)
 #  define lock_destroy(x) DeleteCriticalSection(x)
index c959c75a74b3d651486da1176a211634f8699c39..29b7c5f3ebab93a78b832a23905a0e07af535800 100644 (file)
@@ -2470,8 +2470,8 @@ namespace {
 #endif
 
     // Initialize global locks
-    lock_init(&MPLock, NULL);
-    lock_init(&WaitLock, NULL);
+    lock_init(&MPLock);
+    lock_init(&WaitLock);
 
 #if !defined(_MSC_VER)
     pthread_cond_init(&WaitCond, NULL);
@@ -2483,7 +2483,7 @@ namespace {
     // Initialize splitPoints[] locks
     for (i = 0; i < MAX_THREADS; i++)
         for (int j = 0; j < MAX_ACTIVE_SPLIT_POINTS; j++)
-            lock_init(&(threads[i].splitPoints[j].lock), NULL);
+            lock_init(&(threads[i].splitPoints[j].lock));
 
     // Will be set just before program exits to properly end the threads
     AllThreadsShouldExit = false;