Skip to content

Commit 994129b

Browse files
brad0indygreg
authored andcommitted
zstd: cherry-pick qsort commit
This change reflects a cherry-pick of the following upstream commit from facebook/zstd#4463: * 0d1f8de9addeb2fcb53f1a6a68ef4ac505253c0e This commit is necessary to fix building on OpenBSD and NetBSD. Python sets _GNU_SOURCE breaking the build. Closes #272.
1 parent c275654 commit 994129b

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

docs/news.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Version History
1010
* PyO3 Rust created upgraded from 0.24 to 0.25. (#273)
1111
* We now use `Py_REFCNT(obj)` instead of accessing `(*obj)->ob_refcnt` directly.
1212
This fixes a nogil / multi-threaded compile error. (#201, #275)
13+
* A zstandard commit to fix qsort detection on BSD operating systems
14+
has been backported. (#272)
1315

1416
0.24.0 (released 2025-08-17)
1517
============================

zstd/zstd.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@
8585
* header and the script 'combine.sh' combines the whole zstd source code
8686
* in a single file.
8787
*/
88-
#if defined(__linux) || defined(__linux__) || defined(linux) || defined(__gnu_linux__) || \
89-
defined(__CYGWIN__) || defined(__MSYS__)
90-
#if !defined(_GNU_SOURCE) && !defined(__ANDROID__) /* NDK doesn't ship qsort_r(). */
88+
#if (defined(__linux__) && !defined(__ANDROID__)) || defined(__CYGWIN__) || defined(__MSYS__)
89+
#ifndef _GNU_SOURCE
9190
#define _GNU_SOURCE
9291
#endif
9392
#endif
@@ -47866,10 +47865,12 @@ size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx,
4786647865
/*-*************************************
4786747866
* Dependencies
4786847867
***************************************/
47869-
/* qsort_r is an extension. */
47870-
#if defined(__linux) || defined(__linux__) || defined(linux) || defined(__gnu_linux__) || \
47871-
defined(__CYGWIN__) || defined(__MSYS__)
47872-
# if !defined(_GNU_SOURCE) && !defined(__ANDROID__) /* NDK doesn't ship qsort_r(). */
47868+
/* qsort_r is an extension.
47869+
*
47870+
* Android NDK does not ship qsort_r().
47871+
*/
47872+
#if (defined(__linux__) && !defined(__ANDROID__)) || defined(__CYGWIN__) || defined(__MSYS__)
47873+
# ifndef _GNU_SOURCE
4787347874
# define _GNU_SOURCE
4787447875
# endif
4787547876
#endif
@@ -48557,7 +48558,7 @@ void COVER_dictSelectionFree(COVER_dictSelection_t selection);
4855748558
#ifndef ZDICT_QSORT
4855848559
# if defined(__APPLE__)
4855948560
# define ZDICT_QSORT ZDICT_QSORT_APPLE /* uses qsort_r() with a different order for parameters */
48560-
# elif defined(_GNU_SOURCE)
48561+
# elif (defined(__linux__) && !defined(__ANDROID__)) || defined(__CYGWIN__) || defined(__MSYS__)
4856148562
# define ZDICT_QSORT ZDICT_QSORT_GNU /* uses qsort_r() */
4856248563
# elif defined(_WIN32) && defined(_MSC_VER)
4856348564
# define ZDICT_QSORT ZDICT_QSORT_MSVC /* uses qsort_s() with a different order for parameters */

0 commit comments

Comments
 (0)