Skip to content

Commit a1c5f41

Browse files
authored
thirdparty.zstd: upgrade to v1.5.7 release, add the local changes to a reusable .patch file (#24611)
1 parent b84512d commit a1c5f41

File tree

5 files changed

+311
-330
lines changed

5 files changed

+311
-330
lines changed

thirdparty/zstd/fix.md

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,9 @@
1-
1. replace all `abs64` with `zstd_abs64`.
1+
1. Get `zstd` from https://github.com/facebook/zstd/releases
2+
2. Download and extract `zstd`, and goto `zstd-1.5.7/build/single_file_libs/`, run `create_single_file_library.sh`
3+
3. Copy generated `zstd.c` to v's `thirdparty/zstd/zstd-1.5.7.c`
4+
4. In `thirdparty/zstd/`, apply patch by `patch -p0 -i zstd_v.patch -o zstd.c`
5+
5. Remove `zstd-1.5.7.c`
26

3-
2. add following at header of the file:
4-
#if defined(__TINYC__)
5-
#if defined(_WIN32)
6-
#undef ZSTD_MULTITHREAD
7-
#define ZSTD_NO_INTRINSICS
8-
#endif
9-
#if defined(__arm__) || defined(__aarch64__)
10-
#define NO_PREFETCH
11-
#endif
12-
#endif
13-
14-
3. replace `qsort_r` with `qsort`, as there is no way detect __MUSL__ macro. add following at header of the file:
15-
#ifndef ZDICT_QSORT
16-
# if defined(__APPLE__)
17-
# define ZDICT_QSORT ZDICT_QSORT_APPLE /* uses qsort_r() with a different order for parameters */
18-
# elif defined(__GLIBC__)
19-
# define ZDICT_QSORT ZDICT_QSORT_GNU /* uses qsort_r() */
20-
# elif defined(_WIN32) && defined(_MSC_VER)
21-
# define ZDICT_QSORT ZDICT_QSORT_MSVC /* uses qsort_s() with a different order for parameters */
22-
# elif defined(STDC_LIB_EXT1) && (STDC_LIB_EXT1 > 0) /* C11 Annex K */
23-
# define ZDICT_QSORT ZDICT_QSORT_C11 /* uses qsort_s() */
24-
# else
25-
# define ZDICT_QSORT ZDICT_QSORT_C90 /* uses standard qsort() which is not re-entrant (requires global variable) */
26-
# endif
27-
#endif
7+
You can generate a new patch by `diff -u zstd-1.5.7.c zstd_modified.c > zstd_custom.patch`
288

9+
BTW, patch is between `/* >> v_patch start */` and `/* << v_patch end */` mostly.

0 commit comments

Comments
 (0)