mirror of
https://github.com/vlang/v.git
synced 2025-09-10 16:00:31 -04:00
thirdparty: upgrade zstd to 1.5.8 (#24597)
This commit is contained in:
parent
52c7130a2f
commit
af8ecdaa26
28
thirdparty/zstd/fix.md
vendored
Normal file
28
thirdparty/zstd/fix.md
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
1. replace all `abs64` with `zstd_abs64`.
|
||||||
|
|
||||||
|
2. add following at header of the file:
|
||||||
|
#if defined(__TINYC__)
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#undef ZSTD_MULTITHREAD
|
||||||
|
#define ZSTD_NO_INTRINSICS
|
||||||
|
#endif
|
||||||
|
#if defined(__arm__) || defined(__aarch64__)
|
||||||
|
#define NO_PREFETCH
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
3. replace `qsort_r` with `qsort`, as there is no way detect __MUSL__ macro. add following at header of the file:
|
||||||
|
#ifndef ZDICT_QSORT
|
||||||
|
# if defined(__APPLE__)
|
||||||
|
# define ZDICT_QSORT ZDICT_QSORT_APPLE /* uses qsort_r() with a different order for parameters */
|
||||||
|
# elif defined(__GLIBC__)
|
||||||
|
# define ZDICT_QSORT ZDICT_QSORT_GNU /* uses qsort_r() */
|
||||||
|
# elif defined(_WIN32) && defined(_MSC_VER)
|
||||||
|
# define ZDICT_QSORT ZDICT_QSORT_MSVC /* uses qsort_s() with a different order for parameters */
|
||||||
|
# elif defined(STDC_LIB_EXT1) && (STDC_LIB_EXT1 > 0) /* C11 Annex K */
|
||||||
|
# define ZDICT_QSORT ZDICT_QSORT_C11 /* uses qsort_s() */
|
||||||
|
# else
|
||||||
|
# define ZDICT_QSORT ZDICT_QSORT_C90 /* uses standard qsort() which is not re-entrant (requires global variable) */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
7631
thirdparty/zstd/zstd.c
vendored
7631
thirdparty/zstd/zstd.c
vendored
File diff suppressed because it is too large
Load Diff
3090
thirdparty/zstd/zstd.h
vendored
3090
thirdparty/zstd/zstd.h
vendored
File diff suppressed because it is too large
Load Diff
@ -123,6 +123,18 @@ pub enum CParameter {
|
|||||||
// resulting in stronger and slower compression.
|
// resulting in stronger and slower compression.
|
||||||
// Special: value 0 means "use default strategy".
|
// Special: value 0 means "use default strategy".
|
||||||
strategy = 107
|
strategy = 107
|
||||||
|
// v1.5.6+
|
||||||
|
// Attempts to fit compressed block size into approximately targetCBlockSize.
|
||||||
|
// Bound by ZSTD_TARGETCBLOCKSIZE_MIN and ZSTD_TARGETCBLOCKSIZE_MAX.
|
||||||
|
// Note that it's not a guarantee, just a convergence target (default:0).
|
||||||
|
// No target when targetCBlockSize == 0.
|
||||||
|
// This is helpful in low bandwidth streaming environments to improve end-to-end latency,
|
||||||
|
// when a client can make use of partial documents (a prominent example being Chrome).
|
||||||
|
// Note: this parameter is stable since v1.5.6.
|
||||||
|
// It was present as an experimental parameter in earlier versions,
|
||||||
|
// but it's not recommended using it with earlier library versions
|
||||||
|
// due to massive performance regressions.
|
||||||
|
target_c_block_size = 130
|
||||||
// LDM mode parameters
|
// LDM mode parameters
|
||||||
// Enable long distance matching.
|
// Enable long distance matching.
|
||||||
// This parameter is designed to improve compression ratio
|
// This parameter is designed to improve compression ratio
|
||||||
@ -226,12 +238,12 @@ pub enum CParameter {
|
|||||||
// note : never ever use experimentalParam? names directly;
|
// note : never ever use experimentalParam? names directly;
|
||||||
// also, the enums values themselves are unstable and can still change.
|
// also, the enums values themselves are unstable and can still change.
|
||||||
//
|
//
|
||||||
experimental_param1 = 500
|
experimental_param1 = 500
|
||||||
experimental_param2 = 10
|
experimental_param2 = 10
|
||||||
experimental_param3 = 1000
|
experimental_param3 = 1000
|
||||||
experimental_param4 = 1001
|
experimental_param4 = 1001
|
||||||
experimental_param5 = 1002
|
experimental_param5 = 1002
|
||||||
experimental_param6 = 1003
|
// experimental_param6 = 1003 is now ZSTD_c_targetCBlockSize
|
||||||
experimental_param7 = 1004
|
experimental_param7 = 1004
|
||||||
experimental_param8 = 1005
|
experimental_param8 = 1005
|
||||||
experimental_param9 = 1006
|
experimental_param9 = 1006
|
||||||
@ -245,6 +257,7 @@ pub enum CParameter {
|
|||||||
experimental_param17 = 1014
|
experimental_param17 = 1014
|
||||||
experimental_param18 = 1015
|
experimental_param18 = 1015
|
||||||
experimental_param19 = 1016
|
experimental_param19 = 1016
|
||||||
|
experimental_param20 = 1017
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Bounds {
|
pub struct Bounds {
|
||||||
@ -290,6 +303,7 @@ pub enum DParameter {
|
|||||||
experimental_param3 = 1002
|
experimental_param3 = 1002
|
||||||
experimental_param4 = 1003
|
experimental_param4 = 1003
|
||||||
experimental_param5 = 1004
|
experimental_param5 = 1004
|
||||||
|
experimental_param6 = 1005
|
||||||
}
|
}
|
||||||
|
|
||||||
fn C.ZSTD_dParam_getBounds(DParameter) Bounds
|
fn C.ZSTD_dParam_getBounds(DParameter) Bounds
|
||||||
@ -346,12 +360,12 @@ fn C.ZSTD_decompressStream(voidptr, &OutBuffer, &InBuffer) usize
|
|||||||
fn C.ZSTD_DStreamInSize() usize
|
fn C.ZSTD_DStreamInSize() usize
|
||||||
fn C.ZSTD_DStreamOutSize() usize
|
fn C.ZSTD_DStreamOutSize() usize
|
||||||
|
|
||||||
// version_number return runtime library version, the value is (MAJOR*100*100 + MINOR*100 + RELEASE).
|
// version_number returns runtime library version, the value is (MAJOR*100*100 + MINOR*100 + RELEASE).
|
||||||
pub fn version_number() u32 {
|
pub fn version_number() u32 {
|
||||||
return C.ZSTD_versionNumber()
|
return C.ZSTD_versionNumber()
|
||||||
}
|
}
|
||||||
|
|
||||||
// version_string return runtime library version, like "1.5.5".
|
// version_string returns runtime library version, like "1.5.8".
|
||||||
pub fn version_string() string {
|
pub fn version_string() string {
|
||||||
return unsafe { tos_clone(C.ZSTD_versionString()) }
|
return unsafe { tos_clone(C.ZSTD_versionString()) }
|
||||||
}
|
}
|
||||||
@ -363,27 +377,27 @@ pub fn is_error(code usize) bool {
|
|||||||
|
|
||||||
// get_error_name provides readable string from an error code.
|
// get_error_name provides readable string from an error code.
|
||||||
pub fn get_error_name(code usize) string {
|
pub fn get_error_name(code usize) string {
|
||||||
return unsafe { tos_clone(C.ZSTD_getErrorName(code)) }
|
return unsafe { tos_clone(&u8(C.ZSTD_getErrorName(code))) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// check_zstd check the zstd error code, and return a error string.
|
// check_zstd checks the zstd error code, and return a error string.
|
||||||
pub fn check_error(code usize) ! {
|
pub fn check_error(code usize) ! {
|
||||||
if is_error(code) {
|
if is_error(code) {
|
||||||
return error(get_error_name(code))
|
return error(get_error_name(code))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// min_c_level return minimum negative compression level allowed.
|
// min_c_level returns minimum negative compression level allowed.
|
||||||
pub fn min_c_level() int {
|
pub fn min_c_level() int {
|
||||||
return C.ZSTD_minCLevel()
|
return C.ZSTD_minCLevel()
|
||||||
}
|
}
|
||||||
|
|
||||||
// max_c_level return maximum compression level available.
|
// max_c_level returns maximum compression level available.
|
||||||
pub fn max_c_level() int {
|
pub fn max_c_level() int {
|
||||||
return C.ZSTD_maxCLevel()
|
return C.ZSTD_maxCLevel()
|
||||||
}
|
}
|
||||||
|
|
||||||
// default_c_level return default compression level.
|
// default_c_level returns default compression level.
|
||||||
pub fn default_c_level() int {
|
pub fn default_c_level() int {
|
||||||
return C.ZSTD_defaultCLevel()
|
return C.ZSTD_defaultCLevel()
|
||||||
}
|
}
|
||||||
@ -492,7 +506,7 @@ mut:
|
|||||||
ctx &C.ZSTD_DCtx
|
ctx &C.ZSTD_DCtx
|
||||||
}
|
}
|
||||||
|
|
||||||
// new_dctx create a decompression context
|
// new_dctx creates a decompression context
|
||||||
// extra decompression parameters can be set by `params`
|
// extra decompression parameters can be set by `params`
|
||||||
pub fn new_dctx(params DecompressParams) !&DCtx {
|
pub fn new_dctx(params DecompressParams) !&DCtx {
|
||||||
mut ctx := C.ZSTD_createDCtx()
|
mut ctx := C.ZSTD_createDCtx()
|
||||||
@ -504,7 +518,7 @@ pub fn new_dctx(params DecompressParams) !&DCtx {
|
|||||||
return dctx
|
return dctx
|
||||||
}
|
}
|
||||||
|
|
||||||
// set_parameter set decompression parameter `d_param` to value `val`
|
// set_parameter sets decompression parameter `d_param` to value `val`
|
||||||
pub fn (mut d DCtx) set(d_param DParameter, val int) ! {
|
pub fn (mut d DCtx) set(d_param DParameter, val int) ! {
|
||||||
check_error(C.ZSTD_DCtx_setParameter(d.ctx, d_param, val))!
|
check_error(C.ZSTD_DCtx_setParameter(d.ctx, d_param, val))!
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user