fix mingw compatibility
only enable backtraces for platforms we know support it aka mac OS-X and Linux. can be extended later.
This commit is contained in:
parent
de6c75e4e5
commit
54001f3dbc
@ -20,6 +20,9 @@
|
|||||||
# define _POSIX_SOURCE 1 /* disable %llu warnings with MinGW on Windows */
|
# define _POSIX_SOURCE 1 /* disable %llu warnings with MinGW on Windows */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__))
|
||||||
|
# define BACKTRACES_ENABLE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/*-*************************************
|
/*-*************************************
|
||||||
* Includes
|
* Includes
|
||||||
@ -31,7 +34,7 @@
|
|||||||
#include <string.h> /* strcmp, strlen */
|
#include <string.h> /* strcmp, strlen */
|
||||||
#include <errno.h> /* errno */
|
#include <errno.h> /* errno */
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#ifndef _WIN32
|
#ifdef BACKTRACES_ENABLE
|
||||||
# include <execinfo.h> /* backtrace, backtrace_symbols */
|
# include <execinfo.h> /* backtrace, backtrace_symbols */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -162,9 +165,10 @@ static void clearHandler(void)
|
|||||||
/*-*********************************************************
|
/*-*********************************************************
|
||||||
* Termination signal trapping (Print debug stack trace)
|
* Termination signal trapping (Print debug stack trace)
|
||||||
***********************************************************/
|
***********************************************************/
|
||||||
|
#ifdef BACKTRACES_ENABLE
|
||||||
|
|
||||||
#define MAX_STACK_FRAMES 50
|
#define MAX_STACK_FRAMES 50
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
static void ABRThandler(int sig) {
|
static void ABRThandler(int sig) {
|
||||||
const char* name;
|
const char* name;
|
||||||
void* addrlist[MAX_STACK_FRAMES];
|
void* addrlist[MAX_STACK_FRAMES];
|
||||||
@ -202,7 +206,7 @@ static void ABRThandler(int sig) {
|
|||||||
|
|
||||||
void FIO_addAbortHandler()
|
void FIO_addAbortHandler()
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
#ifdef BACKTRACES_ENABLE
|
||||||
signal(SIGABRT, ABRThandler);
|
signal(SIGABRT, ABRThandler);
|
||||||
signal(SIGFPE, ABRThandler);
|
signal(SIGFPE, ABRThandler);
|
||||||
signal(SIGILL, ABRThandler);
|
signal(SIGILL, ABRThandler);
|
||||||
|
@ -170,7 +170,11 @@ static int g_utilDisplayLevel;
|
|||||||
return ((clockEnd - clockStart) * (U64)rate.numer) / ((U64)rate.denom);
|
return ((clockEnd - clockStart) * (U64)rate.numer) / ((U64)rate.denom);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (PLATFORM_POSIX_VERSION >= 200112L) && (defined __UCLIBC__ || ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17) || __GLIBC__ > 2))
|
#elif (PLATFORM_POSIX_VERSION >= 200112L) \
|
||||||
|
&& (defined(__UCLIBC__) \
|
||||||
|
|| (defined(__GLIBC__) \
|
||||||
|
&& ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17) \
|
||||||
|
|| (__GLIBC__ > 2))))
|
||||||
|
|
||||||
#define UTIL_TIME_INITIALIZER { 0, 0 }
|
#define UTIL_TIME_INITIALIZER { 0, 0 }
|
||||||
typedef struct timespec UTIL_freq_t;
|
typedef struct timespec UTIL_freq_t;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user