Skip to content

Commit 8d091ad

Browse files
committed
zstd: upgrade vendored zstd to 1.5.4
Files are based on upstream commit 945f27758c0fd67b636103a38dbf050266c6b90a / tag v1.5.4. The unified library has been regenerated and headers and license files have been synchronized. The autogenerated unified library source file was renamed from `zstdlib.c` to `zstd.c`. The name doesn't really matter, but we preserve the upstream default. This temporarily breaks the build. The command I used to produce the unified library was `python3 combine.py -r ../../lib -o zstd.c zstd-in.c`. This is slightly different than what the README recommends, as I'm including legacy support and inlining zstd.h.
1 parent 42e25d0 commit 8d091ad

File tree

5 files changed

+5099
-3125
lines changed

5 files changed

+5099
-3125
lines changed

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

zstd/zdict.h

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) Yann Collet, Facebook, Inc.
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
33
* All rights reserved.
44
*
55
* This source code is licensed under both the BSD-style license (found in the
@@ -8,32 +8,43 @@
88
* You may select, at your option, one of the above-listed licenses.
99
*/
1010

11-
#ifndef DICTBUILDER_H_001
12-
#define DICTBUILDER_H_001
13-
1411
#if defined (__cplusplus)
1512
extern "C" {
1613
#endif
1714

15+
#ifndef ZSTD_ZDICT_H
16+
#define ZSTD_ZDICT_H
1817

1918
/*====== Dependencies ======*/
2019
#include <stddef.h> /* size_t */
2120

2221

2322
/* ===== ZDICTLIB_API : control library symbols visibility ===== */
24-
#ifndef ZDICTLIB_VISIBILITY
25-
# if defined(__GNUC__) && (__GNUC__ >= 4)
26-
# define ZDICTLIB_VISIBILITY __attribute__ ((visibility ("default")))
23+
#ifndef ZDICTLIB_VISIBLE
24+
/* Backwards compatibility with old macro name */
25+
# ifdef ZDICTLIB_VISIBILITY
26+
# define ZDICTLIB_VISIBLE ZDICTLIB_VISIBILITY
27+
# elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
28+
# define ZDICTLIB_VISIBLE __attribute__ ((visibility ("default")))
29+
# else
30+
# define ZDICTLIB_VISIBLE
31+
# endif
32+
#endif
33+
34+
#ifndef ZDICTLIB_HIDDEN
35+
# if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
36+
# define ZDICTLIB_HIDDEN __attribute__ ((visibility ("hidden")))
2737
# else
28-
# define ZDICTLIB_VISIBILITY
38+
# define ZDICTLIB_HIDDEN
2939
# endif
3040
#endif
41+
3142
#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
32-
# define ZDICTLIB_API __declspec(dllexport) ZDICTLIB_VISIBILITY
43+
# define ZDICTLIB_API __declspec(dllexport) ZDICTLIB_VISIBLE
3344
#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
34-
# define ZDICTLIB_API __declspec(dllimport) ZDICTLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
45+
# define ZDICTLIB_API __declspec(dllimport) ZDICTLIB_VISIBLE /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
3546
#else
36-
# define ZDICTLIB_API ZDICTLIB_VISIBILITY
47+
# define ZDICTLIB_API ZDICTLIB_VISIBLE
3748
#endif
3849

3950
/*******************************************************************************
@@ -110,8 +121,8 @@ extern "C" {
110121
* The zstd CLI defaults to a 110KB dictionary. You likely don't need a
111122
* dictionary larger than that. But, most use cases can get away with a
112123
* smaller dictionary. The advanced dictionary builders can automatically
113-
* shrink the dictionary for you, and select a the smallest size that
114-
* doesn't hurt compression ratio too much. See the `shrinkDict` parameter.
124+
* shrink the dictionary for you, and select the smallest size that doesn't
125+
* hurt compression ratio too much. See the `shrinkDict` parameter.
115126
* A smaller dictionary can save memory, and potentially speed up
116127
* compression.
117128
*
@@ -201,9 +212,9 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer(void* dictBuffer, size_t dictBufferCap
201212
const size_t* samplesSizes, unsigned nbSamples);
202213

203214
typedef struct {
204-
int compressionLevel; /*< optimize for a specific zstd compression level; 0 means default */
205-
unsigned notificationLevel; /*< Write log to stderr; 0 = none (default); 1 = errors; 2 = progression; 3 = details; 4 = debug; */
206-
unsigned dictID; /*< force dictID value; 0 means auto mode (32-bits random value)
215+
int compressionLevel; /**< optimize for a specific zstd compression level; 0 means default */
216+
unsigned notificationLevel; /**< Write log to stderr; 0 = none (default); 1 = errors; 2 = progression; 3 = details; 4 = debug; */
217+
unsigned dictID; /**< force dictID value; 0 means auto mode (32-bits random value)
207218
* NOTE: The zstd format reserves some dictionary IDs for future use.
208219
* You may use them in private settings, but be warned that they
209220
* may be used by zstd in a public dictionary registry in the future.
@@ -260,9 +271,21 @@ ZDICTLIB_API size_t ZDICT_getDictHeaderSize(const void* dictBuffer, size_t dictS
260271
ZDICTLIB_API unsigned ZDICT_isError(size_t errorCode);
261272
ZDICTLIB_API const char* ZDICT_getErrorName(size_t errorCode);
262273

274+
#endif /* ZSTD_ZDICT_H */
263275

276+
#if defined(ZDICT_STATIC_LINKING_ONLY) && !defined(ZSTD_ZDICT_H_STATIC)
277+
#define ZSTD_ZDICT_H_STATIC
264278

265-
#ifdef ZDICT_STATIC_LINKING_ONLY
279+
/* This can be overridden externally to hide static symbols. */
280+
#ifndef ZDICTLIB_STATIC_API
281+
# if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
282+
# define ZDICTLIB_STATIC_API __declspec(dllexport) ZDICTLIB_VISIBLE
283+
# elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
284+
# define ZDICTLIB_STATIC_API __declspec(dllimport) ZDICTLIB_VISIBLE
285+
# else
286+
# define ZDICTLIB_STATIC_API ZDICTLIB_VISIBLE
287+
# endif
288+
#endif
266289

267290
/* ====================================================================================
268291
* The definitions in this section are considered experimental.
@@ -318,7 +341,7 @@ typedef struct {
318341
* In general, it's recommended to provide a few thousands samples, though this can vary a lot.
319342
* It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
320343
*/
321-
ZDICTLIB_API size_t ZDICT_trainFromBuffer_cover(
344+
ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_cover(
322345
void *dictBuffer, size_t dictBufferCapacity,
323346
const void *samplesBuffer, const size_t *samplesSizes, unsigned nbSamples,
324347
ZDICT_cover_params_t parameters);
@@ -340,7 +363,7 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer_cover(
340363
* See ZDICT_trainFromBuffer() for details on failure modes.
341364
* Note: ZDICT_optimizeTrainFromBuffer_cover() requires about 8 bytes of memory for each input byte and additionally another 5 bytes of memory for each byte of memory for each thread.
342365
*/
343-
ZDICTLIB_API size_t ZDICT_optimizeTrainFromBuffer_cover(
366+
ZDICTLIB_STATIC_API size_t ZDICT_optimizeTrainFromBuffer_cover(
344367
void* dictBuffer, size_t dictBufferCapacity,
345368
const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
346369
ZDICT_cover_params_t* parameters);
@@ -361,7 +384,7 @@ ZDICTLIB_API size_t ZDICT_optimizeTrainFromBuffer_cover(
361384
* In general, it's recommended to provide a few thousands samples, though this can vary a lot.
362385
* It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
363386
*/
364-
ZDICTLIB_API size_t ZDICT_trainFromBuffer_fastCover(void *dictBuffer,
387+
ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_fastCover(void *dictBuffer,
365388
size_t dictBufferCapacity, const void *samplesBuffer,
366389
const size_t *samplesSizes, unsigned nbSamples,
367390
ZDICT_fastCover_params_t parameters);
@@ -384,7 +407,7 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer_fastCover(void *dictBuffer,
384407
* See ZDICT_trainFromBuffer() for details on failure modes.
385408
* Note: ZDICT_optimizeTrainFromBuffer_fastCover() requires about 6 * 2^f bytes of memory for each thread.
386409
*/
387-
ZDICTLIB_API size_t ZDICT_optimizeTrainFromBuffer_fastCover(void* dictBuffer,
410+
ZDICTLIB_STATIC_API size_t ZDICT_optimizeTrainFromBuffer_fastCover(void* dictBuffer,
388411
size_t dictBufferCapacity, const void* samplesBuffer,
389412
const size_t* samplesSizes, unsigned nbSamples,
390413
ZDICT_fastCover_params_t* parameters);
@@ -409,7 +432,7 @@ typedef struct {
409432
* It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
410433
* Note: ZDICT_trainFromBuffer_legacy() will send notifications into stderr if instructed to, using notificationLevel>0.
411434
*/
412-
ZDICTLIB_API size_t ZDICT_trainFromBuffer_legacy(
435+
ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_legacy(
413436
void* dictBuffer, size_t dictBufferCapacity,
414437
const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
415438
ZDICT_legacy_params_t parameters);
@@ -421,32 +444,31 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer_legacy(
421444
or _CRT_SECURE_NO_WARNINGS in Visual.
422445
Otherwise, it's also possible to manually define ZDICT_DISABLE_DEPRECATE_WARNINGS */
423446
#ifdef ZDICT_DISABLE_DEPRECATE_WARNINGS
424-
# define ZDICT_DEPRECATED(message) ZDICTLIB_API /* disable deprecation warnings */
447+
# define ZDICT_DEPRECATED(message) /* disable deprecation warnings */
425448
#else
426449
# define ZDICT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
427450
# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
428-
# define ZDICT_DEPRECATED(message) [[deprecated(message)]] ZDICTLIB_API
451+
# define ZDICT_DEPRECATED(message) [[deprecated(message)]]
429452
# elif defined(__clang__) || (ZDICT_GCC_VERSION >= 405)
430-
# define ZDICT_DEPRECATED(message) ZDICTLIB_API __attribute__((deprecated(message)))
453+
# define ZDICT_DEPRECATED(message) __attribute__((deprecated(message)))
431454
# elif (ZDICT_GCC_VERSION >= 301)
432-
# define ZDICT_DEPRECATED(message) ZDICTLIB_API __attribute__((deprecated))
455+
# define ZDICT_DEPRECATED(message) __attribute__((deprecated))
433456
# elif defined(_MSC_VER)
434-
# define ZDICT_DEPRECATED(message) ZDICTLIB_API __declspec(deprecated(message))
457+
# define ZDICT_DEPRECATED(message) __declspec(deprecated(message))
435458
# else
436459
# pragma message("WARNING: You need to implement ZDICT_DEPRECATED for this compiler")
437-
# define ZDICT_DEPRECATED(message) ZDICTLIB_API
460+
# define ZDICT_DEPRECATED(message)
438461
# endif
439462
#endif /* ZDICT_DISABLE_DEPRECATE_WARNINGS */
440463

441464
ZDICT_DEPRECATED("use ZDICT_finalizeDictionary() instead")
465+
ZDICTLIB_STATIC_API
442466
size_t ZDICT_addEntropyTablesFromBuffer(void* dictBuffer, size_t dictContentSize, size_t dictBufferCapacity,
443467
const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples);
444468

445469

446-
#endif /* ZDICT_STATIC_LINKING_ONLY */
470+
#endif /* ZSTD_ZDICT_H_STATIC */
447471

448472
#if defined (__cplusplus)
449473
}
450474
#endif
451-
452-
#endif /* DICTBUILDER_H_001 */

0 commit comments

Comments
 (0)