Make execinfo.h optional (fixes musl libc build)

This commit is contained in:
Hanicef 2023-12-25 14:31:44 +01:00 committed by Alam Ed Arias
parent dbce1493ee
commit 13cfc5ef59
2 changed files with 9 additions and 1 deletions

View file

@ -5,7 +5,7 @@
passthru_opts+=\ passthru_opts+=\
NONET NO_IPV6 NOHW NOMD5 NOPOSTPROCESSING\ NONET NO_IPV6 NOHW NOMD5 NOPOSTPROCESSING\
MOBJCONSISTANCY PACKETDROP ZDEBUG\ MOBJCONSISTANCY PACKETDROP ZDEBUG\
HAVE_MINIUPNPC\ HAVE_MINIUPNPC NOEXECINFO\
# build with debugging information # build with debugging information
ifdef DEBUGMODE ifdef DEBUGMODE

View file

@ -138,7 +138,9 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#endif #endif
#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
#ifndef NOEXECINFO
#include <execinfo.h> #include <execinfo.h>
#endif
#include <time.h> #include <time.h>
#define UNIXBACKTRACE #define UNIXBACKTRACE
#endif #endif
@ -268,13 +270,17 @@ UINT8 keyboard_started = false;
static void write_backtrace(INT32 signal) static void write_backtrace(INT32 signal)
{ {
int fd = -1; int fd = -1;
#ifndef NOEXECINFO
size_t size; size_t size;
#endif
time_t rawtime; time_t rawtime;
struct tm timeinfo; struct tm timeinfo;
ssize_t junk; ssize_t junk;
enum { BT_SIZE = 1024, STR_SIZE = 32 }; enum { BT_SIZE = 1024, STR_SIZE = 32 };
#ifndef NOEXECINFO
void *array[BT_SIZE]; void *array[BT_SIZE];
#endif
char timestr[STR_SIZE]; char timestr[STR_SIZE];
const char *error = "An error occurred within SRB2! Send this stack trace to someone who can help!\n"; const char *error = "An error occurred within SRB2! Send this stack trace to someone who can help!\n";
@ -307,12 +313,14 @@ static void write_backtrace(INT32 signal)
CRASHLOG_WRITE(strsignal(signal)); CRASHLOG_WRITE(strsignal(signal));
CRASHLOG_WRITE("\n"); // Newline for the signal name CRASHLOG_WRITE("\n"); // Newline for the signal name
#ifndef NOEXECINFO
CRASHLOG_STDERR_WRITE("\nBacktrace:\n"); CRASHLOG_STDERR_WRITE("\nBacktrace:\n");
// Flood the output and log with the backtrace // Flood the output and log with the backtrace
size = backtrace(array, BT_SIZE); size = backtrace(array, BT_SIZE);
backtrace_symbols_fd(array, size, fd); backtrace_symbols_fd(array, size, fd);
backtrace_symbols_fd(array, size, STDERR_FILENO); backtrace_symbols_fd(array, size, STDERR_FILENO);
#endif
CRASHLOG_WRITE("\n"); // Write another newline to the log so it looks nice :) CRASHLOG_WRITE("\n"); // Write another newline to the log so it looks nice :)
(void)junk; (void)junk;