Remove the broken pthread deadlock prediction.
This hasn't built in over one release cycle and no one even noticed.
art does this the right way and other projects should do the same.
Change-Id: I7d1fb84c4080e008f329ee73e209ce85a36e6d55
diff --git a/libc/bionic/pthread_mutex.cpp b/libc/bionic/pthread_mutex.cpp
index c4cd9e0..9fd5d32 100644
--- a/libc/bionic/pthread_mutex.cpp
+++ b/libc/bionic/pthread_mutex.cpp
@@ -445,9 +445,7 @@
}
}
-__LIBC_HIDDEN__
-int pthread_mutex_lock_impl(pthread_mutex_t *mutex)
-{
+int pthread_mutex_lock(pthread_mutex_t* mutex) {
int mvalue, mtype, tid, shared;
mvalue = mutex->value;
@@ -523,20 +521,7 @@
/* NOTREACHED */
}
-int pthread_mutex_lock(pthread_mutex_t *mutex)
-{
- int err = pthread_mutex_lock_impl(mutex);
- if (PTHREAD_DEBUG_ENABLED) {
- if (!err) {
- pthread_debug_mutex_lock_check(mutex);
- }
- }
- return err;
-}
-
-__LIBC_HIDDEN__
-int pthread_mutex_unlock_impl(pthread_mutex_t *mutex)
-{
+int pthread_mutex_unlock(pthread_mutex_t* mutex) {
int mvalue, mtype, tid, shared;
mvalue = mutex->value;
@@ -588,17 +573,7 @@
return 0;
}
-int pthread_mutex_unlock(pthread_mutex_t *mutex)
-{
- if (PTHREAD_DEBUG_ENABLED) {
- pthread_debug_mutex_unlock_check(mutex);
- }
- return pthread_mutex_unlock_impl(mutex);
-}
-
-__LIBC_HIDDEN__
-int pthread_mutex_trylock_impl(pthread_mutex_t *mutex)
-{
+int pthread_mutex_trylock(pthread_mutex_t* mutex) {
int mvalue, mtype, tid, shared;
mvalue = mutex->value;
@@ -638,17 +613,6 @@
return EBUSY;
}
-int pthread_mutex_trylock(pthread_mutex_t *mutex)
-{
- int err = pthread_mutex_trylock_impl(mutex);
- if (PTHREAD_DEBUG_ENABLED) {
- if (!err) {
- pthread_debug_mutex_lock_check(mutex);
- }
- }
- return err;
-}
-
static int __pthread_mutex_timedlock(pthread_mutex_t* mutex, const timespec* abs_timeout, clockid_t clock) {
timespec ts;
@@ -761,16 +725,11 @@
abs_timeout.tv_nsec -= 1000000000;
}
- int err = __pthread_mutex_timedlock(mutex, &abs_timeout, CLOCK_MONOTONIC);
- if (err == ETIMEDOUT) {
- err = EBUSY;
+ int error = __pthread_mutex_timedlock(mutex, &abs_timeout, CLOCK_MONOTONIC);
+ if (error == ETIMEDOUT) {
+ error = EBUSY;
}
- if (PTHREAD_DEBUG_ENABLED) {
- if (!err) {
- pthread_debug_mutex_lock_check(mutex);
- }
- }
- return err;
+ return error;
}
#endif
@@ -778,16 +737,12 @@
return __pthread_mutex_timedlock(mutex, abs_timeout, CLOCK_REALTIME);
}
-int pthread_mutex_destroy(pthread_mutex_t *mutex)
-{
- int ret;
-
- /* use trylock to ensure that the mutex value is
- * valid and is not already locked. */
- ret = pthread_mutex_trylock_impl(mutex);
- if (ret != 0)
- return ret;
-
- mutex->value = 0xdead10cc;
- return 0;
+int pthread_mutex_destroy(pthread_mutex_t* mutex) {
+ // Use trylock to ensure that the mutex is valid and not already locked.
+ int error = pthread_mutex_trylock(mutex);
+ if (error != 0) {
+ return error;
+ }
+ mutex->value = 0xdead10cc;
+ return 0;
}