Skip to content

Commit aaf1f12

Browse files
committed
Update Zstandard to Version 1.5.5
Signed-off-by: Tino Reichardt <[email protected]>
1 parent e615c8c commit aaf1f12

31 files changed

+942
-627
lines changed

C/7zVersion.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#define MY_VER_MAJOR 22
22
#define MY_VER_MINOR 01
3-
#define MY_VER_BUILD 04
4-
#define MY_VERSION_NUMBERS "22.01 ZS v1.5.4 R4"
3+
#define MY_VER_BUILD 05
4+
#define MY_VERSION_NUMBERS "22.01 ZS v1.5.5 R1"
55
#define MY_VERSION MY_VERSION_NUMBERS
66

77
#ifdef MY_CPU_NAME
@@ -10,7 +10,7 @@
1010
#define MY_VERSION_CPU MY_VERSION
1111
#endif
1212

13-
#define MY_DATE "2023-02-27"
13+
#define MY_DATE "2023-04-05"
1414
#undef MY_COPYRIGHT
1515
#undef MY_VERSION_COPYRIGHT_DATE
1616
#define MY_AUTHOR_NAME "Igor Pavlov, Tino Reichardt"

C/zstd/LICENSE

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ BSD License
22

33
For Zstandard software
44

5-
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
5+
Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
66

77
Redistribution and use in source and binary forms, with or without modification,
88
are permitted provided that the following conditions are met:
@@ -14,9 +14,9 @@ are permitted provided that the following conditions are met:
1414
this list of conditions and the following disclaimer in the documentation
1515
and/or other materials provided with the distribution.
1616

17-
* Neither the name Facebook nor the names of its contributors may be used to
18-
endorse or promote products derived from this software without specific
19-
prior written permission.
17+
* Neither the name Facebook, nor Meta, nor the names of its contributors may
18+
be used to endorse or promote products derived from this software without
19+
specific prior written permission.
2020

2121
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
2222
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED

