Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/Vulkan-Loader.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Smith <brad@comstyle.com>2022-09-03 01:55:12 +0300
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2022-09-03 02:52:37 +0300
commitfdfdef6d1b75828c1c3658c867bbbc4adbec956c (patch)
treec14d623b0e16d11be39eb2035e29a6b44aaebbc8
parentefe6aa4f3fddd1cdca25d00fbf88490eb9a26831 (diff)
loader: Only use alloca.h if it exists otherwise fallback to stdlib.h
Check for the existence of the alloca.h header and only use it it exists, otherwise fallback to stdlib.h. Some OS's like macOS and QNX have both headers and can use either (stdlib.h includes alloca.h), some OS's like OpenBSD / FreeBSD / NetBSD do not have the alloca.h header and require the stdlib.h header.
-rw-r--r--loader/CMakeLists.txt4
-rw-r--r--loader/stack_allocation.h4
2 files changed, 7 insertions, 1 deletions
diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt
index 9235fa244..66ad8cc50 100644
--- a/loader/CMakeLists.txt
+++ b/loader/CMakeLists.txt
@@ -95,6 +95,10 @@ else()
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
target_compile_definitions(loader_specific_options INTERFACE __BSD_VISIBLE=1)
endif()
+ check_include_file("alloca.h" HAVE_ALLOCA_H)
+ if(HAVE_ALLOCA_H)
+ target_compile_definitions(loader_specific_options INTERFACE HAVE_ALLOCA_H)
+ endif()
endif()
set(NORMAL_LOADER_SRCS
diff --git a/loader/stack_allocation.h b/loader/stack_allocation.h
index c724de6ca..d1958fbdc 100644
--- a/loader/stack_allocation.h
+++ b/loader/stack_allocation.h
@@ -30,8 +30,10 @@
#if defined(_WIN32)
#include <malloc.h>
-#else
+#elif defined(HAVE_ALLOCA_H)
#include <alloca.h>
+#else
+#include <stdlib.h>
#endif
#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) || defined(__OpenBSD__)