extzstd 0.0.3.CONCEPT → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +5 -5
  2. data/HISTORY.ja.md +39 -0
  3. data/LICENSE +6 -6
  4. data/README.md +26 -45
  5. data/contrib/zstd/CHANGELOG +555 -0
  6. data/contrib/zstd/CODE_OF_CONDUCT.md +5 -0
  7. data/contrib/zstd/CONTRIBUTING.md +392 -0
  8. data/contrib/zstd/COPYING +339 -0
  9. data/contrib/zstd/LICENSE +13 -9
  10. data/contrib/zstd/Makefile +414 -0
  11. data/contrib/zstd/README.md +170 -45
  12. data/contrib/zstd/TESTING.md +44 -0
  13. data/contrib/zstd/appveyor.yml +289 -0
  14. data/contrib/zstd/lib/BUCK +234 -0
  15. data/contrib/zstd/lib/Makefile +354 -0
  16. data/contrib/zstd/lib/README.md +179 -0
  17. data/contrib/zstd/{common → lib/common}/bitstream.h +170 -130
  18. data/contrib/zstd/lib/common/compiler.h +175 -0
  19. data/contrib/zstd/lib/common/cpu.h +215 -0
  20. data/contrib/zstd/lib/common/debug.c +24 -0
  21. data/contrib/zstd/lib/common/debug.h +114 -0
  22. data/contrib/zstd/{common → lib/common}/entropy_common.c +79 -94
  23. data/contrib/zstd/lib/common/error_private.c +55 -0
  24. data/contrib/zstd/lib/common/error_private.h +80 -0
  25. data/contrib/zstd/{common → lib/common}/fse.h +153 -93
  26. data/contrib/zstd/{common → lib/common}/fse_decompress.c +37 -82
  27. data/contrib/zstd/lib/common/huf.h +340 -0
  28. data/contrib/zstd/{common → lib/common}/mem.h +154 -78
  29. data/contrib/zstd/lib/common/pool.c +344 -0
  30. data/contrib/zstd/lib/common/pool.h +84 -0
  31. data/contrib/zstd/lib/common/threading.c +121 -0
  32. data/contrib/zstd/lib/common/threading.h +155 -0
  33. data/contrib/zstd/{common → lib/common}/xxhash.c +85 -75
  34. data/contrib/zstd/{common → lib/common}/xxhash.h +85 -73
  35. data/contrib/zstd/lib/common/zstd_common.c +83 -0
  36. data/contrib/zstd/lib/common/zstd_errors.h +94 -0
  37. data/contrib/zstd/lib/common/zstd_internal.h +447 -0
  38. data/contrib/zstd/{compress → lib/compress}/fse_compress.c +194 -303
  39. data/contrib/zstd/lib/compress/hist.c +183 -0
  40. data/contrib/zstd/lib/compress/hist.h +75 -0
  41. data/contrib/zstd/lib/compress/huf_compress.c +798 -0
  42. data/contrib/zstd/lib/compress/zstd_compress.c +4278 -0
  43. data/contrib/zstd/lib/compress/zstd_compress_internal.h +1125 -0
  44. data/contrib/zstd/lib/compress/zstd_compress_literals.c +158 -0
  45. data/contrib/zstd/lib/compress/zstd_compress_literals.h +29 -0
  46. data/contrib/zstd/lib/compress/zstd_compress_sequences.c +419 -0
  47. data/contrib/zstd/lib/compress/zstd_compress_sequences.h +54 -0
  48. data/contrib/zstd/lib/compress/zstd_compress_superblock.c +845 -0
  49. data/contrib/zstd/lib/compress/zstd_compress_superblock.h +32 -0
  50. data/contrib/zstd/lib/compress/zstd_cwksp.h +525 -0
  51. data/contrib/zstd/lib/compress/zstd_double_fast.c +521 -0
  52. data/contrib/zstd/lib/compress/zstd_double_fast.h +38 -0
  53. data/contrib/zstd/lib/compress/zstd_fast.c +496 -0
  54. data/contrib/zstd/lib/compress/zstd_fast.h +37 -0
  55. data/contrib/zstd/lib/compress/zstd_lazy.c +1138 -0
  56. data/contrib/zstd/lib/compress/zstd_lazy.h +67 -0
  57. data/contrib/zstd/lib/compress/zstd_ldm.c +619 -0
  58. data/contrib/zstd/lib/compress/zstd_ldm.h +110 -0
  59. data/contrib/zstd/lib/compress/zstd_opt.c +1200 -0
  60. data/contrib/zstd/lib/compress/zstd_opt.h +56 -0
  61. data/contrib/zstd/lib/compress/zstdmt_compress.c +2143 -0
  62. data/contrib/zstd/lib/compress/zstdmt_compress.h +192 -0
  63. data/contrib/zstd/lib/decompress/huf_decompress.c +1248 -0
  64. data/contrib/zstd/lib/decompress/zstd_ddict.c +244 -0
  65. data/contrib/zstd/lib/decompress/zstd_ddict.h +44 -0
  66. data/contrib/zstd/lib/decompress/zstd_decompress.c +1885 -0
  67. data/contrib/zstd/lib/decompress/zstd_decompress_block.c +1432 -0
  68. data/contrib/zstd/lib/decompress/zstd_decompress_block.h +59 -0
  69. data/contrib/zstd/lib/decompress/zstd_decompress_internal.h +189 -0
  70. data/contrib/zstd/{common → lib/deprecated}/zbuff.h +86 -69
  71. data/contrib/zstd/lib/deprecated/zbuff_common.c +26 -0
  72. data/contrib/zstd/lib/deprecated/zbuff_compress.c +147 -0
  73. data/contrib/zstd/lib/deprecated/zbuff_decompress.c +75 -0
  74. data/contrib/zstd/lib/dictBuilder/cover.c +1236 -0
  75. data/contrib/zstd/lib/dictBuilder/cover.h +157 -0
  76. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.c +3 -3
  77. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.h +5 -5
  78. data/contrib/zstd/lib/dictBuilder/fastcover.c +757 -0
  79. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/zdict.c +437 -347
  80. data/contrib/zstd/lib/dictBuilder/zdict.h +305 -0
  81. data/contrib/zstd/lib/legacy/zstd_legacy.h +415 -0
  82. data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.c +272 -292
  83. data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.h +26 -32
  84. data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.c +162 -392
  85. data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.h +26 -32
  86. data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.c +162 -391
  87. data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.h +27 -33
  88. data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.c +195 -604
  89. data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.h +26 -32
  90. data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.c +300 -575
  91. data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.h +22 -31
  92. data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.c +165 -592
  93. data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.h +54 -67
  94. data/contrib/zstd/lib/legacy/zstd_v07.c +4541 -0
  95. data/contrib/zstd/lib/legacy/zstd_v07.h +187 -0
  96. data/contrib/zstd/lib/libzstd.pc.in +15 -0
  97. data/contrib/zstd/lib/zstd.h +2090 -0
  98. data/ext/depend +2 -0
  99. data/ext/extconf.rb +18 -5
  100. data/ext/extzstd.c +296 -214
  101. data/ext/extzstd.h +81 -36
  102. data/ext/extzstd_nogvls.h +0 -117
  103. data/ext/extzstd_stream.c +622 -0
  104. data/ext/libzstd_conf.h +8 -0
  105. data/ext/zstd_common.c +11 -0
  106. data/ext/zstd_compress.c +15 -0
  107. data/ext/zstd_decompress.c +6 -0
  108. data/ext/zstd_dictbuilder.c +10 -0
  109. data/ext/zstd_dictbuilder_fastcover.c +3 -0
  110. data/ext/zstd_legacy_v01.c +3 -1
  111. data/ext/zstd_legacy_v02.c +3 -1
  112. data/ext/zstd_legacy_v03.c +3 -1
  113. data/ext/zstd_legacy_v04.c +3 -1
  114. data/ext/zstd_legacy_v05.c +3 -1
  115. data/ext/zstd_legacy_v06.c +3 -1
  116. data/ext/zstd_legacy_v07.c +3 -0
  117. data/gemstub.rb +27 -21
  118. data/lib/extzstd.rb +82 -161
  119. data/lib/extzstd/version.rb +1 -1
  120. data/test/test_basic.rb +19 -6
  121. metadata +127 -59
  122. data/contrib/zstd/common/error_private.h +0 -125
  123. data/contrib/zstd/common/error_public.h +0 -77
  124. data/contrib/zstd/common/huf.h +0 -228
  125. data/contrib/zstd/common/zstd.h +0 -475
  126. data/contrib/zstd/common/zstd_common.c +0 -91
  127. data/contrib/zstd/common/zstd_internal.h +0 -238
  128. data/contrib/zstd/compress/huf_compress.c +0 -577
  129. data/contrib/zstd/compress/zbuff_compress.c +0 -327
  130. data/contrib/zstd/compress/zstd_compress.c +0 -3074
  131. data/contrib/zstd/compress/zstd_opt.h +0 -1046
  132. data/contrib/zstd/decompress/huf_decompress.c +0 -894
  133. data/contrib/zstd/decompress/zbuff_decompress.c +0 -294
  134. data/contrib/zstd/decompress/zstd_decompress.c +0 -1362
  135. data/contrib/zstd/dictBuilder/zdict.h +0 -113
  136. data/contrib/zstd/legacy/zstd_legacy.h +0 -140
  137. data/ext/extzstd_buffered.c +0 -265
  138. data/ext/zstd_amalgam.c +0 -18
