]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Pass POSIX_C_SOURCE for std::alligned_alloc try_compile checks
authorCristi Vîjdea <cvijdea@bitdefender.com>
Fri, 4 Apr 2025 13:32:36 +0000 (16:32 +0300)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Sat, 26 Jul 2025 18:44:20 +0000 (20:44 +0200)
On FreeBSD 11, definining POSIX_C_SOURCE to a lower level has the efect of inhibiting the language level (__ISO_C_VISIBLE ) to be lower than C11, even in the presence of -std=c11

Since the check_symbol_exists runs without setting POSIX_C_SOURCE, this means that we will spuriously define HAVE_ALIGNED_ALLOC, while in the actual build it is not going to be defined

ref: https://github.com/freebsd/freebsd-src/blob/stable/11/sys/sys/cdefs.h#L738

CMakeLists.txt
configure

index 35f71b0f0202c2e2fb3992b352ef5d115daee94b..13a04d5d7bdaa5242e06f2248158e0a38dbe9317 100644 (file)
@@ -436,7 +436,10 @@ if(NOT HAVE_STRERROR)
 endif()
 set(CMAKE_REQUIRED_FLAGS)
 
-set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L)
+#
+# Check for aligned memory allocation support: POSIX
+#
+set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L -D_ISOC11_SOURCE=1)
 set(CMAKE_REQUIRED_FLAGS "${ADDITIONAL_CHECK_FLAGS}")
 check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
 if(HAVE_POSIX_MEMALIGN)
@@ -445,7 +448,10 @@ endif()
 set(CMAKE_REQUIRED_FLAGS)
 set(CMAKE_REQUIRED_DEFINITIONS)
 
-set(CMAKE_REQUIRED_DEFINITIONS -D_ISOC11_SOURCE=1)
+#
+# Check for aligned memory allocation support: C11
+#
+set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L -D_ISOC11_SOURCE=1)
 set(CMAKE_REQUIRED_FLAGS "${ADDITIONAL_CHECK_FLAGS}")
 check_symbol_exists(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
 if(HAVE_ALIGNED_ALLOC)
index 8548f8a65212d8a88251f515749a579c0326420e..60a4eee9dc23cfa76830f56ba3ac74ece6e00cd2 100755 (executable)
--- a/configure
+++ b/configure
@@ -722,6 +722,7 @@ echo >> configure.log
 
 cat > $test.c <<EOF
 #define _POSIX_C_SOURCE 200112L
+#define _ISOC11_SOURCE 1
 #include <stdlib.h>
 int main(void) {
   void *ptr = 0;
@@ -741,6 +742,7 @@ fi
 echo >> configure.log
 
 cat > $test.c <<EOF
+#define _POSIX_C_SOURCE 200112L
 #define _ISOC11_SOURCE 1
 #include <stdlib.h>
 int main(void) {