C/zstd/README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ The file structure is designed to make this selection manually achievable for an
9191
`ZSTD_LIB_COMPRESSION, ZSTD_LIB_DECOMPRESSION`, `ZSTD_LIB_DICTBUILDER`,
9292
and `ZSTD_LIB_DEPRECATED` as `0` to forgo compilation of the
9393
corresponding features. This will also disable compilation of all
94-
dependencies (eg. `ZSTD_LIB_COMPRESSION=0` will also disable
94+
dependencies (e.g. `ZSTD_LIB_COMPRESSION=0` will also disable
9595
dictBuilder).
9696

9797
- There are a number of options that can help minimize the binary size of
@@ -125,7 +125,7 @@ The file structure is designed to make this selection manually achievable for an
125125
`ZSTD_getErrorName` (implied by `ZSTD_LIB_MINIFY`).
126126

127127
Finally, when integrating into your application, make sure you're doing link-
128-
time optimation and unused symbol garbage collection (via some combination of,
128+
time optimization and unused symbol garbage collection (via some combination of,
129129
e.g., `-flto`, `-ffat-lto-objects`, `-fuse-linker-plugin`,
130130
`-ffunction-sections`, `-fdata-sections`, `-fmerge-all-constants`,
131131
`-Wl,--gc-sections`, `-Wl,-z,norelro`, and an archiver that understands
@@ -155,6 +155,19 @@ The file structure is designed to make this selection manually achievable for an
155155
- The build macro `ZSTD_NO_INTRINSICS` can be defined to disable all explicit intrinsics.
156156
Compiler builtins are still used.
157157

158+
- The build macro `ZSTD_DECODER_INTERNAL_BUFFER` can be set to control
159+
the amount of extra memory used during decompression to store literals.
160+
This defaults to 64kB. Reducing this value reduces the memory footprint of
161+
`ZSTD_DCtx` decompression contexts,
162+
but might also result in a small decompression speed cost.
163+
164+
- The C compiler macros `ZSTDLIB_VISIBLE`, `ZSTDERRORLIB_VISIBLE` and `ZDICTLIB_VISIBLE`
165+
can be overridden to control the visibility of zstd's API. Additionally,
166+
`ZSTDLIB_STATIC_API` and `ZDICTLIB_STATIC_API` can be overridden to control the visibility
167+
of zstd's static API. Specifically, it can be set to `ZSTDLIB_HIDDEN` to hide the symbols
168+
from the shared library. These macros default to `ZSTDLIB_VISIBILITY`,
169+
`ZSTDERRORLIB_VSIBILITY`, and `ZDICTLIB_VISIBILITY` if unset, for backwards compatibility
170+
with the old macro names.
158171

159172
#### Windows : using MinGW+MSYS to create DLL
160173

C/zstd/allocations.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under both the BSD-style license (found in the
6+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
7+
* in the COPYING file in the root directory of this source tree).
8+
* You may select, at your option, one of the above-listed licenses.
9+
*/
10+
11+
/* This file provides custom allocation primitives
12+
*/
13+
14+
#define ZSTD_DEPS_NEED_MALLOC
15+
#include "zstd_deps.h" /* ZSTD_malloc, ZSTD_calloc, ZSTD_free, ZSTD_memset */
16+
17+
#include "mem.h" /* MEM_STATIC */
18+
#define ZSTD_STATIC_LINKING_ONLY
19+
#include "zstd.h" /* ZSTD_customMem */
20+
21+
#ifndef ZSTD_ALLOCATIONS_H
22+
#define ZSTD_ALLOCATIONS_H
23+
24+
/* custom memory allocation functions */
25+
26+
MEM_STATIC void* ZSTD_customMalloc(size_t size, ZSTD_customMem customMem)
27+
{
28+
if (customMem.customAlloc)
29+
return customMem.customAlloc(customMem.opaque, size);
30+
return ZSTD_malloc(size);
31+
}
32+
33+
MEM_STATIC void* ZSTD_customCalloc(size_t size, ZSTD_customMem customMem)
34+
{
35+
if (customMem.customAlloc) {
36+
/* calloc implemented as malloc+memset;
37+
* not as efficient as calloc, but next best guess for custom malloc */
38+
void* const ptr = customMem.customAlloc(customMem.opaque, size);
39+
ZSTD_memset(ptr, 0, size);
40+
return ptr;
41+
}
42+
return ZSTD_calloc(1, size);
43+
}
44+
45+
MEM_STATIC void ZSTD_customFree(void* ptr, ZSTD_customMem customMem)
46+
{
47+
if (ptr!=NULL) {
48+
if (customMem.customFree)
49+
customMem.customFree(customMem.opaque, ptr);
50+
else
51+
ZSTD_free(ptr);
52+
}
53+
}
54+
55+
#endif /* ZSTD_ALLOCATIONS_H */

C/zstd/bits.h

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ MEM_STATIC unsigned ZSTD_countTrailingZeros32_fallback(U32 val)
1717
{
1818
assert(val != 0);
1919
{
20-
static const int DeBruijnBytePos[32] = {0, 1, 28, 2, 29, 14, 24, 3,
20+
static const U32 DeBruijnBytePos[32] = {0, 1, 28, 2, 29, 14, 24, 3,
2121
30, 22, 20, 15, 25, 17, 4, 8,
2222
31, 27, 13, 23, 21, 19, 16, 7,
2323
26, 12, 18, 6, 11, 5, 10, 9};
@@ -30,7 +30,7 @@ MEM_STATIC unsigned ZSTD_countTrailingZeros32(U32 val)
3030
assert(val != 0);
3131
# if defined(_MSC_VER)
3232
# if STATIC_BMI2 == 1
33-
return _tzcnt_u32(val);
33+
return (unsigned)_tzcnt_u32(val);
3434
# else
3535
if (val != 0) {
3636
unsigned long r;
@@ -69,7 +69,7 @@ MEM_STATIC unsigned ZSTD_countLeadingZeros32(U32 val)
6969
assert(val != 0);
7070
# if defined(_MSC_VER)
7171
# if STATIC_BMI2 == 1
72-
return _lzcnt_u32(val);
72+
return (unsigned)_lzcnt_u32(val);
7373
# else
7474
if (val != 0) {
7575
unsigned long r;
@@ -92,7 +92,7 @@ MEM_STATIC unsigned ZSTD_countTrailingZeros64(U64 val)
9292
assert(val != 0);
9393
# if defined(_MSC_VER) && defined(_WIN64)
9494
# if STATIC_BMI2 == 1
95-
return _tzcnt_u64(val);
95+
return (unsigned)_tzcnt_u64(val);
9696
# else
9797
if (val != 0) {
9898
unsigned long r;
@@ -123,7 +123,7 @@ MEM_STATIC unsigned ZSTD_countLeadingZeros64(U64 val)
123123
assert(val != 0);
124124
# if defined(_MSC_VER) && defined(_WIN64)
125125
# if STATIC_BMI2 == 1
126-
return _lzcnt_u64(val);
126+
return (unsigned)_lzcnt_u64(val);
127127
# else
128128
if (val != 0) {
129129
unsigned long r;
@@ -172,4 +172,29 @@ MEM_STATIC unsigned ZSTD_highbit32(U32 val) /* compress, dictBuilder, decodeCo
172172
return 31 - ZSTD_countLeadingZeros32(val);
173173
}
174174

175+
/* ZSTD_rotateRight_*():
176+
* Rotates a bitfield to the right by "count" bits.
177+
* https://en.wikipedia.org/w/index.php?title=Circular_shift&oldid=991635599#Implementing_circular_shifts
178+
*/
179+
MEM_STATIC
180+
U64 ZSTD_rotateRight_U64(U64 const value, U32 count) {
181+
assert(count < 64);
182+
count &= 0x3F; /* for fickle pattern recognition */
183+
return (value >> count) | (U64)(value << ((0U - count) & 0x3F));
184+
}
185+
186+
MEM_STATIC
187+
U32 ZSTD_rotateRight_U32(U32 const value, U32 count) {
188+
assert(count < 32);
189+
count &= 0x1F; /* for fickle pattern recognition */
190+
return (value >> count) | (U32)(value << ((0U - count) & 0x1F));
191+
}
192+
193+
MEM_STATIC
194+
U16 ZSTD_rotateRight_U16(U16 const value, U32 count) {
195+
assert(count < 16);
196+
count &= 0x0F; /* for fickle pattern recognition */
197+
return (value >> count) | (U16)(value << ((0U - count) & 0x0F));
198+
}
199+
175200
#endif /* ZSTD_BITS_H */

C/zstd/bitstream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ MEM_STATIC BIT_DStream_status BIT_reloadDStreamFast(BIT_DStream_t* bitD)
396396
* This function is safe, it guarantees it will not read beyond src buffer.
397397
* @return : status of `BIT_DStream_t` internal register.
398398
* when status == BIT_DStream_unfinished, internal register is filled with at least 25 or 57 bits */
399-
MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD)
399+
MEM_STATIC FORCE_INLINE_ATTR BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD)
400400
{
401401
if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* overflow detected, like end of stream */
402402
return BIT_DStream_overflow;

C/zstd/compiler.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ void __msan_poison(const volatile void *a, size_t size);
311311
/* Returns the offset of the first (at least partially) poisoned byte in the
312312
memory range, or -1 if the whole range is good. */
313313
intptr_t __msan_test_shadow(const volatile void *x, size_t size);
314+
315+
/* Print shadow and origin for the memory range to stderr in a human-readable
316+
format. */
317+
void __msan_print_shadow(const volatile void *x, size_t size);
314318
#endif
315319

316320
#if ZSTD_ADDRESS_SANITIZER && !defined(ZSTD_ASAN_DONT_POISON_WORKSPACE)

C/zstd/huf_decompress.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ void HUF_decompress4X1_usingDTable_internal_fast_c_loop(HUF_DecompressFastArgs*
696696

697697
/* Copy the arguments to local variables */
698698
ZSTD_memcpy(&bits, &args->bits, sizeof(bits));
699-
ZSTD_memcpy(&ip, &args->ip, sizeof(ip));
699+
ZSTD_memcpy((void*)(&ip), &args->ip, sizeof(ip));
700700
ZSTD_memcpy(&op, &args->op, sizeof(op));
701701

702702
assert(MEM_isLittleEndian());
@@ -779,7 +779,7 @@ void HUF_decompress4X1_usingDTable_internal_fast_c_loop(HUF_DecompressFastArgs*
779779

780780
/* Save the final values of each of the state variables back to args. */
781781
ZSTD_memcpy(&args->bits, &bits, sizeof(bits));
782-
ZSTD_memcpy(&args->ip, &ip, sizeof(ip));
782+
ZSTD_memcpy((void*)(&args->ip), &ip, sizeof(ip));
783783
ZSTD_memcpy(&args->op, &op, sizeof(op));
784784
}
785785

@@ -1476,7 +1476,7 @@ void HUF_decompress4X2_usingDTable_internal_fast_c_loop(HUF_DecompressFastArgs*
14761476

14771477
/* Copy the arguments to local registers. */
14781478
ZSTD_memcpy(&bits, &args->bits, sizeof(bits));
1479-
ZSTD_memcpy(&ip, &args->ip, sizeof(ip));
1479+
ZSTD_memcpy((void*)(&ip), &args->ip, sizeof(ip));
14801480
ZSTD_memcpy(&op, &args->op, sizeof(op));
14811481

14821482
oend[0] = op[1];
@@ -1599,7 +1599,7 @@ void HUF_decompress4X2_usingDTable_internal_fast_c_loop(HUF_DecompressFastArgs*
15991599

16001600
/* Save the final values of each of the state variables back to args. */
16011601
ZSTD_memcpy(&args->bits, &bits, sizeof(bits));
1602-
ZSTD_memcpy(&args->ip, &ip, sizeof(ip));
1602+
ZSTD_memcpy((void*)(&args->ip), &ip, sizeof(ip));
16031603
ZSTD_memcpy(&args->op, &op, sizeof(op));
16041604
}
16051605

C/zstd/pool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111

1212
/* ====== Dependencies ======= */
13+
#include "allocations.h" /* ZSTD_customCalloc, ZSTD_customFree */
1314
#include "zstd_deps.h" /* size_t */
1415
#include "debug.h" /* assert */
15-
#include "zstd_internal.h" /* ZSTD_customCalloc, ZSTD_customFree */
1616
#include "pool.h"
1717

1818
/* ====== Compiler specifics ====== */

C/zstd/threading.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static unsigned __stdcall worker(void *arg)
4747
void* (*start_routine)(void*);
4848
void* thread_arg;
4949

50-
/* Inialized thread_arg and start_routine and signal main thread that we don't need it
50+
/* Initialized thread_arg and start_routine and signal main thread that we don't need it
5151
* to wait any longer.
5252
*/
5353
{

0 commit comments

Comments
 (0)