introduce ZSTD_USE_C90_QSORT
This commit is contained in:
@@ -693,7 +693,7 @@ jobs:
|
|||||||
sudo apt install -y musl-tools
|
sudo apt install -y musl-tools
|
||||||
- name: Compile the project with musl-gcc
|
- name: Compile the project with musl-gcc
|
||||||
run: |
|
run: |
|
||||||
CC=musl-gcc make -j V=1 zstd
|
CC=musl-gcc CPPFLAGS=-DZSTD_USE_C90_QSORT make -j V=1 zstd
|
||||||
|
|
||||||
intel-cet-compatibility:
|
intel-cet-compatibility:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -24,9 +24,9 @@
|
|||||||
/* qsort_r is an extension. */
|
/* qsort_r is an extension. */
|
||||||
#if defined(__linux) || defined(__linux__) || defined(linux) || defined(__gnu_linux__) || \
|
#if defined(__linux) || defined(__linux__) || defined(linux) || defined(__gnu_linux__) || \
|
||||||
defined(__CYGWIN__) || defined(__MSYS__)
|
defined(__CYGWIN__) || defined(__MSYS__)
|
||||||
#if !defined(_GNU_SOURCE) && !defined(__ANDROID__) /* NDK doesn't ship qsort_r(). */
|
# if !defined(_GNU_SOURCE) && !defined(__ANDROID__) /* NDK doesn't ship qsort_r(). */
|
||||||
#define _GNU_SOURCE
|
# define _GNU_SOURCE
|
||||||
#endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h> /* fprintf */
|
#include <stdio.h> /* fprintf */
|
||||||
@@ -241,8 +241,9 @@ typedef struct {
|
|||||||
unsigned d;
|
unsigned d;
|
||||||
} COVER_ctx_t;
|
} COVER_ctx_t;
|
||||||
|
|
||||||
#if !defined(_GNU_SOURCE) && !defined(__APPLE__) && !defined(_MSC_VER)
|
#if defined(ZSTD_USE_C90_QSORT) \
|
||||||
/* C90 only offers qsort() that needs a global context. */
|
|| (!defined(_GNU_SOURCE) && !defined(__APPLE__) && !defined(_MSC_VER))
|
||||||
|
/* Use global context for non-reentrant sort functions */
|
||||||
static COVER_ctx_t *g_coverCtx = NULL;
|
static COVER_ctx_t *g_coverCtx = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -328,7 +329,7 @@ static void stableSort(COVER_ctx_t *ctx) {
|
|||||||
qsort_r(ctx->suffix, ctx->suffixSize, sizeof(U32),
|
qsort_r(ctx->suffix, ctx->suffixSize, sizeof(U32),
|
||||||
ctx,
|
ctx,
|
||||||
(ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp));
|
(ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp));
|
||||||
#elif defined(_GNU_SOURCE)
|
#elif defined(_GNU_SOURCE) && !defined(ZSTD_USE_C90_QSORT)
|
||||||
qsort_r(ctx->suffix, ctx->suffixSize, sizeof(U32),
|
qsort_r(ctx->suffix, ctx->suffixSize, sizeof(U32),
|
||||||
(ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp),
|
(ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp),
|
||||||
ctx);
|
ctx);
|
||||||
@@ -342,7 +343,7 @@ static void stableSort(COVER_ctx_t *ctx) {
|
|||||||
(ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp));
|
(ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp));
|
||||||
#else /* C90 fallback.*/
|
#else /* C90 fallback.*/
|
||||||
g_coverCtx = ctx;
|
g_coverCtx = ctx;
|
||||||
/* TODO(cavalcanti): implement a reentrant qsort() when is not available. */
|
/* TODO(cavalcanti): implement a reentrant qsort() when _r is not available. */
|
||||||
qsort(ctx->suffix, ctx->suffixSize, sizeof(U32),
|
qsort(ctx->suffix, ctx->suffixSize, sizeof(U32),
|
||||||
(ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp));
|
(ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp));
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user