]> git.saurik.com Git - apple/dyld.git/blobdiff - src/dyldLock.cpp
dyld-360.19.tar.gz
[apple/dyld.git] / src / dyldLock.cpp
index dad139054a626d2274a92e91f33c827836e78b2f..18dfe1494f3d388b73902e0efc240a3dbbd71276 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
  *
- * Copyright (c) 2004-2007 Apple Inc. All rights reserved.
+ * Copyright (c) 2004-2012 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
 
 
 
-static pthread_mutex_t sGlobalMutex;
+static pthread_mutex_t sGlobalMutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
 
 // <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() 
 { 
        dyldGlobalLockAcquire();
@@ -60,12 +47,12 @@ LockHelper::~LockHelper()
 void dyldGlobalLockAcquire() 
 {
        pthread_mutex_lock(&sGlobalMutex);
-       _dyld_global_lock_held = 1;
+       ++_dyld_global_lock_held;
 }
 
 void dyldGlobalLockRelease() 
 {
-       _dyld_global_lock_held = 0;
+       --_dyld_global_lock_held;
        pthread_mutex_unlock(&sGlobalMutex);
 }