diff options
author | "Steven J. Hill" <sjhill@realitydiluted.com> | 2006-02-25 04:03:33 +0000 |
---|---|---|
committer | "Steven J. Hill" <sjhill@realitydiluted.com> | 2006-02-25 04:03:33 +0000 |
commit | cb6a88484ce0b5ffba2fe98a40e2d51f4af92eb8 (patch) | |
tree | 520f8e8d113184cfa7954ebd274564b8c255fa9a /libc/stdlib/abort.c | |
parent | e4461be66e2655058aef358b00050bc70ac72861 (diff) | |
download | uClibc-alpine-cb6a88484ce0b5ffba2fe98a40e2d51f4af92eb8.tar.bz2 uClibc-alpine-cb6a88484ce0b5ffba2fe98a40e2d51f4af92eb8.tar.xz |
Merge from trunk. Going pretty good so far. Kind of. Okay, not really.
Diffstat (limited to 'libc/stdlib/abort.c')
-rw-r--r-- | libc/stdlib/abort.c | 70 |
1 files changed, 21 insertions, 49 deletions
diff --git a/libc/stdlib/abort.c b/libc/stdlib/abort.c index 47252d1f7..a940768c0 100644 --- a/libc/stdlib/abort.c +++ b/libc/stdlib/abort.c @@ -18,9 +18,6 @@ Cambridge, MA 02139, USA. */ /* Hacked up for uClibc by Erik Andersen */ -#define sigaction __sigaction - -#define _GNU_SOURCE #include <features.h> #include <signal.h> #include <stdio.h> @@ -30,41 +27,20 @@ Cambridge, MA 02139, USA. */ #include <signal.h> #include <errno.h> +libc_hidden_proto(abort) + +libc_hidden_proto(memset) +libc_hidden_proto(sigaction) +libc_hidden_proto(sigprocmask) +libc_hidden_proto(raise) +libc_hidden_proto(_exit) /* Our last ditch effort to commit suicide */ -#if defined(__alpha__) -#define ABORT_INSTRUCTION asm ("call_pal 0") -#elif defined(__arm__) -#define ABORT_INSTRUCTION asm ("bl abort") -#elif defined(__hppa__) -#define ABORT_INSTRUCTION asm ("iitlbp %r0,(%r0)") -#elif defined(__i386__) -#define ABORT_INSTRUCTION asm ("hlt") -#elif defined(__ia64__) -#define ABORT_INSTRUCTION asm ("break 0") -#elif defined(__m68k__) -#define ABORT_INSTRUCTION asm ("illegal") -#elif defined(__mc68000__) -#define ABORT_INSTRUCTION asm (".long 0xffffffff") -#elif defined(__mips__) -#define ABORT_INSTRUCTION asm ("break 255") -#elif defined(__powerpc__) -#define ABORT_INSTRUCTION asm (".long 0") -#elif defined(__s390__) -#define ABORT_INSTRUCTION asm (".word 0") -#elif defined(__sparc__) -#define ABORT_INSTRUCTION asm ("unimp 0xf00") -#elif defined(__SH5__) -#define ABORT_INSTRUCTION asm ("movi 0x10, r9; shori 0xff, r9; trapa r9") -#elif defined(__sh2__) -#define ABORT_INSTRUCTION asm ("trapa #32") -#elif defined(__sh__) -#define ABORT_INSTRUCTION asm ("trapa #0xff") -#elif defined(__x86_64__) -#define ABORT_INSTRUCTION asm ("hlt") +#ifdef __UCLIBC_ABORT_INSTRUCTION__ +# define ABORT_INSTRUCTION __asm__(__UCLIBC_ABORT_INSTRUCTION__) #else -#define ABORT_INSTRUCTION -#warning no abort instruction defined for your arch +# define ABORT_INSTRUCTION +# warning "no abort instruction defined for your arch" #endif #ifdef __UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT__ @@ -80,21 +56,17 @@ static pthread_mutex_t mylock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; #define LOCK __pthread_mutex_lock(&mylock) #define UNLOCK __pthread_mutex_unlock(&mylock) -extern int __raise (int __sig) __THROW attribute_hidden; - /* Cause an abnormal program termination with core-dump */ -#undef __abort -#undef abort -void attribute_hidden __abort(void) +void abort(void) { - sigset_t sigset; + sigset_t sigs; /* Make sure we acquire the lock before proceeding */ LOCK; /* Unmask SIGABRT to be sure we can get it */ - if (__sigemptyset(&sigset) == 0 && __sigaddset(&sigset, SIGABRT) == 0) { - __sigprocmask(SIG_UNBLOCK, &sigset, (sigset_t *) NULL); + if (__sigemptyset(&sigs) == 0 && __sigaddset(&sigs, SIGABRT) == 0) { + sigprocmask(SIG_UNBLOCK, &sigs, (sigset_t *) NULL); } while (1) { @@ -104,8 +76,8 @@ void attribute_hidden __abort(void) #ifdef __UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT__ /* If we are using stdio, try to shut it down. At the very least, - * this will attemt to commit all buffered writes. It may also - * unboffer all writable files, or close them outright. + * this will attempt to commit all buffered writes. It may also + * unbuffer all writable files, or close them outright. * Check the stdio routines for details. */ if (_stdio_term) { _stdio_term(); @@ -114,7 +86,7 @@ void attribute_hidden __abort(void) abort_it: UNLOCK; - __raise(SIGABRT); + raise(SIGABRT); LOCK; } @@ -123,7 +95,7 @@ abort_it: struct sigaction act; been_there_done_that++; - __memset(&act, '\0', sizeof(struct sigaction)); + memset(&act, '\0', sizeof(struct sigaction)); act.sa_handler = SIG_DFL; __sigfillset(&act.sa_mask); act.sa_flags = 0; @@ -141,7 +113,7 @@ abort_it: /* Still here? Try to at least exit */ if (been_there_done_that == 3) { been_there_done_that++; - _exit_internal(127); + _exit(127); } /* Still here? We're screwed. Sleepy time. Good night. */ @@ -150,4 +122,4 @@ abort_it: ABORT_INSTRUCTION; } } -strong_alias(__abort,abort) +libc_hidden_def(abort) |