From: Simon McVittie Date: Fri, 30 Aug 2013 16:24:20 +0000 (+0100) Subject: Revert "Add a statically-initialized implementation of _dbus_lock() on glibc systems" X-Git-Tag: dbus-1.7.6~77 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=31edd76313922780fb640f13ad1b5ed130fe442b;p=thirdparty%2Fdbus.git Revert "Add a statically-initialized implementation of _dbus_lock() on glibc systems" This reverts commit 83aaa9f359e90d3b8cae5d17f6d9ba4600cff68b. This wasn't right: because it looked for a symbol from pthread.h, modules could end up disagreeing about whether threading was enabled or not. --- diff --git a/dbus/dbus-sysdeps-pthread.c b/dbus/dbus-sysdeps-pthread.c index 2180c37b1..1300ec351 100644 --- a/dbus/dbus-sysdeps-pthread.c +++ b/dbus/dbus-sysdeps-pthread.c @@ -300,50 +300,3 @@ _dbus_threads_unlock_platform_specific (void) { pthread_mutex_unlock (&init_mutex); } - -#ifdef DBUS_HAVE_STATIC_RECURSIVE_MUTEXES - -static pthread_mutex_t global_locks[] = { - /* 0-4 */ - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - /* 5-9 */ - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - /* 10-11 */ - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP -}; - -_DBUS_STATIC_ASSERT (_DBUS_N_ELEMENTS (global_locks) == _DBUS_N_GLOBAL_LOCKS); - -dbus_bool_t -_dbus_lock (DBusGlobalLock lock) -{ - /* No initialization is needed. */ - _dbus_assert (lock >= 0); - _dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS); - - PTHREAD_CHECK ("pthread_mutex_lock", - pthread_mutex_lock (&(global_locks[lock]))); - return TRUE; -} - -void -_dbus_unlock (DBusGlobalLock lock) -{ - /* No initialization is needed. */ - _dbus_assert (lock >= 0); - _dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS); - - PTHREAD_CHECK ("pthread_mutex_unlock", - pthread_mutex_unlock (&(global_locks[lock]))); -} - -#endif diff --git a/dbus/dbus-threads-internal.h b/dbus/dbus-threads-internal.h index 228a8c058..64e8bac09 100644 --- a/dbus/dbus-threads-internal.h +++ b/dbus/dbus-threads-internal.h @@ -32,12 +32,6 @@ * @{ */ -/* glibc can implement global locks without needing an initialization step, - * which improves our thread-safety-by-default further. */ -#if defined(__GLIBC__) && defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) -# define DBUS_HAVE_STATIC_RECURSIVE_MUTEXES 1 -#endif - /** * A mutex which is recursive if possible, else non-recursive. * This is typically recursive, but that cannot be relied upon. diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index 45b262dc1..12d40493b 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -283,18 +283,6 @@ _dbus_condvar_wake_one (DBusCondVar *cond) _dbus_platform_condvar_wake_one (cond); } -#ifdef DBUS_HAVE_STATIC_RECURSIVE_MUTEXES - -static dbus_bool_t -init_global_locks (void) -{ - return TRUE; -} - -/* implementations in dbus-sysdeps-pthread.c */ - -#else /* !defined(DBUS_HAVE_STATIC_RECURSIVE_MUTEXES) */ - static DBusRMutex *global_locks[_DBUS_N_GLOBAL_LOCKS] = { NULL }; static void @@ -368,8 +356,6 @@ _dbus_unlock (DBusGlobalLock lock) _dbus_platform_rmutex_unlock (global_locks[lock]); } -#endif /* !defined(DBUS_HAVE_STATIC_RECURSIVE_MUTEXES) */ - /** @} */ /* end of internals */ /**