From: Brad Smith Date: Fri, 2 Sep 2022 22:55:12 +0000 (-0400) Subject: loader: Only use alloca.h if it exists otherwise fallback to stdlib.h X-Git-Tag: upstream/1.3.240~114 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fdfdef6d1b75828c1c3658c867bbbc4adbec956c;p=platform%2Fupstream%2FVulkan-Loader.git 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. --- diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index 9235fa24..66ad8cc5 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 c724de6c..d1958fbd 100644 --- a/loader/stack_allocation.h +++ b/loader/stack_allocation.h @@ -30,8 +30,10 @@ #if defined(_WIN32) #include -#else +#elif defined(HAVE_ALLOCA_H) #include +#else +#include #endif #if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) || defined(__OpenBSD__)