diff options
| -rw-r--r-- | include/slang.h | 12 | ||||
| -rw-r--r-- | source/core/slang-platform.cpp | 6 |
2 files changed, 16 insertions, 2 deletions
diff --git a/include/slang.h b/include/slang.h index 3c2a31413..a3d979de5 100644 --- a/include/slang.h +++ b/include/slang.h @@ -489,6 +489,18 @@ convention for interface methods. #define SLANG_UNALIGNED_ACCESS 0 #endif +// Backtrace +#if SLANG_LINUX_FAMILY + #include <features.h> // for __GLIBC__ define, if using GNU libc + #if defined(__GLIBC__) || (__ANDROID_API__ >= 33) + #define SLANG_HAS_BACKTRACE 1 + #else + #define SLANG_HAS_BACKTRACE 0 + #endif +#else + #define SLANG_HAS_BACKTRACE 0 +#endif + // One endianness must be set #if ((SLANG_BIG_ENDIAN | SLANG_LITTLE_ENDIAN) == 0) #error "Couldn't determine endianness" diff --git a/source/core/slang-platform.cpp b/source/core/slang-platform.cpp index 7f79d99e1..25e6bc6f0 100644 --- a/source/core/slang-platform.cpp +++ b/source/core/slang-platform.cpp @@ -15,9 +15,11 @@ #include <dlfcn.h> #endif +#if SLANG_HAS_BACKTRACE +#include <execinfo.h> +#endif #if SLANG_LINUX_FAMILY -#include <execinfo.h> #include <unistd.h> #endif @@ -363,7 +365,7 @@ static const PlatformFlags s_familyFlags[int(PlatformFamily::CountOf)] = { /* static */ void PlatformUtil::backtrace() { -#if SLANG_LINUX_FAMILY +#if SLANG_HAS_BACKTRACE // Print stack trace for debugging assistance void* stackTrace[64]; int stackDepth = ::backtrace(stackTrace, 64); |
