]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[zstd][android] Fix build with NDK r27 4107/head
authorAdenilson Cavalcanti <cavalcantii@chromium.org>
Mon, 29 Jul 2024 23:37:41 +0000 (16:37 -0700)
committerAdenilson Cavalcanti <cavalcantii@chromium.org>
Tue, 30 Jul 2024 00:13:58 +0000 (17:13 -0700)
The NDK cross compiler declares the target as __linux (which is
not technically incorrect), which triggers the enablement of _GNU_SOURCE
in the newly added code that requires the presence of qsort_r() used
in the COVER dictionary code.

Even though the NDK uses llvm/libc, it doesn't declare qsort_r()
in the stdlib.h header.

The build fix is to only activate the _GNU_SOURCE macro if the OS is
*not* Android, as then we will fallback to the C90 compliant code.

This patch should solve the reported issue number #4103.

lib/common/zstd_deps.h
lib/dictBuilder/cover.c

index f41a973c3476baa5c49907f5d80a8739b594f962..8a9c7cc5313ad8c507f456e43f2b3afaad374673 100644 (file)
@@ -31,7 +31,7 @@
  */
 #if defined(__linux) || defined(__linux__) || defined(linux) || defined(__gnu_linux__) || \
     defined(__CYGWIN__) || defined(__MSYS__)
-#if !defined(_GNU_SOURCE)
+#if !defined(_GNU_SOURCE) && !defined(__ANDROID__) /* NDK doesn't ship qsort_r(). */
 #define _GNU_SOURCE
 #endif
 #endif
index 386a4d57210c992b792c57a962e94d5b70b41a88..2ef33c73e5d91747cfc5782aadd6d6ddc197a476 100644 (file)
@@ -24,7 +24,7 @@
 /* qsort_r is an extension. */
 #if defined(__linux) || defined(__linux__) || defined(linux) || defined(__gnu_linux__) || \
     defined(__CYGWIN__) || defined(__MSYS__)
-#if !defined(_GNU_SOURCE)
+#if !defined(_GNU_SOURCE) && !defined(__ANDROID__) /* NDK doesn't ship qsort_r(). */
 #define _GNU_SOURCE
 #endif
 #endif