Check for build environment instead of just _GNU_SOURCE
Fixes the build on OpenBSD and NetBSD. It is too easy for _GNU_SOURCE to be defined even on non-Linux systems. Found via py-zstandard with the embedded copy of zstandard and Python defines _GNU_SOURCE. Also simplify the Linux checking, there is no need to check the rest of the symbol names.
This commit is contained in:
@@ -21,10 +21,12 @@
|
|||||||
/*-*************************************
|
/*-*************************************
|
||||||
* Dependencies
|
* Dependencies
|
||||||
***************************************/
|
***************************************/
|
||||||
/* qsort_r is an extension. */
|
/* qsort_r is an extension.
|
||||||
#if defined(__linux) || defined(__linux__) || defined(linux) || defined(__gnu_linux__) || \
|
*
|
||||||
defined(__CYGWIN__) || defined(__MSYS__)
|
* Android NDK does not ship qsort_r().
|
||||||
# if !defined(_GNU_SOURCE) && !defined(__ANDROID__) /* NDK doesn't ship qsort_r(). */
|
*/
|
||||||
|
#if (defined(__linux__) && !defined(__ANDROID__)) || defined(__CYGWIN__) || defined(__MSYS__)
|
||||||
|
# ifndef _GNU_SOURCE
|
||||||
# define _GNU_SOURCE
|
# define _GNU_SOURCE
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
@@ -77,7 +79,7 @@
|
|||||||
#ifndef ZDICT_QSORT
|
#ifndef ZDICT_QSORT
|
||||||
# if defined(__APPLE__)
|
# if defined(__APPLE__)
|
||||||
# define ZDICT_QSORT ZDICT_QSORT_APPLE /* uses qsort_r() with a different order for parameters */
|
# define ZDICT_QSORT ZDICT_QSORT_APPLE /* uses qsort_r() with a different order for parameters */
|
||||||
# elif defined(_GNU_SOURCE)
|
# elif (defined(__linux__) && !defined(__ANDROID__)) || defined(__CYGWIN__) || defined(__MSYS__)
|
||||||
# define ZDICT_QSORT ZDICT_QSORT_GNU /* uses qsort_r() */
|
# define ZDICT_QSORT ZDICT_QSORT_GNU /* uses qsort_r() */
|
||||||
# elif defined(_WIN32) && defined(_MSC_VER)
|
# elif defined(_WIN32) && defined(_MSC_VER)
|
||||||
# define ZDICT_QSORT ZDICT_QSORT_MSVC /* uses qsort_s() with a different order for parameters */
|
# define ZDICT_QSORT ZDICT_QSORT_MSVC /* uses qsort_s() with a different order for parameters */
|
||||||
|
|||||||
Reference in New Issue
Block a user