From 8f3f91d3db1f740002c2f69327370350753c8851 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 19 Nov 2015 22:23:47 +0100 Subject: Check for __GLIBC__ to detect correct strerror_r version --- src/OSSupport/Errors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/OSSupport/Errors.cpp b/src/OSSupport/Errors.cpp index 7fcd3168f..ce2e2acb0 100644 --- a/src/OSSupport/Errors.cpp +++ b/src/OSSupport/Errors.cpp @@ -22,7 +22,7 @@ AString GetOSErrorString( int a_ErrNo) // According to http://linux.die.net/man/3/strerror_r there are two versions of strerror_r(): - #if !defined(__APPLE__) && defined( _GNU_SOURCE) && !defined(ANDROID_NDK) // GNU version of strerror_r() + #if defined(__GLIBC__) && defined( _GNU_SOURCE) && !defined(ANDROID_NDK) // GNU version of strerror_r() char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer)); if (res != nullptr) -- cgit v1.2.3 From a16a9eab4fa7da5bd741e1b4dbc5315768dec6ad Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 19 Nov 2015 22:26:39 +0100 Subject: Define stacktrace functions only if __GLIBC__ is defined --- src/OSSupport/StackTrace.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/OSSupport/StackTrace.cpp b/src/OSSupport/StackTrace.cpp index 1ec10f20e..b39bb6b7f 100644 --- a/src/OSSupport/StackTrace.cpp +++ b/src/OSSupport/StackTrace.cpp @@ -38,11 +38,13 @@ void PrintStackTrace(void) } sw; sw.ShowCallstack(); #else - // Use the backtrace() function to get and output the stackTrace: - // Code adapted from http://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes - void * stackTrace[30]; - btsize numItems = backtrace(stackTrace, ARRAYCOUNT(stackTrace)); - backtrace_symbols_fd(stackTrace, numItems, STDERR_FILENO); + #ifdef __GLIBC__ + // Use the backtrace() function to get and output the stackTrace: + // Code adapted from http://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes + void * stackTrace[30]; + btsize numItems = backtrace(stackTrace, ARRAYCOUNT(stackTrace)); + backtrace_symbols_fd(stackTrace, numItems, STDERR_FILENO); + #endif #endif } -- cgit v1.2.3 From ffed4891569a5bcc16c4b16744a5adcf932b4f85 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 19 Nov 2015 22:34:32 +0100 Subject: Include execinfo.h only on __GLIBC__ --- src/OSSupport/StackTrace.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/OSSupport/StackTrace.cpp b/src/OSSupport/StackTrace.cpp index b39bb6b7f..d0e088f4e 100644 --- a/src/OSSupport/StackTrace.cpp +++ b/src/OSSupport/StackTrace.cpp @@ -8,7 +8,9 @@ #ifdef _WIN32 #include "../StackWalker.h" #else - #include + #ifdef __GLIBC__ + #include + #endif #include #endif -- cgit v1.2.3