Loading...
src/dyldLock.cpp dyld-239.3 dyld-210.2.3
--- dyld/dyld-239.3/src/dyldLock.cpp
+++ dyld/dyld-210.2.3/src/dyldLock.cpp
@@ -1,6 +1,6 @@
 /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
  *
- * Copyright (c) 2004-2012 Apple Inc. All rights reserved.
+ * Copyright (c) 2004-2007 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
@@ -28,10 +28,23 @@
 
 
 
-static pthread_mutex_t	sGlobalMutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
+static pthread_mutex_t	sGlobalMutex;
 
 // <rdar://problem/6361143> Need a way to determine if a gdb call to dlopen() would block
 int	__attribute__((visibility("hidden")))			_dyld_global_lock_held = 0;
+
+
+//
+// This initializer can go away once the following is available:
+//     <rdar://problem/4927311> implement PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+//
+void dyldGlobalLockInitialize()
+{
+	pthread_mutexattr_t recursiveMutexAttr;
+	pthread_mutexattr_init(&recursiveMutexAttr);
+	pthread_mutexattr_settype(&recursiveMutexAttr, PTHREAD_MUTEX_RECURSIVE);
+	pthread_mutex_init(&sGlobalMutex, &recursiveMutexAttr);
+}
 
 
 LockHelper::LockHelper() 
@@ -47,12 +60,12 @@
 void dyldGlobalLockAcquire() 
 {
 	pthread_mutex_lock(&sGlobalMutex);
-	++_dyld_global_lock_held;
+	_dyld_global_lock_held = 1;
 }
 
 void dyldGlobalLockRelease() 
 {
-	--_dyld_global_lock_held;
+	_dyld_global_lock_held = 0;
 	pthread_mutex_unlock(&sGlobalMutex);
 }