comparison contrib/python-zstandard/zstd/common/zstd_internal.h @ 40121:73fef626dae3

zstandard: vendor python-zstandard 0.10.1 This was just released. The upstream source distribution from PyPI was extracted. Unwanted files were removed. The clang-format ignore list was updated to reflect the new source of files. setup.py was updated to pass a new argument to python-zstandard's function for returning an Extension instance. Upstream had to change to use relative paths because Python 3.7's packaging doesn't seem to like absolute paths when defining sources, includes, etc. The default relative path calculation is relative to setup_zstd.py which is different from the directory of Mercurial's setup.py. The project contains a vendored copy of zstandard 1.3.6. The old version was 1.3.4. The API should be backwards compatible and nothing in core should need adjusted. However, there is a new "chunker" API that we may find useful in places where we want to emit compressed chunks of a fixed size. There are a pair of bug fixes in 0.10.0 with regards to compressobj() and decompressobj() when block flushing is used. I actually found these bugs when introducing these APIs in Mercurial! But existing Mercurial code is not affected because we don't perform block flushing. # no-check-commit because 3rd party code has different style guidelines Differential Revision: https://phab.mercurial-scm.org/D4911
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 08 Oct 2018 16:27:40 -0700
parents b1fb341d8a61
children 675775c33ab6
comparison
equal deleted inserted replaced
40120:89742f1fa6cb 40121:73fef626dae3
19 /*-************************************* 19 /*-*************************************
20 * Dependencies 20 * Dependencies
21 ***************************************/ 21 ***************************************/
22 #include "compiler.h" 22 #include "compiler.h"
23 #include "mem.h" 23 #include "mem.h"
24 #include "debug.h" /* assert, DEBUGLOG, RAWLOG, g_debuglevel */
24 #include "error_private.h" 25 #include "error_private.h"
25 #define ZSTD_STATIC_LINKING_ONLY 26 #define ZSTD_STATIC_LINKING_ONLY
26 #include "zstd.h" 27 #include "zstd.h"
27 #define FSE_STATIC_LINKING_ONLY 28 #define FSE_STATIC_LINKING_ONLY
28 #include "fse.h" 29 #include "fse.h"
36 37
37 #if defined (__cplusplus) 38 #if defined (__cplusplus)
38 extern "C" { 39 extern "C" {
39 #endif 40 #endif
40 41
41 42 /* ---- static assert (debug) --- */
42 /*-************************************* 43 #define ZSTD_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c)
43 * Debug
44 ***************************************/
45 #if defined(ZSTD_DEBUG) && (ZSTD_DEBUG>=1)
46 # include <assert.h>
47 #else
48 # ifndef assert
49 # define assert(condition) ((void)0)
50 # endif
51 #endif
52
53 #define ZSTD_STATIC_ASSERT(c) { enum { ZSTD_static_assert = 1/(int)(!!(c)) }; }
54
55 #if defined(ZSTD_DEBUG) && (ZSTD_DEBUG>=2)
56 # include <stdio.h>
57 extern int g_debuglog_enable;
58 /* recommended values for ZSTD_DEBUG display levels :
59 * 1 : no display, enables assert() only
60 * 2 : reserved for currently active debug path
61 * 3 : events once per object lifetime (CCtx, CDict, etc.)
62 * 4 : events once per frame
63 * 5 : events once per block
64 * 6 : events once per sequence (*very* verbose) */
65 # define RAWLOG(l, ...) { \
66 if ((g_debuglog_enable) & (l<=ZSTD_DEBUG)) { \
67 fprintf(stderr, __VA_ARGS__); \
68 } }
69 # define DEBUGLOG(l, ...) { \
70 if ((g_debuglog_enable) & (l<=ZSTD_DEBUG)) { \
71 fprintf(stderr, __FILE__ ": " __VA_ARGS__); \
72 fprintf(stderr, " \n"); \
73 } }
74 #else
75 # define RAWLOG(l, ...) {} /* disabled */
76 # define DEBUGLOG(l, ...) {} /* disabled */
77 #endif
78 44
79 45
80 /*-************************************* 46 /*-*************************************
81 * shared macros 47 * shared macros
82 ***************************************/ 48 ***************************************/
111 #define ZSTD_WINDOWLOG_ABSOLUTEMIN 10 77 #define ZSTD_WINDOWLOG_ABSOLUTEMIN 10
112 #define ZSTD_WINDOWLOG_DEFAULTMAX 27 /* Default maximum allowed window log */ 78 #define ZSTD_WINDOWLOG_DEFAULTMAX 27 /* Default maximum allowed window log */
113 static const size_t ZSTD_fcs_fieldSize[4] = { 0, 2, 4, 8 }; 79 static const size_t ZSTD_fcs_fieldSize[4] = { 0, 2, 4, 8 };
114 static const size_t ZSTD_did_fieldSize[4] = { 0, 1, 2, 4 }; 80 static const size_t ZSTD_did_fieldSize[4] = { 0, 1, 2, 4 };
115 81
116 #define ZSTD_FRAMEIDSIZE 4 82 #define ZSTD_FRAMEIDSIZE 4 /* magic number size */
117 static const size_t ZSTD_frameIdSize = ZSTD_FRAMEIDSIZE; /* magic number size */
118 83
119 #define ZSTD_BLOCKHEADERSIZE 3 /* C standard doesn't allow `static const` variable to be init using another `static const` variable */ 84 #define ZSTD_BLOCKHEADERSIZE 3 /* C standard doesn't allow `static const` variable to be init using another `static const` variable */
120 static const size_t ZSTD_blockHeaderSize = ZSTD_BLOCKHEADERSIZE; 85 static const size_t ZSTD_blockHeaderSize = ZSTD_BLOCKHEADERSIZE;
121 typedef enum { bt_raw, bt_rle, bt_compressed, bt_reserved } blockType_e; 86 typedef enum { bt_raw, bt_rle, bt_compressed, bt_reserved } blockType_e;
122 87
225 BYTE* litStart; 190 BYTE* litStart;
226 BYTE* lit; 191 BYTE* lit;
227 BYTE* llCode; 192 BYTE* llCode;
228 BYTE* mlCode; 193 BYTE* mlCode;
229 BYTE* ofCode; 194 BYTE* ofCode;
195 size_t maxNbSeq;
196 size_t maxNbLit;
230 U32 longLengthID; /* 0 == no longLength; 1 == Lit.longLength; 2 == Match.longLength; */ 197 U32 longLengthID; /* 0 == no longLength; 1 == Lit.longLength; 2 == Match.longLength; */
231 U32 longLengthPos; 198 U32 longLengthPos;
232 } seqStore_t; 199 } seqStore_t;
233 200
234 const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); /* compress & dictBuilder */ 201 const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); /* compress & dictBuilder */