mcst-linux-kernel/patches-2024.06.26/gl4es-1.1.4/0080-Detect-stacktrace-supp...

101 lines
3.0 KiB
Diff

From b10ec45fc501e3f29b4a0ebd7ce02eb70e8e9451 Mon Sep 17 00:00:00 2001
From: Paul Cercueil <paul@crapouillou.net>
Date: Tue, 27 Oct 2020 19:03:10 +0000
Subject: [PATCH 080/233] Detect stacktrace support in CMake script
Remove unused execinfo.h includes, and detect stacktrace support in
CMake script so that we can still build for systems that lack this
functionality.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
CMakeLists.txt | 6 ++++++
src/gl/framebuffers.c | 3 ---
src/gl/init.c | 3 ---
src/gl/samplers.c | 3 ---
src/glx/glx.c | 6 +++---
5 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index af2dec88..15099d89 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,6 +24,12 @@ option(USE_CLOCK "Set to ON to use clock_gettime instead of gttimeofday for LIBG
option(NO_LOADER "disable library loader (useful for static library with NOEGL, NOX11, use include/gl4esinit.h)" ${NO_LOADER})
option(NO_INIT_CONSTRUCTOR "disable automatic initialization (useful for static library, use include/gl4esinit.h)" ${NO_INIT_CONSTRUCTOR})
+include(CheckSymbolExists)
+check_symbol_exists(backtrace "execinfo.h" HAS_BACKTRACE)
+if (HAS_BACKTRACE)
+ add_definitions(-DHAS_BACKTRACE)
+endif()
+
# Pandora
if(PANDORA)
add_definitions(-DPANDORA)
diff --git a/src/gl/framebuffers.c b/src/gl/framebuffers.c
index 0028e8b5..50f82c77 100755
--- a/src/gl/framebuffers.c
+++ b/src/gl/framebuffers.c
@@ -1,8 +1,5 @@
#include "framebuffers.h"
-#if !defined(ANDROID) && !defined(AMIGAOS4) && !defined(__EMSCRIPTEN__) && !defined(__APPLE__)
-#include <execinfo.h>
-#endif
#include "../glx/hardext.h"
#include "blit.h"
#include "debug.h"
diff --git a/src/gl/init.c b/src/gl/init.c
index 0577a27b..aab1c3dc 100755
--- a/src/gl/init.c
+++ b/src/gl/init.c
@@ -1,6 +1,3 @@
-#if !defined(ANDROID) && !defined(AMIGAOS4) && !defined(__EMSCRIPTEN__) && !defined(__APPLE__)
-#include <execinfo.h>
-#endif
#include <stdio.h>
#include <unistd.h>
#include "../../version.h"
diff --git a/src/gl/samplers.c b/src/gl/samplers.c
index 9f7e0227..c9f206c1 100755
--- a/src/gl/samplers.c
+++ b/src/gl/samplers.c
@@ -1,8 +1,5 @@
#include "samplers.h"
-#if !defined(ANDROID) && !defined(AMIGAOS4) && !defined(__EMSCRIPTEN__) && !defined(__APPLE__)
-#include <execinfo.h>
-#endif
#include "../glx/hardext.h"
#include "blit.h"
#include "debug.h"
diff --git a/src/glx/glx.c b/src/glx/glx.c
index 8bd8e37b..fb60600a 100755
--- a/src/glx/glx.c
+++ b/src/glx/glx.c
@@ -1,9 +1,9 @@
#include "glx.h"
#include "../gl/init.h"
-#if !defined(ANDROID) && !defined(AMIGAOS4)
+#ifdef HAS_BACKTRACE
#include <execinfo.h>
-#endif // !defined(ANDROID) && !defined(AMIGAOS4)
+#endif // HAS_BACKTRACE
#include <fcntl.h>
#include "khash.h"
#ifdef USE_FBIO
@@ -458,7 +458,7 @@ static void signal_handler(int sig) {
#if defined(BCMHOST) && !defined(ANDROID)
rpi_fini();
#endif
-#if !defined(ANDROID) && !defined(AMIGAOS4)
+#ifdef HAS_BACKTRACE
if (globals4es.stacktrace) {
switch (sig) {
case SIGBUS:
--
2.11.0