@@ -1,18 +1,22 @@
1
- ZSTD Library
2
- Copyright (c) 2014-2015, Yann Collet
3
- All rights reserved.
4
-
5
1
  BSD License
6
2
 
3
+ For Zstandard software
4
+
5
+ Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
6
+
7
7
  Redistribution and use in source and binary forms, with or without modification,
8
8
  are permitted provided that the following conditions are met:
9
9
 
10
- * Redistributions of source code must retain the above copyright notice, this
11
- list of conditions and the following disclaimer.
10
+ * Redistributions of source code must retain the above copyright notice, this
11
+ list of conditions and the following disclaimer.
12
+
13
+ * Redistributions in binary form must reproduce the above copyright notice,
14
+ this list of conditions and the following disclaimer in the documentation
15
+ and/or other materials provided with the distribution.
12
16
 
13
- * Redistributions in binary form must reproduce the above copyright notice, this
14
- list of conditions and the following disclaimer in the documentation and/or
15
- other materials provided with the distribution.
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.
16
20
 
17
21
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
22
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -0,0 +1,414 @@
1
+ # ################################################################
2
+ # Copyright (c) 2015-2020, Yann Collet, Facebook, Inc.
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
+ PRGDIR = programs
12
+ ZSTDDIR = lib
13
+ BUILDIR = build
14
+ ZWRAPDIR = zlibWrapper
15
+ TESTDIR = tests
16
+ FUZZDIR = $(TESTDIR)/fuzz
17
+
18
+ # Define nul output
19
+ VOID = /dev/null
20
+
21
+ # When cross-compiling from linux to windows, you might
22
+ # need to specify this as "Windows." Fedora build fails
23
+ # without it.
24
+ #
25
+ # Note: mingw-w64 build from linux to windows does not
26
+ # fail on other tested distros (ubuntu, debian) even
27
+ # without manually specifying the TARGET_SYSTEM.
28
+ TARGET_SYSTEM ?= $(OS)
29
+
30
+ ifneq (,$(filter Windows%,$(TARGET_SYSTEM)))
31
+ EXT =.exe
32
+ else
33
+ EXT =
34
+ endif
35
+
36
+ ## default: Build lib-release and zstd-release
37
+ .PHONY: default
38
+ default: lib-release zstd-release
39
+
40
+ .PHONY: all
41
+ all: allmost examples manual contrib
42
+
43
+ .PHONY: allmost
44
+ allmost: allzstd zlibwrapper
45
+
46
+ # skip zwrapper, can't build that on alternate architectures without the proper zlib installed
47
+ .PHONY: allzstd
48
+ allzstd: lib-all
49
+ $(MAKE) -C $(PRGDIR) all
50
+ $(MAKE) -C $(TESTDIR) all
51
+
52
+ .PHONY: all32
53
+ all32:
54
+ $(MAKE) -C $(PRGDIR) zstd32
55
+ $(MAKE) -C $(TESTDIR) all32
56
+
57
+ .PHONY: lib lib-release libzstd.a
58
+ lib lib-release lib-all :
59
+ @$(MAKE) -C $(ZSTDDIR) $@
60
+
61
+ .PHONY: zstd zstd-release
62
+ zstd zstd-release:
63
+ @$(MAKE) -C $(PRGDIR) $@
64
+ cp $(PRGDIR)/zstd$(EXT) .
65
+
66
+ .PHONY: zstdmt
67
+ zstdmt:
68
+ @$(MAKE) -C $(PRGDIR) $@
69
+ cp $(PRGDIR)/zstd$(EXT) ./zstdmt$(EXT)
70
+
71
+ .PHONY: zlibwrapper
72
+ zlibwrapper: lib
73
+ $(MAKE) -C $(ZWRAPDIR) all
74
+
75
+ ## test: run long-duration tests
76
+ .PHONY: test
77
+ DEBUGLEVEL ?= 1
78
+ test: MOREFLAGS += -g -DDEBUGLEVEL=$(DEBUGLEVEL) -Werror
79
+ test:
80
+ MOREFLAGS="$(MOREFLAGS)" $(MAKE) -j -C $(PRGDIR) allVariants
81
+ $(MAKE) -C $(TESTDIR) $@
82
+ ZSTD=../../programs/zstd $(MAKE) -C doc/educational_decoder test
83
+
84
+ ## shortest: same as `make check`
85
+ .PHONY: shortest
86
+ shortest:
87
+ $(MAKE) -C $(TESTDIR) $@
88
+
89
+ ## check: run basic tests for `zstd` cli
90
+ .PHONY: check
91
+ check: shortest
92
+
93
+ .PHONY: automated_benchmarking
94
+ automated_benchmarking:
95
+ $(MAKE) -C $(TESTDIR) $@
96
+
97
+ .PHONY: benchmarking
98
+ benchmarking: automated_benchmarking
99
+
100
+ ## examples: build all examples in `/examples` directory
101
+ .PHONY: examples
102
+ examples: lib
103
+ CPPFLAGS=-I../lib LDFLAGS=-L../lib $(MAKE) -C examples/ all
104
+
105
+ ## manual: generate API documentation in html format
106
+ .PHONY: manual
107
+ manual:
108
+ $(MAKE) -C contrib/gen_html $@
109
+
110
+ ## man: generate man page
111
+ .PHONY: man
112
+ man:
113
+ $(MAKE) -C programs $@
114
+
115
+ ## contrib: build all supported projects in `/contrib` directory
116
+ .PHONY: contrib
117
+ contrib: lib
118
+ $(MAKE) -C contrib/pzstd all
119
+ $(MAKE) -C contrib/seekable_format/examples all
120
+ $(MAKE) -C contrib/largeNbDicts all
121
+ cd contrib/single_file_libs/ ; ./build_decoder_test.sh
122
+ cd contrib/single_file_libs/ ; ./build_library_test.sh
123
+
124
+ .PHONY: cleanTabs
125
+ cleanTabs:
126
+ cd contrib; ./cleanTabs
127
+
128
+ .PHONY: clean
129
+ clean:
130
+ @$(MAKE) -C $(ZSTDDIR) $@ > $(VOID)
131
+ @$(MAKE) -C $(PRGDIR) $@ > $(VOID)
132
+ @$(MAKE) -C $(TESTDIR) $@ > $(VOID)
133
+ @$(MAKE) -C $(ZWRAPDIR) $@ > $(VOID)
134
+ @$(MAKE) -C examples/ $@ > $(VOID)
135
+ @$(MAKE) -C contrib/gen_html $@ > $(VOID)
136
+ @$(MAKE) -C contrib/pzstd $@ > $(VOID)
137
+ @$(MAKE) -C contrib/seekable_format/examples $@ > $(VOID)
138
+ @$(MAKE) -C contrib/largeNbDicts $@ > $(VOID)
139
+ @$(RM) zstd$(EXT) zstdmt$(EXT) tmp*
140
+ @$(RM) -r lz4
141
+ @echo Cleaning completed
142
+
143
+ #------------------------------------------------------------------------------
144
+ # make install is validated only for Linux, macOS, Hurd and some BSD targets
145
+ #------------------------------------------------------------------------------
146
+ ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD DragonFly NetBSD MSYS_NT Haiku))
147
+
148
+ HOST_OS = POSIX
149
+ CMAKE_PARAMS = -DZSTD_BUILD_CONTRIB:BOOL=ON -DZSTD_BUILD_STATIC:BOOL=ON -DZSTD_BUILD_TESTS:BOOL=ON -DZSTD_ZLIB_SUPPORT:BOOL=ON -DZSTD_LZMA_SUPPORT:BOOL=ON -DCMAKE_BUILD_TYPE=Release
150
+
151
+ HAVE_COLORNEVER = $(shell echo a | egrep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)
152
+ EGREP_OPTIONS ?=
153
+ ifeq ($HAVE_COLORNEVER, 1)
154
+ EGREP_OPTIONS += --color=never
155
+ endif
156
+ EGREP = egrep $(EGREP_OPTIONS)
157
+
158
+ # Print a two column output of targets and their description. To add a target description, put a
159
+ # comment in the Makefile with the format "## <TARGET>: <DESCRIPTION>". For example:
160
+ #
161
+ ## list: Print all targets and their descriptions (if provided)
162
+ .PHONY: list
163
+ list:
164
+ @TARGETS=$$($(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null \
165
+ | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' \
166
+ | $(EGREP) -v -e '^[^[:alnum:]]' | sort); \
167
+ { \
168
+ printf "Target Name\tDescription\n"; \
169
+ printf "%0.s-" {1..16}; printf "\t"; printf "%0.s-" {1..40}; printf "\n"; \
170
+ for target in $$TARGETS; do \
171
+ line=$$($(EGREP) "^##[[:space:]]+$$target:" $(lastword $(MAKEFILE_LIST))); \
172
+ description=$$(echo $$line | awk '{i=index($$0,":"); print substr($$0,i+1)}' | xargs); \
173
+ printf "$$target\t$$description\n"; \
174
+ done \
175
+ } | column -t -s $$'\t'
176
+
177
+ .PHONY: install armtest usan asan uasan
178
+ install:
179
+ @$(MAKE) -C $(ZSTDDIR) $@
180
+ @$(MAKE) -C $(PRGDIR) $@
181
+
182
+ .PHONY: uninstall
183
+ uninstall:
184
+ @$(MAKE) -C $(ZSTDDIR) $@
185
+ @$(MAKE) -C $(PRGDIR) $@
186
+
187
+ .PHONY: travis-install
188
+ travis-install:
189
+ $(MAKE) install PREFIX=~/install_test_dir
190
+
191
+ .PHONY: gcc5build
192
+ gcc5build: clean
193
+ gcc-5 -v
194
+ CC=gcc-5 $(MAKE) all MOREFLAGS="-Werror"
195
+
196
+ .PHONY: gcc6build
197
+ gcc6build: clean
198
+ gcc-6 -v
199
+ CC=gcc-6 $(MAKE) all MOREFLAGS="-Werror"
200
+
201
+ .PHONY: gcc7build
202
+ gcc7build: clean
203
+ gcc-7 -v
204
+ CC=gcc-7 $(MAKE) all MOREFLAGS="-Werror"
205
+
206
+ .PHONY: clangbuild
207
+ clangbuild: clean
208
+ clang -v
209
+ CXX=clang++ CC=clang CFLAGS="-Werror -Wconversion -Wno-sign-conversion -Wdocumentation" $(MAKE) all
210
+
211
+ m32build: clean
212
+ gcc -v
213
+ $(MAKE) all32
214
+
215
+ armbuild: clean
216
+ CC=arm-linux-gnueabi-gcc CFLAGS="-Werror" $(MAKE) allzstd
217
+
218
+ aarch64build: clean
219
+ CC=aarch64-linux-gnu-gcc CFLAGS="-Werror" $(MAKE) allzstd
220
+
221
+ ppcbuild: clean
222
+ CC=powerpc-linux-gnu-gcc CFLAGS="-m32 -Wno-attributes -Werror" $(MAKE) allzstd
223
+
224
+ ppc64build: clean
225
+ CC=powerpc-linux-gnu-gcc CFLAGS="-m64 -Werror" $(MAKE) allzstd
226
+
227
+ armfuzz: clean
228
+ CC=arm-linux-gnueabi-gcc QEMU_SYS=qemu-arm-static MOREFLAGS="-static" FUZZER_FLAGS=--no-big-tests $(MAKE) -C $(TESTDIR) fuzztest
229
+
230
+ aarch64fuzz: clean
231
+ ld -v
232
+ CC=aarch64-linux-gnu-gcc QEMU_SYS=qemu-aarch64-static MOREFLAGS="-static" FUZZER_FLAGS=--no-big-tests $(MAKE) -C $(TESTDIR) fuzztest
233
+
234
+ ppcfuzz: clean
235
+ CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc-static MOREFLAGS="-static" FUZZER_FLAGS=--no-big-tests $(MAKE) -C $(TESTDIR) fuzztest
236
+
237
+ ppc64fuzz: clean
238
+ CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc64-static MOREFLAGS="-m64 -static" FUZZER_FLAGS=--no-big-tests $(MAKE) -C $(TESTDIR) fuzztest
239
+
240
+ .PHONY: cxxtest
241
+ cxxtest: CXXFLAGS += -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror
242
+ cxxtest: clean
243
+ $(MAKE) -C $(PRGDIR) all CC="$(CXX) -Wno-deprecated" CFLAGS="$(CXXFLAGS)" # adding -Wno-deprecated to avoid clang++ warning on dealing with C files directly
244
+
245
+ gcc5test: clean
246
+ gcc-5 -v
247
+ $(MAKE) all CC=gcc-5 MOREFLAGS="-Werror"
248
+
249
+ gcc6test: clean
250
+ gcc-6 -v
251
+ $(MAKE) all CC=gcc-6 MOREFLAGS="-Werror"
252
+
253
+ armtest: clean
254
+ $(MAKE) -C $(TESTDIR) datagen # use native, faster
255
+ $(MAKE) -C $(TESTDIR) test CC=arm-linux-gnueabi-gcc QEMU_SYS=qemu-arm-static ZSTDRTTEST= MOREFLAGS="-Werror -static" FUZZER_FLAGS=--no-big-tests
256
+
257
+ aarch64test:
258
+ $(MAKE) -C $(TESTDIR) datagen # use native, faster
259
+ $(MAKE) -C $(TESTDIR) test CC=aarch64-linux-gnu-gcc QEMU_SYS=qemu-aarch64-static ZSTDRTTEST= MOREFLAGS="-Werror -static" FUZZER_FLAGS=--no-big-tests
260
+
261
+ ppctest: clean
262
+ $(MAKE) -C $(TESTDIR) datagen # use native, faster
263
+ $(MAKE) -C $(TESTDIR) test CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc-static ZSTDRTTEST= MOREFLAGS="-Werror -Wno-attributes -static" FUZZER_FLAGS=--no-big-tests
264
+
265
+ ppc64test: clean
266
+ $(MAKE) -C $(TESTDIR) datagen # use native, faster
267
+ $(MAKE) -C $(TESTDIR) test CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc64-static ZSTDRTTEST= MOREFLAGS="-m64 -static" FUZZER_FLAGS=--no-big-tests
268
+
269
+ arm-ppc-compilation:
270
+ $(MAKE) -C $(PRGDIR) clean zstd CC=arm-linux-gnueabi-gcc QEMU_SYS=qemu-arm-static ZSTDRTTEST= MOREFLAGS="-Werror -static"
271
+ $(MAKE) -C $(PRGDIR) clean zstd CC=aarch64-linux-gnu-gcc QEMU_SYS=qemu-aarch64-static ZSTDRTTEST= MOREFLAGS="-Werror -static"
272
+ $(MAKE) -C $(PRGDIR) clean zstd CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc-static ZSTDRTTEST= MOREFLAGS="-Werror -Wno-attributes -static"
273
+ $(MAKE) -C $(PRGDIR) clean zstd CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc64-static ZSTDRTTEST= MOREFLAGS="-m64 -static"
274
+
275
+ regressiontest:
276
+ $(MAKE) -C $(FUZZDIR) regressiontest
277
+
278
+ uasanregressiontest:
279
+ $(MAKE) -C $(FUZZDIR) regressiontest CC=clang CXX=clang++ CFLAGS="-O3 -fsanitize=address,undefined" CXXFLAGS="-O3 -fsanitize=address,undefined"
280
+
281
+ msanregressiontest:
282
+ $(MAKE) -C $(FUZZDIR) regressiontest CC=clang CXX=clang++ CFLAGS="-O3 -fsanitize=memory" CXXFLAGS="-O3 -fsanitize=memory"
283
+
284
+ # run UBsan with -fsanitize-recover=signed-integer-overflow
285
+ # due to a bug in UBsan when doing pointer subtraction
286
+ # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63303
287
+
288
+ usan: clean
289
+ $(MAKE) test CC=clang MOREFLAGS="-g -fno-sanitize-recover=all -fsanitize-recover=signed-integer-overflow -fsanitize=undefined -Werror"
290
+
291
+ asan: clean
292
+ $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address -Werror"
293
+
294
+ asan-%: clean
295
+ LDFLAGS=-fuse-ld=gold MOREFLAGS="-g -fno-sanitize-recover=all -fsanitize=address -Werror" $(MAKE) -C $(TESTDIR) $*
296
+
297
+ msan: clean
298
+ $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=memory -fno-omit-frame-pointer -Werror" HAVE_LZMA=0 # datagen.c fails this test for no obvious reason
299
+
300
+ msan-%: clean
301
+ LDFLAGS=-fuse-ld=gold MOREFLAGS="-g -fno-sanitize-recover=all -fsanitize=memory -fno-omit-frame-pointer -Werror" FUZZER_FLAGS=--no-big-tests $(MAKE) -C $(TESTDIR) HAVE_LZMA=0 $*
302
+
303
+ asan32: clean
304
+ $(MAKE) -C $(TESTDIR) test32 CC=clang MOREFLAGS="-g -fsanitize=address"
305
+
306
+ uasan: clean
307
+ $(MAKE) test CC=clang MOREFLAGS="-g -fno-sanitize-recover=all -fsanitize-recover=signed-integer-overflow -fsanitize=address,undefined -Werror"
308
+
309
+ uasan-%: clean
310
+ LDFLAGS=-fuse-ld=gold MOREFLAGS="-g -fno-sanitize-recover=all -fsanitize-recover=signed-integer-overflow -fsanitize=address,undefined -Werror" $(MAKE) -C $(TESTDIR) $*
311
+
312
+ tsan-%: clean
313
+ LDFLAGS=-fuse-ld=gold MOREFLAGS="-g -fno-sanitize-recover=all -fsanitize=thread -Werror" $(MAKE) -C $(TESTDIR) $* FUZZER_FLAGS=--no-big-tests
314
+
315
+ apt-install:
316
+ sudo apt-get -yq --no-install-suggests --no-install-recommends --force-yes install $(APT_PACKAGES)
317
+
318
+ apt-add-repo:
319
+ sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
320
+ sudo apt-get update -y -qq
321
+
322
+ ppcinstall:
323
+ APT_PACKAGES="qemu-system-ppc qemu-user-static gcc-powerpc-linux-gnu" $(MAKE) apt-install
324
+
325
+ arminstall:
326
+ APT_PACKAGES="qemu-system-arm qemu-user-static gcc-arm-linux-gnueabi libc6-dev-armel-cross gcc-aarch64-linux-gnu libc6-dev-arm64-cross" $(MAKE) apt-install
327
+
328
+ valgrindinstall:
329
+ APT_PACKAGES="valgrind" $(MAKE) apt-install
330
+
331
+ libc6install:
332
+ APT_PACKAGES="libc6-dev-i386 gcc-multilib" $(MAKE) apt-install
333
+
334
+ gcc6install: apt-add-repo
335
+ APT_PACKAGES="libc6-dev-i386 gcc-multilib gcc-6 gcc-6-multilib" $(MAKE) apt-install
336
+
337
+ gcc7install: apt-add-repo
338
+ APT_PACKAGES="libc6-dev-i386 gcc-multilib gcc-7 gcc-7-multilib" $(MAKE) apt-install
339
+
340
+ gcc8install: apt-add-repo
341
+ APT_PACKAGES="libc6-dev-i386 gcc-multilib gcc-8 gcc-8-multilib" $(MAKE) apt-install
342
+
343
+ gpp6install: apt-add-repo
344
+ APT_PACKAGES="libc6-dev-i386 g++-multilib gcc-6 g++-6 g++-6-multilib" $(MAKE) apt-install
345
+
346
+ clang38install:
347
+ APT_PACKAGES="clang-3.8" $(MAKE) apt-install
348
+
349
+ # Ubuntu 14.04 ships a too-old lz4
350
+ lz4install:
351
+ [ -e lz4 ] || git clone https://github.com/lz4/lz4 && sudo $(MAKE) -C lz4 install
352
+
353
+ endif
354
+
355
+
356
+ ifneq (,$(filter MSYS%,$(shell uname)))
357
+ HOST_OS = MSYS
358
+ CMAKE_PARAMS = -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Debug -DZSTD_MULTITHREAD_SUPPORT:BOOL=OFF -DZSTD_BUILD_STATIC:BOOL=ON -DZSTD_BUILD_TESTS:BOOL=ON
359
+ endif
360
+
361
+
362
+ #------------------------------------------------------------------------
363
+ # target specific tests
364
+ #------------------------------------------------------------------------
365
+ ifneq (,$(filter $(HOST_OS),MSYS POSIX))
366
+ cmakebuild:
367
+ cmake --version
368
+ $(RM) -r $(BUILDIR)/cmake/build
369
+ mkdir $(BUILDIR)/cmake/build
370
+ cd $(BUILDIR)/cmake/build; cmake -DCMAKE_INSTALL_PREFIX:PATH=~/install_test_dir $(CMAKE_PARAMS) ..
371
+ $(MAKE) -C $(BUILDIR)/cmake/build -j4;
372
+ $(MAKE) -C $(BUILDIR)/cmake/build install;
373
+ $(MAKE) -C $(BUILDIR)/cmake/build uninstall;
374
+ cd $(BUILDIR)/cmake/build; ctest -V -L Medium
375
+
376
+ c89build: clean
377
+ $(CC) -v
378
+ CFLAGS="-std=c89 -Werror" $(MAKE) allmost # will fail, due to missing support for `long long`
379
+
380
+ gnu90build: clean
381
+ $(CC) -v
382
+ CFLAGS="-std=gnu90 -Werror" $(MAKE) allmost
383
+
384
+ c99build: clean
385
+ $(CC) -v
386
+ CFLAGS="-std=c99 -Werror" $(MAKE) allmost
387
+
388
+ gnu99build: clean
389
+ $(CC) -v
390
+ CFLAGS="-std=gnu99 -Werror" $(MAKE) allmost
391
+
392
+ c11build: clean
393
+ $(CC) -v
394
+ CFLAGS="-std=c11 -Werror" $(MAKE) allmost
395
+
396
+ bmix64build: clean
397
+ $(CC) -v
398
+ CFLAGS="-O3 -mbmi -Werror" $(MAKE) -C $(TESTDIR) test
399
+
400
+ bmix32build: clean
401
+ $(CC) -v
402
+ CFLAGS="-O3 -mbmi -mx32 -Werror" $(MAKE) -C $(TESTDIR) test
403
+
404
+ bmi32build: clean
405
+ $(CC) -v
406
+ CFLAGS="-O3 -mbmi -m32 -Werror" $(MAKE) -C $(TESTDIR) test
407
+
408
+ # static analyzer test uses clang's scan-build
409
+ # does not analyze zlibWrapper, due to detected issues in zlib source code
410
+ staticAnalyze: SCANBUILD ?= scan-build
411
+ staticAnalyze:
412
+ $(CC) -v
413
+ CC=$(CC) CPPFLAGS=-g $(SCANBUILD) --status-bugs -v $(MAKE) allzstd examples contrib
414
+ endif
@@ -1,68 +1,193 @@
1
- zstd - library files
2
- ================================
1
+ <p align="center"><img src="https://raw.githubusercontent.com/facebook/zstd/dev/doc/images/zstd_logo86.png" alt="Zstandard"></p>
2
+
3
+ __Zstandard__, or `zstd` as short version, is a fast lossless compression algorithm,
4
+ targeting real-time compression scenarios at zlib-level and better compression ratios.
5
+ It's backed by a very fast entropy stage, provided by [Huff0 and FSE library](https://github.com/Cyan4973/FiniteStateEntropy).
6
+
7
+ The project is provided as an open-source dual [BSD](LICENSE) and [GPLv2](COPYING) licensed **C** library,
8
+ and a command line utility producing and decoding `.zst`, `.gz`, `.xz` and `.lz4` files.
9
+ Should your project require another programming language,
10
+ a list of known ports and bindings is provided on [Zstandard homepage](http://www.zstd.net/#other-languages).
3
11
 
4
- The __lib__ directory contains several files, but depending on target use case, some of them may not be necessary.
12
+ **Development branch status:**
5
13
 
6
- #### Minimal library files
14
+ [![Build Status][travisDevBadge]][travisLink]
15
+ [![Build status][AppveyorDevBadge]][AppveyorLink]
16
+ [![Build status][CircleDevBadge]][CircleLink]
17
+ [![Build status][CirrusDevBadge]][CirrusLink]
18
+ [![Fuzzing Status][OSSFuzzBadge]][OSSFuzzLink]
7
19
 
8
- To build the zstd library the following files are required:
20
+ [travisDevBadge]: https://travis-ci.org/facebook/zstd.svg?branch=dev "Continuous Integration test suite"
21
+ [travisLink]: https://travis-ci.org/facebook/zstd
22
+ [AppveyorDevBadge]: https://ci.appveyor.com/api/projects/status/xt38wbdxjk5mrbem/branch/dev?svg=true "Windows test suite"
23
+ [AppveyorLink]: https://ci.appveyor.com/project/YannCollet/zstd-p0yf0
24
+ [CircleDevBadge]: https://circleci.com/gh/facebook/zstd/tree/dev.svg?style=shield "Short test suite"
25
+ [CircleLink]: https://circleci.com/gh/facebook/zstd
26
+ [CirrusDevBadge]: https://api.cirrus-ci.com/github/facebook/zstd.svg?branch=dev
27
+ [CirrusLink]: https://cirrus-ci.com/github/facebook/zstd
28
+ [OSSFuzzBadge]: https://oss-fuzz-build-logs.storage.googleapis.com/badges/zstd.svg
29
+ [OSSFuzzLink]: https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:zstd
9
30
 
10
- - [common/bitstream.h](common/bitstream.h)
11
- - [common/error_private.h](common/error_private.h)
12
- - [common/error_public.h](common/error_public.h)
13
- - common/fse.h
14
- - common/fse_decompress.c
15
- - common/huf.h
16
- - [common/mem.h](common/mem.h)
17
- - [common/zstd.h]
18
- - common/zstd_internal.h
19
- - compress/fse_compress.c
20
- - compress/huf_compress.c
21
- - compress/zstd_compress.c
22
- - compress/zstd_opt.h
23
- - decompress/huf_decompress.c
24
- - decompress/zstd_decompress.c
31
+ ## Benchmarks
25
32
 
26
- Stable API is exposed in [common/zstd.h].
27
- Advanced and experimental API can be enabled by defining `ZSTD_STATIC_LINKING_ONLY`.
28
- Never use them with a dynamic library, as their definition may change in future versions.
33
+ For reference, several fast compression algorithms were tested and compared
34
+ on a server running Arch Linux (`Linux version 5.5.11-arch1-1`),
35
+ with a Core i9-9900K CPU @ 5.0GHz,
36
+ using [lzbench], an open-source in-memory benchmark by @inikep
37
+ compiled with [gcc] 9.3.0,
38
+ on the [Silesia compression corpus].
29
39
 
30
- [common/zstd.h]: common/zstd.h
40
+ [lzbench]: https://github.com/inikep/lzbench
41
+ [Silesia compression corpus]: http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia
42
+ [gcc]: https://gcc.gnu.org/
31
43
 
44
+ | Compressor name | Ratio | Compression| Decompress.|
45
+ | --------------- | ------| -----------| ---------- |
46
+ | **zstd 1.4.5 -1** | 2.884 | 500 MB/s | 1660 MB/s |
47
+ | zlib 1.2.11 -1 | 2.743 | 90 MB/s | 400 MB/s |
48
+ | brotli 1.0.7 -0 | 2.703 | 400 MB/s | 450 MB/s |
49
+ | **zstd 1.4.5 --fast=1** | 2.434 | 570 MB/s | 2200 MB/s |
50
+ | **zstd 1.4.5 --fast=3** | 2.312 | 640 MB/s | 2300 MB/s |
51
+ | quicklz 1.5.0 -1 | 2.238 | 560 MB/s | 710 MB/s |
52
+ | **zstd 1.4.5 --fast=5** | 2.178 | 700 MB/s | 2420 MB/s |
53
+ | lzo1x 2.10 -1 | 2.106 | 690 MB/s | 820 MB/s |
54
+ | lz4 1.9.2 | 2.101 | 740 MB/s | 4530 MB/s |
55
+ | **zstd 1.4.5 --fast=7** | 2.096 | 750 MB/s | 2480 MB/s |
56
+ | lzf 3.6 -1 | 2.077 | 410 MB/s | 860 MB/s |
57
+ | snappy 1.1.8 | 2.073 | 560 MB/s | 1790 MB/s |
32
58
 
33
- #### Separate compressor and decompressor
59
+ [zlib]: http://www.zlib.net/
60
+ [LZ4]: http://www.lz4.org/
34
61
 
35
- To build a separate zstd compressor all files from `common/` and `compressor/` directories are required.
36
- In a similar way to build a separate zstd decompressor all files from `common/` and `decompressor/` directories are needed.
62
+ The negative compression levels, specified with `--fast=#`,
63
+ offer faster compression and decompression speed in exchange for some loss in
64
+ compression ratio compared to level 1, as seen in the table above.
37
65
 
66
+ Zstd can also offer stronger compression ratios at the cost of compression speed.
67
+ Speed vs Compression trade-off is configurable by small increments.
68
+ Decompression speed is preserved and remains roughly the same at all settings,
69
+ a property shared by most LZ compression algorithms, such as [zlib] or lzma.
38
70
 
39
- #### Buffered streaming
71
+ The following tests were run
72
+ on a server running Linux Debian (`Linux version 4.14.0-3-amd64`)
73
+ with a Core i7-6700K CPU @ 4.0GHz,
74
+ using [lzbench], an open-source in-memory benchmark by @inikep
75
+ compiled with [gcc] 7.3.0,
76
+ on the [Silesia compression corpus].
40
77
 
41
- This complementary API makes streaming integration easier.
42
- It is used by `zstd` command line utility, and [7zip plugin](http://mcmilk.de/projects/7-Zip-ZStd) :
78
+ Compression Speed vs Ratio | Decompression Speed
79
+ ---------------------------|--------------------
80
+ ![Compression Speed vs Ratio](doc/images/CSpeed2.png "Compression Speed vs Ratio") | ![Decompression Speed](doc/images/DSpeed3.png "Decompression Speed")
43
81
 
44
- - common/zbuff.h
45
- - compress/zbuff_compress.c
46
- - decompress/zbuff_decompress.c
82
+ A few other algorithms can produce higher compression ratios at slower speeds, falling outside of the graph.
83
+ For a larger picture including slow modes, [click on this link](doc/images/DCspeed5.png).
47
84
 
48
85
 
49
- #### Dictionary builder
86
+ ## The case for Small Data compression
50
87
 
51
- In order to create dictionaries from some training sets,
52
- it's needed to include all files from [dictBuilder directory](dictBuilder/)
88
+ Previous charts provide results applicable to typical file and stream scenarios (several MB). Small data comes with different perspectives.
53
89
 
90
+ The smaller the amount of data to compress, the more difficult it is to compress. This problem is common to all compression algorithms, and reason is, compression algorithms learn from past data how to compress future data. But at the beginning of a new data set, there is no "past" to build upon.
54
91
 
55
- #### Legacy support
92
+ To solve this situation, Zstd offers a __training mode__, which can be used to tune the algorithm for a selected type of data.
93
+ Training Zstandard is achieved by providing it with a few samples (one file per sample). The result of this training is stored in a file called "dictionary", which must be loaded before compression and decompression.
94
+ Using this dictionary, the compression ratio achievable on small data improves dramatically.
56
95
 
57
- Zstandard can decode previous formats, starting from v0.1.
58
- Support for these format is provided in [folder legacy](legacy/).
59
- It's also required to compile the library with `ZSTD_LEGACY_SUPPORT = 1`.
96
+ The following example uses the `github-users` [sample set](https://github.com/facebook/zstd/releases/tag/v1.1.3), created from [github public API](https://developer.github.com/v3/users/#get-all-users).
97
+ It consists of roughly 10K records weighing about 1KB each.
60
98
 
99
+ Compression Ratio | Compression Speed | Decompression Speed
100
+ ------------------|-------------------|--------------------
101
+ ![Compression Ratio](doc/images/dict-cr.png "Compression Ratio") | ![Compression Speed](doc/images/dict-cs.png "Compression Speed") | ![Decompression Speed](doc/images/dict-ds.png "Decompression Speed")
61
102
 
62
- #### Miscellaneous
63
103
 
64
- The other files are not source code. There are :
104
+ These compression gains are achieved while simultaneously providing _faster_ compression and decompression speeds.
65
105
 
66
- - LICENSE : contains the BSD license text
67
- - Makefile : script to compile or install zstd library (static or dynamic)
68
- - libzstd.pc.in : for pkg-config (make install)
106
+ Training works if there is some correlation in a family of small data samples. The more data-specific a dictionary is, the more efficient it is (there is no _universal dictionary_).
107
+ Hence, deploying one dictionary per type of data will provide the greatest benefits.
108
+ Dictionary gains are mostly effective in the first few KB. Then, the compression algorithm will gradually use previously decoded content to better compress the rest of the file.
109
+
110
+ ### Dictionary compression How To:
111
+
112
+ 1. Create the dictionary
113
+
114
+ `zstd --train FullPathToTrainingSet/* -o dictionaryName`
115
+
116
+ 2. Compress with dictionary
117
+
118
+ `zstd -D dictionaryName FILE`
119
+
120
+ 3. Decompress with dictionary
121
+
122
+ `zstd -D dictionaryName --decompress FILE.zst`
123
+
124
+
125
+ ## Build instructions
126
+
127
+ ### Makefile
128
+
129
+ If your system is compatible with standard `make` (or `gmake`),
130
+ invoking `make` in root directory will generate `zstd` cli in root directory.
131
+
132
+ Other available options include:
133
+ - `make install` : create and install zstd cli, library and man pages
134
+ - `make check` : create and run `zstd`, tests its behavior on local platform
135
+
136
+ ### cmake
137
+
138
+ A `cmake` project generator is provided within `build/cmake`.
139
+ It can generate Makefiles or other build scripts
140
+ to create `zstd` binary, and `libzstd` dynamic and static libraries.
141
+
142
+ By default, `CMAKE_BUILD_TYPE` is set to `Release`.
143
+
144
+ ### Meson
145
+
146
+ A Meson project is provided within [`build/meson`](build/meson). Follow
147
+ build instructions in that directory.
148
+
149
+ You can also take a look at [`.travis.yml`](.travis.yml) file for an
150
+ example about how Meson is used to build this project.
151
+
152
+ Note that default build type is **release**.
153
+
154
+ ### VCPKG
155
+ You can build and install zstd [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
156
+
157
+ git clone https://github.com/Microsoft/vcpkg.git
158
+ cd vcpkg
159
+ ./bootstrap-vcpkg.sh
160
+ ./vcpkg integrate install
161
+ ./vcpkg install zstd
162
+
163
+ The zstd port in vcpkg is kept up to date by Microsoft team members and community contributors.
164
+ If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
165
+
166
+ ### Visual Studio (Windows)
167
+
168
+ Going into `build` directory, you will find additional possibilities:
169
+ - Projects for Visual Studio 2005, 2008 and 2010.
170
+ + VS2010 project is compatible with VS2012, VS2013, VS2015 and VS2017.
171
+ - Automated build scripts for Visual compiler by [@KrzysFR](https://github.com/KrzysFR), in `build/VS_scripts`,
172
+ which will build `zstd` cli and `libzstd` library without any need to open Visual Studio solution.
173
+
174
+ ### Buck
175
+
176
+ You can build the zstd binary via buck by executing: `buck build programs:zstd` from the root of the repo.
177
+ The output binary will be in `buck-out/gen/programs/`.
178
+
179
+ ## Status
180
+
181
+ Zstandard is currently deployed within Facebook. It is used continuously to compress large amounts of data in multiple formats and use cases.
182
+ Zstandard is considered safe for production environments.
183
+
184
+ ## License
185
+
186
+ Zstandard is dual-licensed under [BSD](LICENSE) and [GPLv2](COPYING).
187
+
188
+ ## Contributing
189
+
190
+ The "dev" branch is the one where all contributions are merged before reaching "master".
191
+ If you plan to propose a patch, please commit into the "dev" branch, or its own feature branch.
192
+ Direct commit to "master" are not permitted.
193
+ For more information, please read [CONTRIBUTING](CONTRIBUTING.md).