diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-06-29 21:17:39 -0600 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-06-29 21:17:39 -0600 |
commit | 1874938c0d35990f95e494a7fef066bf97001d8f (patch) | |
tree | b6c43254129237843d07f7cbf13572397e6973f6 /libdimension/error.c | |
parent | eb4691098767935c1ffd10f7da46796c11eefcfa (diff) | |
download | dimension-1874938c0d35990f95e494a7fef066bf97001d8f.tar.xz |
Move platform-specific stuff in libdimension into platform.c.
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 } |