Merge pull request #2661 from tboerger/musl-fixes

Musl fixes
This commit is contained in:
worktycho 2015-11-19 22:42:16 +00:00
commit dd7572925b
2 changed files with 11 additions and 7 deletions

View File

@ -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(): // 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)); char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer));
if (res != nullptr) if (res != nullptr)

View File

@ -8,7 +8,9 @@
#ifdef _WIN32 #ifdef _WIN32
#include "../StackWalker.h" #include "../StackWalker.h"
#else #else
#include <execinfo.h> #ifdef __GLIBC__
#include <execinfo.h>
#endif
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -38,11 +40,13 @@ void PrintStackTrace(void)
} sw; } sw;
sw.ShowCallstack(); sw.ShowCallstack();
#else #else
// Use the backtrace() function to get and output the stackTrace: #ifdef __GLIBC__
// Code adapted from http://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes // Use the backtrace() function to get and output the stackTrace:
void * stackTrace[30]; // Code adapted from http://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes
btsize numItems = backtrace(stackTrace, ARRAYCOUNT(stackTrace)); void * stackTrace[30];
backtrace_symbols_fd(stackTrace, numItems, STDERR_FILENO); btsize numItems = backtrace(stackTrace, ARRAYCOUNT(stackTrace));
backtrace_symbols_fd(stackTrace, numItems, STDERR_FILENO);
#endif
#endif #endif
} }