diff options
Diffstat (limited to 'libdimension/error.c')
-rw-r--r-- | libdimension/error.c | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/libdimension/error.c b/libdimension/error.c index 49b1d8d..bc0e3e2 100644 --- a/libdimension/error.c +++ b/libdimension/error.c @@ -18,15 +18,10 @@ * <http://www.gnu.org/licenses/>. * *************************************************************************/ -#define _GNU_SOURCE -#include <unistd.h> -#include <sys/syscall.h> /* For gettid() where supported */ -#include <execinfo.h> /* For backtrace() etc. */ - -#include "dimension.h" +#include "dimension_impl.h" #include <pthread.h> -#include <stdio.h> /* For fprintf() */ -#include <stdlib.h> /* For exit() */ +#include <stdio.h> /* For fprintf() */ +#include <stdlib.h> /* For exit() */ static void dmnsn_default_fatal_error_fn(); static dmnsn_fatal_error_fn *dmnsn_fatal = &dmnsn_default_fatal_error_fn; @@ -139,18 +134,9 @@ void dmnsn_set_fatal_error_fn(dmnsn_fatal_error_fn *fatal) static void dmnsn_default_fatal_error_fn() { - const unsigned int size = 64; - void *buffer[size]; - - int nptrs = backtrace(buffer, size); - /* buffer + 1 to hide this static function */ - backtrace_symbols_fd(buffer + 1, nptrs - 1, STDERR_FILENO); - -#ifdef SYS_gettid - pid_t pid = getpid(), - tid = syscall(SYS_gettid); + dmnsn_backtrace(stderr); - if (pid == tid) { + if (dmnsn_is_main_thread()) { exit(EXIT_FAILURE); } else { int *ret = malloc(sizeof(int)); /* Don't use dmnsn_malloc */ @@ -158,7 +144,4 @@ dmnsn_default_fatal_error_fn() *ret = 1; pthread_exit(ret); } -#else - exit(EXIT_FAILURE); -#endif } |