]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed explicit BACKTRACE order
authorYann Collet <cyan@fb.com>
Wed, 10 Oct 2018 00:12:21 +0000 (17:12 -0700)
committerYann Collet <cyan@fb.com>
Wed, 10 Oct 2018 00:12:21 +0000 (17:12 -0700)
and automatic linux backtrace detection :
__GLIBC__ must be tested after #include <features.h>

programs/Makefile
programs/fileio.c

index 9e241357bfa0fd4b7b95cf16a82a789543f8c118..ac17caee8b232ba76f2bd9482968c6d343d7a29d 100644 (file)
@@ -134,8 +134,10 @@ else
 LZ4_MSG := $(NO_LZ4_MSG)
 endif
 
-# enable backtrace symbol names for Linux & Darwin
-BACKTRACE ?= 0
+# explicit backtrace enable/disable for Linux & Darwin
+ifeq ($(BACKTRACE), 0)
+DEBUGFLAGS += -DBACKTRACE_ENABLE=0
+endif
 ifeq (,$(filter Windows%, $(OS)))
 ifeq ($(BACKTRACE), 1)
 DEBUGFLAGS += -DBACKTRACE_ENABLE=1
index 8b1e9f2f224740b8469cc147d90b9a54e6ef111d..16bfd530db7a6529dc1a5b59ab89ffc6f30bcd75 100644 (file)
 #  define _POSIX_SOURCE 1          /* disable %llu warnings with MinGW on Windows */
 #endif
 
-#if !defined(BACKTRACE_ENABLE)          \
-   && ((defined(__linux__) && defined(__GLIBC__)) \
-       || (defined(__APPLE__) && defined(__MACH__)) )
-#  define BACKTRACE_ENABLE 1
-#endif
-
 
 /*-*************************************
 *  Includes
@@ -38,9 +32,6 @@
 #include <assert.h>
 #include <errno.h>      /* errno */
 #include <signal.h>
-#if defined(BACKTRACE_ENABLE) && (BACKTRACE_ENABLE >= 1)
-#  include <execinfo.h>   /* backtrace, backtrace_symbols */
-#endif
 
 #if defined (_MSC_VER)
 #  include <sys/stat.h>
@@ -168,8 +159,17 @@ static void clearHandler(void)
 /*-*********************************************************
 *  Termination signal trapping (Print debug stack trace)
 ***********************************************************/
+#if !defined(BACKTRACE_ENABLE)          \
+   && ((defined(__linux__) && defined(__GLIBC__)) \
+       || (defined(__APPLE__) && defined(__MACH__)) )
+#  define BACKTRACE_ENABLE 1
+#endif
+
+
 #if defined(BACKTRACE_ENABLE) && (BACKTRACE_ENABLE>=1)
 
+#include <execinfo.h>   /* backtrace, backtrace_symbols */
+
 #define MAX_STACK_FRAMES    50
 
 static void ABRThandler(int sig) {