]> granicus.if.org Git - openjpeg/commitdiff
Fix support of posix_memalign for Linux
authorStefan Weil <sw@weilnetz.de>
Sun, 1 Nov 2015 19:37:19 +0000 (20:37 +0100)
committerStefan Weil <sw@weilnetz.de>
Wed, 6 Jan 2016 17:06:45 +0000 (18:06 +0100)
posix_memalign is only declared conditionally in stdlib.h,
so add one of the possible definitions to get the declaration.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
CMakeLists.txt
src/lib/openjp2/opj_config_private.h.cmake.in

index b014a00fd7e81c02bfbef5c5e843f37449b0f393..3326b54e5cc24a2c10069f5c146d958dca00938b 100644 (file)
@@ -231,8 +231,10 @@ check_include_files(malloc.h OPJ_HAVE_MALLOC_H)
 include(CheckSymbolExists)
 # _aligned_alloc https://msdn.microsoft.com/en-us/library/8z34s9c6.aspx
 check_symbol_exists(_aligned_malloc malloc.h OPJ_HAVE__ALIGNED_MALLOC)
-# posix_memalign
+# posix_memalign (needs _POSIX_C_SOURCE >= 200112L on Linux)
+set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L)
 check_symbol_exists(posix_memalign stdlib.h OPJ_HAVE_POSIX_MEMALIGN)
+unset(CMAKE_REQUIRED_DEFINITIONS)
 # memalign (obsolete)
 check_symbol_exists(memalign malloc.h OPJ_HAVE_MEMALIGN)
 #-----------------------------------------------------------------------------
index b05822c3ca0a6cb1225e703f5a153e2e9dcfc768..c41f9066242d7318b89beab7a33132007cfff3fc 100644 (file)
 /* check if function `posix_memalign` exists */
 #cmakedefine OPJ_HAVE_POSIX_MEMALIGN
 
+#if !defined(_POSIX_C_SOURCE)
+#if defined(OPJ_HAVE_FSEEKO) || defined(OPJ_HAVE_POSIX_MEMALIGN)
+/* Get declarations of fseeko, ftello, posix_memalign. */
+#define _POSIX_C_SOURCE 200112L
+#endif
+#endif
+
 /* Byte order.  */
 /* All compilers that support Mac OS X define either __BIG_ENDIAN__ or
 __LITTLE_ENDIAN__ to match the endianness of the architecture being