summaryrefslogtreecommitdiff
path: root/libc/stdlib/abort.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2006-12-07 23:24:02 +0000
committerEric Andersen <andersen@codepoet.org>2006-12-07 23:24:02 +0000
commit1478c2de052374c6356db5513749a144c13791b1 (patch)
tree3b22a3f8361f94c99508c497e240ecb71acf8641 /libc/stdlib/abort.c
parent99d6c367c4820a072dc4ada51561df17e2093778 (diff)
Major cleanup of internal mutex locking. Be more consistant in how we do
things, and avoid potential deadlocks caused when a thread holding a uClibc internal lock get canceled and terminates without releasing the lock. This change also provides a single place, bits/uClibc_mutex.h, for thread libraries to modify to change all instances of internal locking.
Diffstat (limited to 'libc/stdlib/abort.c')
-rw-r--r--libc/stdlib/abort.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/libc/stdlib/abort.c b/libc/stdlib/abort.c
index a940768c0..6e1806eae 100644
--- a/libc/stdlib/abort.c
+++ b/libc/stdlib/abort.c
@@ -49,12 +49,8 @@ extern void weak_function _stdio_term(void) attribute_hidden;
static int been_there_done_that = 0;
/* Be prepared in case multiple threads try to abort() */
-#ifdef __UCLIBC_HAS_THREADS__
-# include <pthread.h>
-static pthread_mutex_t mylock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
-#endif
-#define LOCK __pthread_mutex_lock(&mylock)
-#define UNLOCK __pthread_mutex_unlock(&mylock)
+#include <bits/uClibc_mutex.h>
+__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
/* Cause an abnormal program termination with core-dump */
void abort(void)
@@ -62,7 +58,7 @@ void abort(void)
sigset_t sigs;
/* Make sure we acquire the lock before proceeding */
- LOCK;
+ __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(mylock);
/* Unmask SIGABRT to be sure we can get it */
if (__sigemptyset(&sigs) == 0 && __sigaddset(&sigs, SIGABRT) == 0) {
@@ -85,9 +81,9 @@ void abort(void)
#endif
abort_it:
- UNLOCK;
+ __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE(mylock);
raise(SIGABRT);
- LOCK;
+ __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(mylock);
}
/* Still here? Try to remove any signal handlers */