mirror of
https://github.com/facebook/zstd.git
synced 2025-06-25 00:02:54 -04:00
Compare commits
698 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
3c3b8274c5 | ||
|
7b1b6a0d2d | ||
|
bdceb81271 | ||
|
2e8ec28b30 | ||
|
2295826266 | ||
|
d77a7b6895 | ||
|
528132e9a0 | ||
|
878be1c8f0 | ||
|
16e13ebdeb | ||
|
a74f7fcabd | ||
|
a4b9ebcbeb | ||
|
7eefc22169 | ||
|
354cede369 | ||
|
e315155cc2 | ||
|
429dc891b2 | ||
|
2082749775 | ||
|
4255c5ea89 | ||
|
57bd0eb6a7 | ||
|
d28a737750 | ||
|
cad0b72ad8 | ||
|
7e4937bc75 | ||
|
5e6bdf5e3d | ||
|
9a6fe9a428 | ||
|
88bea95d11 | ||
|
39c091bc9e | ||
|
de8d9e8914 | ||
|
472acf5d83 | ||
|
7e0324e124 | ||
|
b6dc2924f8 | ||
|
49fe2ec793 | ||
|
75abb8bc1c | ||
|
c826c572cf | ||
|
a168ae7232 | ||
|
b922774602 | ||
|
a2dba85fd1 | ||
|
ec8ad2e552 | ||
|
5b6fbf5f96 | ||
|
e23d0a9616 | ||
|
a480191f9e | ||
|
80cac404c7 | ||
|
4be08ba122 | ||
|
a81ffe11d4 | ||
|
bd894054c0 | ||
|
dd4cee9190 | ||
|
d95123f2e6 | ||
|
4bd5654e72 | ||
|
4618b255ea | ||
|
f9938c217d | ||
|
448a09ff78 | ||
|
13cb7a10ae | ||
|
01c973de8d | ||
|
6fc8455a72 | ||
|
2d4cff69c4 | ||
|
f5b6531902 | ||
|
6b0039abcf | ||
|
769723aee2 | ||
|
2d224dc745 | ||
|
e26dde3dcf | ||
|
453e252015 | ||
|
7f907d5c23 | ||
|
8929d3b09f | ||
|
d654fca786 | ||
|
28ffb100ab | ||
|
f5d4da09f5 | ||
|
2a12bbaf90 | ||
|
3bd5aa3404 | ||
|
c5926fbab8 | ||
|
2f9627863f | ||
|
0bdeb1d204 | ||
|
8626da73b6 | ||
|
a293cdcb85 | ||
|
0bde39a9b3 | ||
|
94cfa0b5a0 | ||
|
76c2fdc7b7 | ||
|
7630870b47 | ||
|
165e52ce62 | ||
|
7f0519dcfd | ||
|
23e8812f5b | ||
|
eb168a0afc | ||
|
12ea5f6e30 | ||
|
ec40252066 | ||
|
64dc08f47f | ||
|
334af72280 | ||
|
c59f7ac51e | ||
|
33f4d40d1e | ||
|
bea1e942f7 | ||
|
2fec3989c1 | ||
|
6775af5b2e | ||
|
cd8ca9d92e | ||
|
eca205fc78 | ||
|
4d53e27144 | ||
|
ddcb41a282 | ||
|
a9b8fef2e8 | ||
|
dcf675886b | ||
|
51b6e79f65 | ||
|
9a57bdc0bd | ||
|
68dfd14a8c | ||
|
b27ba56a6d | ||
|
19541b4d1a | ||
|
c583c2c39e | ||
|
f9a6031963 | ||
|
3c4096c83e | ||
|
2ff87aefac | ||
|
c18374bb16 | ||
|
56e2ebf5c3 | ||
|
d5986f235f | ||
|
b16d193512 | ||
|
0de4991942 | ||
|
99cf130cfc | ||
|
190a620974 | ||
|
d5b84f5a27 | ||
|
5e7d721235 | ||
|
5ae1cb9fa1 | ||
|
f5a0e047cb | ||
|
0b40c513fd | ||
|
0298df50f9 | ||
|
9b8b414833 | ||
|
19ffcf81b8 | ||
|
fcfb3160dc | ||
|
d5dbdd6ece | ||
|
bceb8f2dbc | ||
|
9ec1a7c0ac | ||
|
7df457a51d | ||
|
cab2a29c36 | ||
|
3c6c472f01 | ||
|
46b2e05a33 | ||
|
83db5376d7 | ||
|
0727fc5ff9 | ||
|
a9337e6739 | ||
|
e99be473a6 | ||
|
bbbb2379ed | ||
|
a6d232dcad | ||
|
88100bc62f | ||
|
4e1723a7e4 | ||
|
7340657c6f | ||
|
77e58994d2 | ||
|
e94e09dd7b | ||
|
017ada44b5 | ||
|
bbf2801ddd | ||
|
a1a5154b69 | ||
|
22b2fd2517 | ||
|
d6fbaaac99 | ||
|
0ac659fb00 | ||
|
dca9791862 | ||
|
4d81b0000d | ||
|
f0d3173203 | ||
|
97bc43cc68 | ||
|
db2d205ada | ||
|
2413f17322 | ||
|
8ffa27d93b | ||
|
e635221f1b | ||
|
30281d889f | ||
|
2840631dc1 | ||
|
76779f52c2 | ||
|
3ff0d794b8 | ||
|
5743da491b | ||
|
e1e2f3873d | ||
|
b40dabeda2 | ||
|
fd5498a179 | ||
|
ebfa660b82 | ||
|
8ff47f3df0 | ||
|
0c3345d6ec | ||
|
c2ab0f9c4e | ||
|
4690d66c7e | ||
|
1bef87857b | ||
|
6af3842118 | ||
|
d157156bb8 | ||
|
37077c859b | ||
|
eb6608869f | ||
|
ea027ab21c | ||
|
b14d76d888 | ||
|
5c465fcabe | ||
|
99a12e6f72 | ||
|
c26bde119b | ||
|
22c39b9891 | ||
|
beccbc6f74 | ||
|
2a58b04752 | ||
|
85c39b78cf | ||
|
0b8119f0ad | ||
|
b73e06b83e | ||
|
2b7c661ad2 | ||
|
75bcae1272 | ||
|
fc1baf3463 | ||
|
815ca8c678 | ||
|
d84d70bd04 | ||
|
d2c562b803 | ||
|
67fad95f79 | ||
|
339bca6606 | ||
|
09d7e34ed8 | ||
|
d5e4698267 | ||
|
72406b71c3 | ||
|
7c5b6002c9 | ||
|
bf218c142a | ||
|
f26cc54f37 | ||
|
4609a40b89 | ||
|
5b8575adaa | ||
|
e3a9351402 | ||
|
071a4a0904 | ||
|
613901b6d3 | ||
|
468e1453a5 | ||
|
1603cbe83e | ||
|
7a2fce5a1f | ||
|
f86024ccd2 | ||
|
39d1d82fa8 | ||
|
41b7193757 | ||
|
8ae1330708 | ||
|
630b47a158 | ||
|
aebffd66ec | ||
|
0396480109 | ||
|
ef2bf57811 | ||
|
23e5f80390 | ||
|
c7cd7dc04b | ||
|
f11bd19c7f | ||
|
7406d2b6eb | ||
|
220abe6da8 | ||
|
85a44b233a | ||
|
e637fc64c5 | ||
|
34ba14437a | ||
|
ffa66a6971 | ||
|
30e0f29c4d | ||
|
2949252923 | ||
|
e87d15938c | ||
|
590c22454e | ||
|
f9c1850aa2 | ||
|
e117d79e22 | ||
|
c39424ea87 | ||
|
32dff04d32 | ||
|
5883ee6cc2 | ||
|
8156a19cac | ||
|
54e9d46db4 | ||
|
bcf404c0ab | ||
|
6e1d02f1f0 | ||
|
7b856e3028 | ||
|
26a2b5d5df | ||
|
086ddcd9ba | ||
|
b55ff3c61d | ||
|
60f84f73fe | ||
|
283fbd2dca | ||
|
8df6155495 | ||
|
de7c8b9842 | ||
|
6a65a43032 | ||
|
be1bf2469e | ||
|
1d088ba55c | ||
|
92be4be810 | ||
|
6cd4204ee3 | ||
|
ab54285129 | ||
|
0cda0100ea | ||
|
f7e8fc339b | ||
|
0a183620a3 | ||
|
d486ccc9e9 | ||
|
1b15e888fc | ||
|
59afb28c97 | ||
|
ea0aa030cd | ||
|
1204626138 | ||
|
a7b59bcb7f | ||
|
55c0c5bdca | ||
|
2ef57cf1e2 | ||
|
45c0e72c0a | ||
|
becef672bb | ||
|
03d5ad6fed | ||
|
897cec3876 | ||
|
a0872a8372 | ||
|
6c1d1cc600 | ||
|
f7c7553e4f | ||
|
cf01bbf005 | ||
|
056492e31b | ||
|
5b9c5d4929 | ||
|
e39ed41435 | ||
|
48b186f76b | ||
|
0c335c97b8 | ||
|
82346b92bb | ||
|
4bbf4a285d | ||
|
9fbed3330c | ||
|
a556559841 | ||
|
e475dc4c05 | ||
|
d2d74616c0 | ||
|
27d7940631 | ||
|
0501095898 | ||
|
f0b5f65bca | ||
|
35edbc20dc | ||
|
9efb09749b | ||
|
a469e7c083 | ||
|
167b00495d | ||
|
eb2ceb4bc8 | ||
|
fcd684b9b4 | ||
|
d60c4d75e9 | ||
|
462484d5dc | ||
|
26e5fb3614 | ||
|
936927a427 | ||
|
e8de8085f4 | ||
|
053e4bef20 | ||
|
4f3311f245 | ||
|
ee17f4c6d2 | ||
|
46e17b805b | ||
|
78275149ea | ||
|
c8243b4724 | ||
|
319dc2911f | ||
|
19025f3da0 | ||
|
33747e2569 | ||
|
87f0a4fbe0 | ||
|
8bff69af86 | ||
|
2f3ee8b530 | ||
|
debe3d20d9 | ||
|
6f8e6f3c97 | ||
|
e3181cfd32 | ||
|
aa2cdf964f | ||
|
57a4554192 | ||
|
4aaf9cefe9 | ||
|
db3d48823a | ||
|
cd53924eff | ||
|
ed0a8b8be1 | ||
|
b6a4d5a8ba | ||
|
8eb2587432 | ||
|
bfc58f5ba2 | ||
|
8d62164589 | ||
|
d1f0e5fb97 | ||
|
886720442f | ||
|
72277079fb | ||
|
0b96e6d42a | ||
|
43626f1ce0 | ||
|
d4ae5c3752 | ||
|
642157cc45 | ||
|
80ff61de1d | ||
|
196e76efe1 | ||
|
0e819c9f93 | ||
|
908a95889b | ||
|
92d1a7d07c | ||
|
421f9c947d | ||
|
7d63a1c7c3 | ||
|
afff3d2cce | ||
|
80af41e08a | ||
|
e490be895c | ||
|
f5dbdac818 | ||
|
56500044c4 | ||
|
42d704ad5e | ||
|
a610550e2c | ||
|
f5e2996dd3 | ||
|
59c2e3335f | ||
|
0fd521048d | ||
|
d88651e604 | ||
|
1548bfc349 | ||
|
2759d9d52f | ||
|
dfb236b2aa | ||
|
6b046f5841 | ||
|
757e29e170 | ||
|
54c3d998a0 | ||
|
f5d9d57fe6 | ||
|
04a2a0219c | ||
|
cf5e53f618 | ||
|
a2ff6ea784 | ||
|
f8a2b352d6 | ||
|
788926fe48 | ||
|
72ce56b527 | ||
|
7b294caf46 | ||
|
f8725e80cc | ||
|
f0937b83d9 | ||
|
47cbfc87a9 | ||
|
522adc34eb | ||
|
b7a9e69d8d | ||
|
76445bb379 | ||
|
52a9bc6fca | ||
|
ab0f1798e8 | ||
|
b339efff2b | ||
|
a80f55f47d | ||
|
0a54f6f288 | ||
|
ad023b392f | ||
|
b7b4e86347 | ||
|
12c47d3262 | ||
|
95ad9e47ff | ||
|
d48e330ae1 | ||
|
61ac8311e0 | ||
|
f617e86b71 | ||
|
47edd0acf4 | ||
|
6f8c1046d0 | ||
|
f0d0d95234 | ||
|
31b5ef2539 | ||
|
5164d44dab | ||
|
ca8bd83373 | ||
|
d2d0fdac42 | ||
|
1f6d6815c3 | ||
|
a288751de7 | ||
|
f176514467 | ||
|
1c8f5b0f11 | ||
|
0a5c0807af | ||
|
f281497aef | ||
|
ac05ea89a5 | ||
|
8ab04097ed | ||
|
c050ae4fb8 | ||
|
8b7e1b795d | ||
|
c540976a4b | ||
|
4c097b4939 | ||
|
09964c6276 | ||
|
0b013b2688 | ||
|
14a21e43b3 | ||
|
bcb15091aa | ||
|
047db4f1f8 | ||
|
4ef9d7d585 | ||
|
56cfb7816a | ||
|
13b9296d79 | ||
|
2503b64345 | ||
|
e0f3aaee46 | ||
|
08edecb78c | ||
|
25bef24c5c | ||
|
41c667c0fd | ||
|
5df80acedb | ||
|
fa468944f2 | ||
|
30671d77af | ||
|
5359d16d8d | ||
|
03d95f9d13 | ||
|
76dd3a98c4 | ||
|
1ac79ba1b6 | ||
|
894ea31281 | ||
|
c97522f7fb | ||
|
0165eeb441 | ||
|
e9f8a119b4 | ||
|
0442e43aca | ||
|
477a01067f | ||
|
8d4506bc94 | ||
|
a2245721ca | ||
|
9671813375 | ||
|
b4a40a845f | ||
|
a00f45a037 | ||
|
125f05282b | ||
|
5a7f5c745c | ||
|
d06e8778bc | ||
|
8f49db5a02 | ||
|
c7af0428c6 | ||
|
10b9d81909 | ||
|
c727d5cd67 | ||
|
d0d5ce4c00 | ||
|
d51e6072a8 | ||
|
a7bb6d6c49 | ||
|
07ffcc6b65 | ||
|
f25b9f11ba | ||
|
63acf9a995 | ||
|
58a7f4b869 | ||
|
fa5bfb6030 | ||
|
ded4c1ec18 | ||
|
5222dd87cf | ||
|
fc726da774 | ||
|
0218c8de0f | ||
|
2d8710c447 | ||
|
5a1c5014cb | ||
|
50ca9984ad | ||
|
f7a8bb1263 | ||
|
7236e05b0a | ||
|
1198a582d3 | ||
|
17beeb5d1a | ||
|
4a4786bef0 | ||
|
e190e7944e | ||
|
709be6c227 | ||
|
c254ea097b | ||
|
5e0a83ec25 | ||
|
82d470564d | ||
|
2b36d4bc1c | ||
|
7f11e6d2b6 | ||
|
fcf88ae39b | ||
|
1958fff050 | ||
|
b683c0dbe2 | ||
|
10beb7cb53 | ||
|
194062a4e7 | ||
|
b0a179d469 | ||
|
a9d279c97c | ||
|
45fdc5f9e4 | ||
|
314092f150 | ||
|
2d1bbc37eb | ||
|
b2c5bc16d9 | ||
|
d0fe334c85 | ||
|
b3035b36c6 | ||
|
51eb7daf39 | ||
|
2e02cd330d | ||
|
adbb536d00 | ||
|
d9553fd218 | ||
|
15c29168b7 | ||
|
bbaba45589 | ||
|
4f93206d62 | ||
|
f593ccda04 | ||
|
fcbf6b014a | ||
|
37706a677c | ||
|
226ae73311 | ||
|
01474bf73b | ||
|
5bae43b411 | ||
|
4e1a87976f | ||
|
5b4ce643f0 | ||
|
e557abc8a0 | ||
|
7fb5347e88 | ||
|
c63b5d2294 | ||
|
da2c0dffd8 | ||
|
2366a87ddc | ||
|
ea082692aa | ||
|
326c45bb8e | ||
|
ca6e55cbf5 | ||
|
94d7b07425 | ||
|
566763fdc9 | ||
|
2dddf09056 | ||
|
70c77d20d6 | ||
|
90095f056d | ||
|
bbda1acf85 | ||
|
c80645a055 | ||
|
7d3e5e3ba1 | ||
|
b68ddce818 | ||
|
57239c4d3b | ||
|
18b1e67223 | ||
|
d2eeed53dc | ||
|
0be334d208 | ||
|
06b7cfabf8 | ||
|
16450d0732 | ||
|
1ec5f9f1f6 | ||
|
4662f6e646 | ||
|
ea85dc7af6 | ||
|
5ae34e4c96 | ||
|
7bad787d8b | ||
|
a167571db5 | ||
|
1c62e714ab | ||
|
dac26eaeac | ||
|
4ce91cbf2b | ||
|
cae8d13294 | ||
|
4685eafa81 | ||
|
433f4598ad | ||
|
73a6653653 | ||
|
7f015c2fd7 | ||
|
31d48e9ffa | ||
|
76ad1d6903 | ||
|
cdddcaaec9 | ||
|
6939235f01 | ||
|
80a912dec1 | ||
|
6dc52122e6 | ||
|
20c3d176cd | ||
|
0d4b520657 | ||
|
dd38c677eb | ||
|
8b3887f579 | ||
|
f83ed087f6 | ||
|
83a3402a92 | ||
|
fa147cbb4d | ||
|
6021b6663a | ||
|
e2d7d08888 | ||
|
586ca96fec | ||
|
9e52789962 | ||
|
a5bce4ae84 | ||
|
dfaf5fafb9 | ||
|
f34bc9cee6 | ||
|
0079d515b1 | ||
|
b880f20d52 | ||
|
41d870fbbf | ||
|
ff8e98bebe | ||
|
47d4f5662d | ||
|
61d08b0e42 | ||
|
6326775166 | ||
|
18a42190c2 | ||
|
730d2dce41 | ||
|
c2abfc5ba4 | ||
|
e63896eb58 | ||
|
def3ee9548 | ||
|
e6740355e3 | ||
|
6f2e29a234 | ||
|
1024aa9252 | ||
|
8c38bda935 | ||
|
8e5823b65c | ||
|
83de00316c | ||
|
7ba43091b8 | ||
|
fa1fcb08ab | ||
|
3e7c66acd1 | ||
|
d45aee43f4 | ||
|
741b860fc1 | ||
|
197c258a79 | ||
|
186b132495 | ||
|
2cc600bab2 | ||
|
3b343dcfb1 | ||
|
1e7fa242f4 | ||
|
da23998e9a | ||
|
b84653fc83 | ||
|
b7e1eef048 | ||
|
a8b86d024a | ||
|
75b0f5f4f5 | ||
|
dda3cdfdec | ||
|
751bf1ffd8 | ||
|
dcc8fd0472 | ||
|
8edd147686 | ||
|
de6cc98e07 | ||
|
3d5d3f5630 | ||
|
27bf1362fe | ||
|
ccc02a9a77 | ||
|
d2d49a1161 | ||
|
a3b5c4521c | ||
|
984d11a4d1 | ||
|
d2212c680a | ||
|
039f404faa | ||
|
9215de52c7 | ||
|
a8b544d460 | ||
|
bc96d4b077 | ||
|
d27a4cd4ac | ||
|
e8fce38954 | ||
|
7a48dc230c | ||
|
20707e3718 | ||
|
09cb37cbb1 | ||
|
ad038d8768 | ||
|
ec0c41414d | ||
|
a761013b03 | ||
|
aed3c7540a | ||
|
1eb32ff594 | ||
|
ee1fc7ee5c | ||
|
10e2a8042c | ||
|
bf4a43fcd4 | ||
|
9a5c74b2ca | ||
|
a40bad8ec0 | ||
|
6dbd49bcd0 | ||
|
14b8d398fd | ||
|
89451cafbd | ||
|
6b16169ccf | ||
|
688a815c86 | ||
|
fdfb2aff39 | ||
|
cb784edf5d | ||
|
d4b176db0f | ||
|
c3c28c4d5a | ||
|
43b713a2ce | ||
|
81b52f31e3 | ||
|
adcb543fb8 | ||
|
b768e09393 | ||
|
80b1385d23 | ||
|
46a3135524 | ||
|
efbb5ef015 | ||
|
1f5df587fa | ||
|
0986e1e630 | ||
|
0ff651dd87 | ||
|
5d63f186cc | ||
|
b320d096a4 | ||
|
ab02fd342f | ||
|
1f72f52bc1 | ||
|
345bcb5ff7 | ||
|
3de0541aef | ||
|
4fe0ba0328 | ||
|
0938308ff6 | ||
|
44e83e9180 | ||
|
2d736d9c50 | ||
|
17b5315016 | ||
|
80170f6aad | ||
|
3242ac598e | ||
|
6a77f213c4 | ||
|
d7a84a683f | ||
|
aa76eeafb7 | ||
|
7ddf633a8a | ||
|
f19c98228f | ||
|
2acf90431a | ||
|
be6a182006 | ||
|
949689facf | ||
|
f70fb7c870 | ||
|
c5862f7731 | ||
|
5e9a6c2fe4 | ||
|
4c6a519fdd | ||
|
0e2ceb2d50 | ||
|
1872688e0a | ||
|
5fadd8e6b1 | ||
|
2955d92ac0 | ||
|
78955f5f9d | ||
|
4356192cb2 | ||
|
97291fc502 | ||
|
d7cb47036c | ||
|
fe67503f84 | ||
|
f65dde9860 | ||
|
a86f5f3f33 | ||
|
68a6d9b9f6 | ||
|
ff7a151f2e | ||
|
eb541403c4 | ||
|
1232d4c45d | ||
|
da797d0a43 | ||
|
fb5a5e46a5 | ||
|
849b2ad907 | ||
|
0b24fc0a11 | ||
|
b4ecf724b1 | ||
|
75d0f66c87 | ||
|
01cea2e1e2 | ||
|
4f41631aa4 | ||
|
1d5e9705db | ||
|
592de19843 | ||
|
5be2a8721d | ||
|
9f42fa0a04 | ||
|
f1f1ae369a | ||
|
7968c661af | ||
|
71def59890 | ||
|
87af5fb2df | ||
|
6f7f59b232 | ||
|
3fd4f3bf04 | ||
|
fd5f8106a5 | ||
|
c54f4783d0 | ||
|
8cff66f2f5 | ||
|
a2f145f059 | ||
|
72c16b187d | ||
|
e3566d62ac | ||
|
4b5a266d7b | ||
|
e0ee0fccf8 | ||
|
aaad8e2e8c | ||
|
ebf24b7b77 | ||
|
80a9a2dfcd | ||
|
103a85e6f6 | ||
|
81a5e5d438 | ||
|
101e601c79 | ||
|
9c442d6fc2 | ||
|
65ab6c267e |
@ -1,123 +0,0 @@
|
||||
version: 2
|
||||
|
||||
jobs:
|
||||
# the first half of the jobs are in this test
|
||||
short-tests-0:
|
||||
# TODO: Create a small custom docker image with all the dependencies we need
|
||||
# preinstalled to reduce installation time.
|
||||
docker:
|
||||
- image: fbopensource/zstd-circleci-primary:0.0.1
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Test
|
||||
command: |
|
||||
./tests/test-license.py
|
||||
cc -v
|
||||
CFLAGS="-O0 -Werror -pedantic" make allmost; make clean
|
||||
make c99build; make clean
|
||||
make c11build; make clean
|
||||
make -j regressiontest; make clean
|
||||
make shortest; make clean
|
||||
make cxxtest; make clean
|
||||
# the second half of the jobs are in this test
|
||||
short-tests-1:
|
||||
docker:
|
||||
- image: fbopensource/zstd-circleci-primary:0.0.1
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Test
|
||||
command: |
|
||||
make gnu90build; make clean
|
||||
make gnu99build; make clean
|
||||
make ppc64build V=1; make clean
|
||||
make ppcbuild V=1; make clean
|
||||
make armbuild V=1; make clean
|
||||
make aarch64build V=1; make clean
|
||||
make -C tests test-legacy test-longmatch; make clean
|
||||
make -C lib libzstd-nomt; make clean
|
||||
# This step should only be run in a cron job
|
||||
regression-test:
|
||||
docker:
|
||||
- image: fbopensource/zstd-circleci-primary:0.0.1
|
||||
environment:
|
||||
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
|
||||
steps:
|
||||
- checkout
|
||||
# Restore the cached resources.
|
||||
- restore_cache:
|
||||
# We try our best to bust the cache when the data changes by hashing
|
||||
# data.c. If that doesn't work, simply update the version number here
|
||||
# and below. If we fail to bust the cache, the regression testing will
|
||||
# still work, since it has its own stamp, but will need to redownload
|
||||
# everything.
|
||||
keys:
|
||||
- regression-cache-{{ checksum "tests/regression/data.c" }}-v0
|
||||
- run:
|
||||
name: Regression Test
|
||||
command: |
|
||||
make -C programs zstd
|
||||
make -C tests/regression test
|
||||
mkdir -p $CIRCLE_ARTIFACTS
|
||||
./tests/regression/test \
|
||||
--cache tests/regression/cache \
|
||||
--output $CIRCLE_ARTIFACTS/results.csv \
|
||||
--zstd programs/zstd
|
||||
echo "NOTE: The new results.csv is uploaded as an artifact to this job"
|
||||
echo " If this fails, go to the Artifacts pane in CircleCI, "
|
||||
echo " download /tmp/circleci-artifacts/results.csv, and if they "
|
||||
echo " are still good, copy it into the repo and commit it."
|
||||
echo "> diff tests/regression/results.csv $CIRCLE_ARTIFACTS/results.csv"
|
||||
diff tests/regression/results.csv $CIRCLE_ARTIFACTS/results.csv
|
||||
# Only save the cache on success (default), since if the failure happened
|
||||
# before we stamp the data cache, we will have a bad cache for this key.
|
||||
- save_cache:
|
||||
key: regression-cache-{{ checksum "tests/regression/data.c" }}-v0
|
||||
paths:
|
||||
- tests/regression/cache
|
||||
- store_artifacts:
|
||||
path: /tmp/circleci-artifacts
|
||||
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
commit:
|
||||
jobs:
|
||||
# Run the tests in parallel
|
||||
- short-tests-0
|
||||
- short-tests-1
|
||||
- regression-test
|
||||
|
||||
nightly:
|
||||
triggers:
|
||||
- schedule:
|
||||
cron: "0 0 * * *"
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- release
|
||||
- dev
|
||||
- master
|
||||
jobs:
|
||||
# Run daily regression tests
|
||||
- regression-test
|
||||
|
||||
|
||||
|
||||
# Longer tests
|
||||
#- make -C tests test-zstd-nolegacy && make clean
|
||||
#- pyenv global 3.4.4; make -C tests versionsTest && make clean
|
||||
#- make zlibwrapper && make clean
|
||||
#- gcc -v; make -C tests test32 MOREFLAGS="-I/usr/include/x86_64-linux-gnu" && make clean
|
||||
#- make uasan && make clean
|
||||
#- make asan32 && make clean
|
||||
#- make -C tests test32 CC=clang MOREFLAGS="-g -fsanitize=address -I/usr/include/x86_64-linux-gnu"
|
||||
# Valgrind tests
|
||||
#- CFLAGS="-O1 -g" make -C zlibWrapper valgrindTest && make clean
|
||||
#- make -C tests valgrindTest && make clean
|
||||
# ARM, AArch64, PowerPC, PowerPC64 tests
|
||||
#- make ppctest && make clean
|
||||
#- make ppc64test && make clean
|
||||
#- make armtest && make clean
|
||||
#- make aarch64test && make clean
|
@ -1,9 +0,0 @@
|
||||
FROM circleci/buildpack-deps@sha256:f6f10c11b7b8ccfd4f4a5b830c3256803604ce61292b60cb22e26b12f62b0e8c
|
||||
|
||||
RUN sudo dpkg --add-architecture i386
|
||||
RUN sudo apt-get -y -qq update
|
||||
RUN sudo apt-get -y install \
|
||||
gcc-multilib-powerpc-linux-gnu gcc-arm-linux-gnueabi \
|
||||
libc6-dev-armel-cross gcc-aarch64-linux-gnu libc6-dev-arm64-cross \
|
||||
libc6-dev-ppc64-powerpc-cross zstd gzip coreutils \
|
||||
libcurl4-openssl-dev
|
@ -1,10 +1,9 @@
|
||||
task:
|
||||
name: FreeBSD (shortest)
|
||||
name: FreeBSD (make check)
|
||||
freebsd_instance:
|
||||
matrix:
|
||||
image_family: freebsd-14-0
|
||||
image_family: freebsd-13-2
|
||||
image_family: freebsd-14-2
|
||||
install_script: pkg install -y gmake coreutils
|
||||
script: |
|
||||
MOREFLAGS="-Werror" gmake -j all
|
||||
gmake shortest
|
||||
gmake check
|
||||
|
39
.github/workflows/android-ndk-build.yml
vendored
Normal file
39
.github/workflows/android-ndk-build.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
name: Android NDK Build
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ dev, release, actionsTest ]
|
||||
push:
|
||||
branches: [ actionsTest, '*ndk*' ]
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Setup Android SDK
|
||||
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2
|
||||
|
||||
- name: Install Android NDK
|
||||
run: |
|
||||
sdkmanager --install "ndk;27.0.12077973"
|
||||
echo "ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/27.0.12077973" >> $GITHUB_ENV
|
||||
|
||||
- name: Build with NDK
|
||||
run: |
|
||||
export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
|
||||
make CC=aarch64-linux-android21-clang \
|
||||
AR=llvm-ar \
|
||||
RANLIB=llvm-ranlib \
|
||||
STRIP=llvm-strip
|
||||
|
153
.github/workflows/cmake-tests.yml
vendored
Normal file
153
.github/workflows/cmake-tests.yml
vendored
Normal file
@ -0,0 +1,153 @@
|
||||
name: cmake-tests
|
||||
# CMake-specific build and test workflows
|
||||
# This workflow validates zstd builds across different CMake configurations,
|
||||
# platforms, and edge cases to ensure broad compatibility.
|
||||
|
||||
concurrency:
|
||||
group: cmake-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ dev, release, actionsTest ]
|
||||
|
||||
permissions: read-all
|
||||
|
||||
env:
|
||||
# Centralized test timeouts for consistency
|
||||
QUICK_TEST_TIME: "30s"
|
||||
STANDARD_TEST_TIME: "1mn"
|
||||
# Common CMake flags
|
||||
COMMON_CMAKE_FLAGS: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DZSTD_BUILD_TESTS=ON"
|
||||
|
||||
jobs:
|
||||
# Ubuntu-based cmake build using make wrapper
|
||||
# This test uses the make-driven cmake build to ensure compatibility
|
||||
# with the existing build system integration
|
||||
cmake-ubuntu-basic:
|
||||
name: "CMake Ubuntu Basic Build"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt install liblzma-dev # Required for compression algorithms
|
||||
- name: CMake build and test via make
|
||||
run: |
|
||||
# Use make wrapper for cmake build with quick test timeouts
|
||||
FUZZERTEST=-T${{ env.STANDARD_TEST_TIME }} ZSTREAM_TESTTIME=-T${{ env.STANDARD_TEST_TIME }} make cmakebuild V=1
|
||||
|
||||
# Cross-platform cmake build with edge case: source paths containing spaces
|
||||
# This test ensures cmake handles filesystem paths with spaces correctly
|
||||
# across different operating systems and build generators
|
||||
cmake-cross-platform-spaces:
|
||||
name: "CMake Cross-Platform (Spaces in Path)"
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
generator: "Unix Makefiles"
|
||||
name: "Linux"
|
||||
- os: windows-latest
|
||||
generator: "NMake Makefiles"
|
||||
name: "Windows NMake"
|
||||
- os: macos-latest
|
||||
generator: "Unix Makefiles"
|
||||
name: "macOS"
|
||||
env:
|
||||
SRC_DIR: "source directory with spaces"
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
with:
|
||||
path: "${{ env.SRC_DIR }}"
|
||||
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
|
||||
if: ${{ matrix.generator == 'NMake Makefiles' }}
|
||||
- name: "CMake build and install (${{ matrix.name }})"
|
||||
run: |
|
||||
# Test Release build with installation to verify packaging
|
||||
cmake -S "${{ env.SRC_DIR }}/build/cmake" -B build -DBUILD_TESTING=ON -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE=Release --install-prefix "${{ runner.temp }}/install"
|
||||
cmake --build build --config Release
|
||||
cmake --install build --config Release
|
||||
|
||||
# Windows-specific cmake testing with Visual Studio 2022
|
||||
# Tests multiple generators and toolchains to ensure broad Windows compatibility
|
||||
# including MSVC (x64, Win32, ARM64), MinGW, and Clang-CL with various architectures and optimizations
|
||||
cmake-windows-comprehensive:
|
||||
name: "CMake Windows VS2022 (${{ matrix.name }})"
|
||||
runs-on: ${{ matrix.runner }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- generator: "Visual Studio 17 2022"
|
||||
flags: "-A x64"
|
||||
name: "MSVC x64"
|
||||
runner: "windows-2022"
|
||||
cmake_extra_flags: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DZSTD_BUILD_TESTS=ON"
|
||||
- generator: "Visual Studio 17 2022"
|
||||
flags: "-A Win32"
|
||||
name: "MSVC Win32"
|
||||
runner: "windows-2022"
|
||||
cmake_extra_flags: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DZSTD_BUILD_TESTS=ON"
|
||||
- generator: "Visual Studio 17 2022"
|
||||
flags: "-A x64"
|
||||
name: "MSVC x64 (No ZSTD_BUILD_TESTS)"
|
||||
runner: "windows-2022"
|
||||
# Intentionally omit ZSTD_BUILD_TESTS to reproduce the CXX language configuration bug
|
||||
cmake_extra_flags: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON"
|
||||
# - generator: "Visual Studio 17 2022"
|
||||
# flags: "-A ARM64"
|
||||
# name: "MSVC ARM64"
|
||||
# runner: "windows-2022-arm64" # Disabled due to very long queue times
|
||||
- generator: "MinGW Makefiles"
|
||||
flags: ""
|
||||
name: "MinGW"
|
||||
runner: "windows-2022"
|
||||
cmake_extra_flags: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DZSTD_BUILD_TESTS=ON"
|
||||
- generator: "Visual Studio 17 2022"
|
||||
flags: "-T ClangCL"
|
||||
name: "Clang-CL"
|
||||
runner: "windows-2022"
|
||||
cmake_extra_flags: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DZSTD_BUILD_TESTS=ON"
|
||||
- generator: "Visual Studio 17 2022"
|
||||
flags: "-T ClangCL -A x64 -DCMAKE_C_FLAGS=/arch:AVX2"
|
||||
name: "Clang-CL AVX2"
|
||||
runner: "windows-2022"
|
||||
cmake_extra_flags: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DZSTD_BUILD_TESTS=ON"
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Add MSBuild to PATH
|
||||
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # tag=v2.0.0
|
||||
- name: "Configure CMake (${{ matrix.name }})"
|
||||
run: |
|
||||
cd build\cmake
|
||||
mkdir build
|
||||
cd build
|
||||
cmake.exe -G "${{matrix.generator}}" ${{matrix.flags}} -DCMAKE_BUILD_TYPE=Debug ${{ matrix.cmake_extra_flags }} -DZSTD_ZSTREAM_FLAGS=-T${{ env.QUICK_TEST_TIME }} -DZSTD_FUZZER_FLAGS=-T${{ env.QUICK_TEST_TIME }} -DZSTD_FULLBENCH_FLAGS=-i0 ..
|
||||
- name: "Build (${{ matrix.name }})"
|
||||
run: |
|
||||
cd build\cmake\build
|
||||
cmake.exe --build .
|
||||
- name: "Test (${{ matrix.name }})"
|
||||
run: |
|
||||
cd build\cmake\build
|
||||
ctest.exe -V -C Debug
|
||||
|
||||
# macOS ARM64 (Apple Silicon) specific cmake testing
|
||||
# Validates zstd builds and runs correctly on Apple Silicon architecture
|
||||
# Uses native ARM64 hardware for optimal performance and compatibility testing
|
||||
cmake-macos-arm64:
|
||||
name: "CMake macOS ARM64 (Apple Silicon)"
|
||||
runs-on: macos-14 # ARM64 runner
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: "CMake build and test (ARM64)"
|
||||
run: |
|
||||
# Configure and build with ARM64-specific optimizations
|
||||
cd build/cmake
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ${{ env.COMMON_CMAKE_FLAGS }} -DZSTD_ZSTREAM_FLAGS=-T${{ env.QUICK_TEST_TIME }} -DZSTD_FUZZER_FLAGS=-T${{ env.QUICK_TEST_TIME }} -DZSTD_FULLBENCH_FLAGS=-i1 ..
|
||||
make -j$(sysctl -n hw.ncpu)
|
||||
ctest -V
|
39
.github/workflows/commit.yml
vendored
39
.github/workflows/commit.yml
vendored
@ -3,7 +3,12 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
pull_request:
|
||||
branches:
|
||||
- dev
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
short-tests-0:
|
||||
runs-on: ubuntu-latest
|
||||
@ -25,8 +30,9 @@ jobs:
|
||||
make c99build; make clean
|
||||
make c11build; make clean
|
||||
make -j regressiontest; make clean
|
||||
make shortest; make clean
|
||||
make check; make clean
|
||||
make cxxtest; make clean
|
||||
|
||||
short-tests-1:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
@ -38,17 +44,26 @@ jobs:
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc-powerpc-linux-gnu gcc-arm-linux-gnueabi gcc-aarch64-linux-gnu libc6-dev-ppc64-powerpc-cross libcurl4-gnutls-dev lib64gcc-11-dev-powerpc-cross
|
||||
- name: Test
|
||||
run: |-
|
||||
make gnu90build; make clean
|
||||
make gnu99build; make clean
|
||||
make ppc64build V=1; make clean
|
||||
make ppcbuild V=1; make clean
|
||||
make armbuild V=1; make clean
|
||||
make aarch64build V=1; make clean
|
||||
make -C tests test-legacy test-longmatch; make clean
|
||||
make -C lib libzstd-nomt; make clean
|
||||
sudo apt-get install gcc-powerpc-linux-gnu gcc-arm-linux-gnueabi gcc-aarch64-linux-gnu libc6-dev-ppc64-powerpc-cross libcurl4-gnutls-dev lib64gcc-13-dev-powerpc-cross
|
||||
- name: gnu90 build
|
||||
run: make gnu90build && make clean
|
||||
- name: gnu99 build
|
||||
run: make gnu99build && make clean
|
||||
- name: ppc64 build
|
||||
run: make ppc64build V=1 && make clean
|
||||
- name: ppc build
|
||||
run: make ppcbuild V=1 && make clean
|
||||
- name: arm build
|
||||
run: make armbuild V=1 && make clean
|
||||
- name: aarch64 build
|
||||
run: make aarch64build V=1 && make clean
|
||||
- name: test-legacy
|
||||
run: make -C tests test-legacy V=1 && make clean
|
||||
- name: test-longmatch
|
||||
run: make -C tests test-longmatch V=1 && make clean
|
||||
- name: libzstd-nomt build
|
||||
run: make -C lib libzstd-nomt V=1 && make clean
|
||||
|
||||
regression-test:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
|
159
.github/workflows/dev-long-tests.yml
vendored
159
.github/workflows/dev-long-tests.yml
vendored
@ -1,5 +1,5 @@
|
||||
name: dev-long-tests
|
||||
# Tests longer than 10mn
|
||||
# Tests generally longer than 10mn
|
||||
|
||||
concurrency:
|
||||
group: long-${{ github.ref }}
|
||||
@ -12,91 +12,106 @@ on:
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
# lasts ~7mn
|
||||
make-all:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: make all
|
||||
run: make all
|
||||
|
||||
# lasts ~24mn
|
||||
# lasts ~19mn
|
||||
make-test:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DEVNULLRIGHTS: 1
|
||||
READFROMBLOCKDEVICE: 1
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: make test
|
||||
run: make test
|
||||
run: |
|
||||
make test
|
||||
make -j zstd
|
||||
./tests/test_process_substitution.bash ./zstd
|
||||
|
||||
# lasts ~26mn
|
||||
make-test-osx:
|
||||
# lasts ~16mn
|
||||
make-test-macos:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- name: OS-X test
|
||||
run: make test # make -c lib all doesn't work because of the fact that it's not a tty
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: make test on macos
|
||||
run: make test
|
||||
|
||||
# lasts ~24mn
|
||||
# lasts ~10mn
|
||||
make-test-32bit:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DEVNULLRIGHTS: 1
|
||||
READFROMBLOCKDEVICE: 1
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- name: make test
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: make test # note: `make -j test success` seems to require a clean state
|
||||
run: |
|
||||
sudo apt-get -qqq update
|
||||
make libc6install
|
||||
CFLAGS="-m32" make test
|
||||
make clean
|
||||
CFLAGS="-m32 -O2" make -j test V=1
|
||||
|
||||
# lasts ~7mn
|
||||
test-largeDictionary:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: largeDictionary
|
||||
run: |
|
||||
CFLAGS="-Werror -O3" make -j -C tests test-largeDictionary
|
||||
|
||||
# lasts ~9mn
|
||||
no-intrinsics-fuzztest:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: no intrinsics fuzztest
|
||||
run: MOREFLAGS="-DZSTD_NO_INTRINSICS" make -C tests fuzztest
|
||||
|
||||
# lasts ~8mn
|
||||
tsan-zstreamtest:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: thread sanitizer zstreamtest
|
||||
run: CC=clang ZSTREAM_TESTTIME=-T3mn make tsan-test-zstream
|
||||
|
||||
ubsan-zstreamtest:
|
||||
runs-on: ubuntu-20.04
|
||||
uasan-zstreamtest:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- name: undefined behavior sanitizer zstreamtest
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: ub + address sanitizer on zstreamtest
|
||||
run: CC=clang make uasan-test-zstream
|
||||
|
||||
# lasts ~15mn
|
||||
# lasts ~11mn
|
||||
tsan-fuzztest:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: thread sanitizer fuzztest
|
||||
run: CC=clang make tsan-fuzztest
|
||||
|
||||
|
||||
big-tests-zstreamtest32:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: zstream tests in 32bit mode, with big tests
|
||||
run: |
|
||||
sudo apt-get -qqq update
|
||||
make libc6install
|
||||
CC=clang make -C tests test-zstream32 FUZZER_FLAGS="--big-tests"
|
||||
|
||||
# lasts ~23mn
|
||||
# lasts ~13mn
|
||||
gcc-8-asan-ubsan-testzstd:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: gcc-8 + ASan + UBSan + Test Zstd
|
||||
# See https://askubuntu.com/a/1428822
|
||||
run: |
|
||||
@ -106,16 +121,16 @@ jobs:
|
||||
CC=gcc-8 make -j uasan-test-zstd </dev/null V=1
|
||||
|
||||
clang-asan-ubsan-testzstd:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: clang + ASan + UBSan + Test Zstd
|
||||
run: CC=clang make -j uasan-test-zstd </dev/null V=1
|
||||
|
||||
gcc-asan-ubsan-testzstd-32bit:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: ASan + UBSan + Test Zstd, 32bit mode
|
||||
run: |
|
||||
sudo apt-get -qqq update
|
||||
@ -127,9 +142,9 @@ jobs:
|
||||
# so any data coming from these libraries is always considered "uninitialized"
|
||||
|
||||
gcc-8-asan-ubsan-fuzz:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: gcc-8 + ASan + UBSan + Fuzz Test
|
||||
# See https://askubuntu.com/a/1428822
|
||||
run: |
|
||||
@ -139,57 +154,72 @@ jobs:
|
||||
CC=gcc-8 FUZZER_FLAGS="--long-tests" make clean uasan-fuzztest
|
||||
|
||||
clang-asan-ubsan-fuzz:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: clang + ASan + UBSan + Fuzz Test
|
||||
run: CC=clang FUZZER_FLAGS="--long-tests" make clean uasan-fuzztest
|
||||
|
||||
gcc-asan-ubsan-fuzz32:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: ASan + UBSan + Fuzz Test 32bit
|
||||
run: |
|
||||
sudo apt-get -qqq update
|
||||
make libc6install
|
||||
CFLAGS="-O3 -m32" FUZZER_FLAGS="--long-tests" make uasan-fuzztest
|
||||
|
||||
clang-asan-ubsan-fuzz32:
|
||||
runs-on: ubuntu-20.04
|
||||
clang-asan-fuzz32:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- name: clang + ASan + UBSan + Fuzz Test 32bit
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: clang + ASan + Fuzz Test 32bit
|
||||
run: |
|
||||
sudo apt-get -qqq update
|
||||
make libc6install
|
||||
CC=clang CFLAGS="-O3 -m32" FUZZER_FLAGS="--long-tests" make uasan-fuzztest
|
||||
CC=clang CFLAGS="-O3 -m32" FUZZER_FLAGS="--long-tests" make asan-fuzztest
|
||||
|
||||
# The following test seems to have issues on github CI specifically,
|
||||
# it does not provide the `__mulodi4` instruction emulation
|
||||
# required for signed 64-bit multiplication.
|
||||
# Replaced by asan-only test (above)
|
||||
#
|
||||
# clang-asan-ubsan-fuzz32:
|
||||
# runs-on: ubuntu-20.04
|
||||
# steps:
|
||||
# - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
# - name: clang + ASan + UBSan + Fuzz Test 32bit
|
||||
# run: |
|
||||
# sudo apt-get -qqq update
|
||||
# make libc6install
|
||||
# CC=clang CFLAGS="-O3 -m32" FUZZER_FLAGS="--long-tests" make uasan-fuzztest
|
||||
|
||||
asan-ubsan-regression:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: ASan + UBSan + Regression Test
|
||||
run: make -j uasanregressiontest
|
||||
|
||||
clang-ubsan-regression:
|
||||
runs-on: ubuntu-20.04
|
||||
clang-asan-ubsan-regression:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: clang + ASan + UBSan + Regression Test
|
||||
run: CC=clang make -j uasanregressiontest
|
||||
|
||||
msan-regression:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: MSan + Regression Test
|
||||
run: make -j msanregressiontest
|
||||
|
||||
clang-msan-fuzz-unoptimized:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: clang + MSan + Fuzz Test
|
||||
run: |
|
||||
sudo apt-get -qqq update
|
||||
@ -197,30 +227,27 @@ jobs:
|
||||
CC=clang MOREFLAGS="-O0" make clean msan-fuzztest
|
||||
|
||||
clang-msan-fuzz:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: clang + MSan + Fuzz Test
|
||||
run: |
|
||||
sudo apt-get -qqq update
|
||||
sudo apt-get install clang
|
||||
CC=clang FUZZER_FLAGS="--long-tests" make clean msan-fuzztest
|
||||
|
||||
# lasts ~24mn
|
||||
clang-msan-testzstd:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: clang + MSan + Test Zstd
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install clang
|
||||
CC=clang make msan-test-zstd HAVE_ZLIB=0 HAVE_LZ4=0 HAVE_LZMA=0 V=1
|
||||
CC=clang make -j msan-test-zstd HAVE_ZLIB=0 HAVE_LZ4=0 HAVE_LZMA=0 V=1
|
||||
|
||||
armfuzz:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Qemu ARM emulation + Fuzz Test
|
||||
run: |
|
||||
sudo apt-get -qqq update
|
||||
@ -230,7 +257,7 @@ jobs:
|
||||
valgrind-fuzz-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: valgrind + fuzz test stack mode # ~ 7mn
|
||||
shell: 'script -q -e -c "bash {0}"'
|
||||
run: |
|
||||
@ -246,8 +273,8 @@ jobs:
|
||||
run:
|
||||
shell: msys2 {0}
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: msys2/setup-msys2@cc11e9188b693c2b100158c3322424c4cc1dadea # tag=v2.22.0
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- uses: msys2/setup-msys2@40677d36a502eb2cf0fb808cc9dec31bf6152638 # tag=v2.28.0
|
||||
with:
|
||||
msystem: MINGW64
|
||||
install: make
|
||||
@ -269,7 +296,7 @@ jobs:
|
||||
|
||||
# lasts ~20mn
|
||||
oss-fuzz:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
303
.github/workflows/dev-short-tests.yml
vendored
303
.github/workflows/dev-short-tests.yml
vendored
@ -16,51 +16,40 @@ jobs:
|
||||
linux-kernel:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: linux kernel, library + build + test
|
||||
run: make -C contrib/linux-kernel test CFLAGS="-Werror -Wunused-const-variable -Wunused-but-set-variable"
|
||||
|
||||
benchmarking:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: make benchmarking
|
||||
run: make benchmarking
|
||||
|
||||
check-32bit: # designed to catch https://github.com/facebook/zstd/issues/2428
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: make check on 32-bit
|
||||
run: |
|
||||
sudo apt update
|
||||
APT_PACKAGES="gcc-multilib" make apt-install
|
||||
CFLAGS="-m32 -O1 -fstack-protector" make check V=1
|
||||
|
||||
check-x32:
|
||||
runs-on: ubuntu-20.04 # ubuntu-latest == ubuntu-22.04 have issues currently with x32
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- name: make check on x32 ABI # https://en.wikipedia.org/wiki/X32_ABI
|
||||
env:
|
||||
CHECK_CONSTRAINED_MEM: true
|
||||
run: |
|
||||
sudo apt update
|
||||
APT_PACKAGES="gcc-multilib" make apt-install
|
||||
CFLAGS="-mx32 -O1 -fstack-protector" make check V=1
|
||||
CFLAGS="-m32 -O1 -fstack-protector" make V=1 -C tests test-cli-tests
|
||||
|
||||
build-c89:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- name: ensure zstd can be build with c89/c90 compilers (+ long long support + variadic macros)
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: ensure zstd can be built with c89/c90 compilers (+ long long support + variadic macros)
|
||||
run: |
|
||||
make c89build V=1
|
||||
|
||||
build-zstd-dll:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: build zstd bin against a dynamic lib (debuglevel for more dependencies)
|
||||
run: |
|
||||
make -C lib lib-mt-release
|
||||
@ -69,7 +58,7 @@ jobs:
|
||||
gcc-7-libzstd:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: gcc-7 + libzstdmt compilation
|
||||
# See https://askubuntu.com/a/1428822
|
||||
run: |
|
||||
@ -83,18 +72,10 @@ jobs:
|
||||
# candidate test (for discussion) : underlink test
|
||||
# LDFLAGS=-Wl,--no-undefined : will make the linker fail if dll is underlinked
|
||||
|
||||
cmake-build-and-test-check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- name: cmake build and test
|
||||
run: |
|
||||
FUZZERTEST=-T1mn ZSTREAM_TESTTIME=-T1mn make cmakebuild V=1
|
||||
|
||||
cpp-gnu90-c99-compatibility:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: C++, gnu90 and c99 compatibility
|
||||
run: |
|
||||
make cxxtest
|
||||
@ -108,7 +89,7 @@ jobs:
|
||||
mingw-cross-compilation:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: mingw cross-compilation
|
||||
run: |
|
||||
# sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix; (doesn't work)
|
||||
@ -119,7 +100,7 @@ jobs:
|
||||
armbuild:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: ARM Build Test
|
||||
run: |
|
||||
sudo apt-get -qqq update
|
||||
@ -129,7 +110,7 @@ jobs:
|
||||
bourne-shell:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Bourne shell compatibility (shellcheck)
|
||||
run: |
|
||||
wget https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.linux.x86_64.tar.xz
|
||||
@ -139,21 +120,22 @@ jobs:
|
||||
zlib-wrapper:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- name: zlib wrapper test
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: install valgrind
|
||||
run: |
|
||||
sudo apt-get -qqq update
|
||||
make valgrindinstall
|
||||
make -C zlibWrapper test
|
||||
make -C zlibWrapper test-valgrind
|
||||
make valgrindinstall V=1
|
||||
- name: zlib wrapper test
|
||||
run: make -C zlibWrapper test V=1
|
||||
- name: zlib wrapper test under valgrind
|
||||
run: make -C zlibWrapper test-valgrind V=1
|
||||
|
||||
lz4-threadpool-libs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: LZ4, thread pool, and libs build testslib wrapper test
|
||||
run: |
|
||||
make lz4install
|
||||
make -C tests test-lz4
|
||||
make check < /dev/null | tee # mess with lz4 console detection
|
||||
make clean
|
||||
@ -161,20 +143,41 @@ jobs:
|
||||
make clean
|
||||
bash tests/libzstd_builds.sh
|
||||
|
||||
gcc-make-tests-32bit:
|
||||
gcc-make-all-avx2:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Make all, with AVX2
|
||||
run: |
|
||||
sudo apt-get -qqq update
|
||||
make libc6install
|
||||
CFLAGS="-Werror -mavx2" make -j all
|
||||
|
||||
gcc-make-all-32bit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Make all, 32bit mode
|
||||
run: |
|
||||
sudo apt-get -qqq update
|
||||
make libc6install
|
||||
CFLAGS="-Werror -m32" make -j all32
|
||||
|
||||
gcc-make-all-32bit-avx2:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Make all, 32bit + AVX2 mode
|
||||
run: |
|
||||
sudo apt-get -qqq update
|
||||
make libc6install
|
||||
CPPFLAGS="-DSTATIC_BMI2=1" CFLAGS="-Werror -m32 -mavx2 -mbmi2" make -j all32
|
||||
|
||||
|
||||
gcc-8-make:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: gcc-8 build
|
||||
# See https://askubuntu.com/a/1428822
|
||||
run: |
|
||||
@ -197,15 +200,17 @@ jobs:
|
||||
flags: "HAVE_ZLIB=0 HAVE_LZ4=0 HAVE_LZMA=1"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Build with ${{matrix.name}}
|
||||
run: ${{matrix.flags}} make zstd
|
||||
run: |
|
||||
sudo apt install liblzma-dev
|
||||
${{matrix.flags}} make zstd
|
||||
|
||||
|
||||
implicit-fall-through:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: -Wimplicit-fallthrough build
|
||||
run: |
|
||||
make clean
|
||||
@ -216,11 +221,11 @@ jobs:
|
||||
meson-linux:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Install packages
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install build-essential python3-pip ninja-build liblz4-dev
|
||||
sudo apt-get -y install build-essential python3-pip ninja-build liblz4-dev liblzma-dev
|
||||
pip install --pre meson
|
||||
- name: Build with Meson
|
||||
run: |
|
||||
@ -232,15 +237,59 @@ jobs:
|
||||
-Dbin_tests=true \
|
||||
-Dbin_contrib=true \
|
||||
-Ddefault_library=both \
|
||||
build/meson mesonBuild
|
||||
ninja -C mesonBuild/
|
||||
meson test -C mesonBuild/ --print-errorlogs
|
||||
meson install -C mesonBuild --destdir staging/
|
||||
|
||||
meson-mingw-cross-compilation:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Install packages
|
||||
run: |
|
||||
sudo apt-get -qqq update
|
||||
sudo apt-get -y install build-essential python3-pip ninja-build {gcc,g++}-mingw-w64-x86-64
|
||||
pip install --pre meson
|
||||
- name: Build with Meson
|
||||
run: |
|
||||
cat > cross.ini <<EOF
|
||||
[binaries]
|
||||
ar = 'x86_64-w64-mingw32-ar'
|
||||
c = 'x86_64-w64-mingw32-gcc'
|
||||
cpp = 'x86_64-w64-mingw32-g++'
|
||||
ld = 'x86_64-w64-mingw32-ld'
|
||||
objcopy = 'x86_64-w64-mingw32-objcopy'
|
||||
objdump = 'x86_64-w64-mingw32-objdump'
|
||||
strip = 'x86_64-w64-mingw32-strip'
|
||||
windres = 'x86_64-w64-mingw32-windres'
|
||||
|
||||
[host_machine]
|
||||
system = 'windows'
|
||||
endian = 'little'
|
||||
cpu_family = 'x86_64'
|
||||
cpu = 'x86_64'
|
||||
EOF
|
||||
|
||||
# pzstd doesn't build; skip -Dbin_contrib=true
|
||||
meson setup \
|
||||
--buildtype=debugoptimized \
|
||||
--cross-file=cross.ini \
|
||||
-Db_lundef=false \
|
||||
-Dbin_programs=true \
|
||||
-Dbin_tests=true \
|
||||
-Ddefault_library=both \
|
||||
build/meson builddir
|
||||
ninja -C builddir/
|
||||
meson test -C builddir/ --print-errorlogs
|
||||
meson install -C builddir --destdir staging/
|
||||
if grep -- -pthread builddir/meson-private/libzstd.pc; then
|
||||
echo "Error: found stray pthread dependency"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
meson-windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Install packages
|
||||
run: pip install --pre meson
|
||||
- name: Configure with Meson
|
||||
@ -256,32 +305,6 @@ jobs:
|
||||
run: |
|
||||
meson install -C builddir --destdir staging/
|
||||
|
||||
cmake-visual-2022:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- generator: "Visual Studio 17 2022"
|
||||
flags: "-A x64"
|
||||
- generator: "Visual Studio 17 2022"
|
||||
flags: "-A Win32"
|
||||
- generator: "MinGW Makefiles"
|
||||
- generator: "Visual Studio 17 2022"
|
||||
flags: "-T ClangCL"
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- name: Add MSBuild to PATH
|
||||
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # tag=v2.0.0
|
||||
- name: Build & Test
|
||||
working-directory: ${{env.GITHUB_WORKSPACE}}
|
||||
run: |
|
||||
cd build\cmake
|
||||
mkdir build
|
||||
cd build
|
||||
cmake.exe -G "${{matrix.generator}}" ${{matrix.flags}} -DCMAKE_BUILD_TYPE=Debug -DZSTD_BUILD_TESTS:BOOL=ON -DZSTD_ZSTREAM_FLAGS=-T30s -DZSTD_FUZZER_FLAGS=-T30s -DZSTD_FULLBENCH_FLAGS=-i0 ..
|
||||
cmake.exe --build .
|
||||
ctest.exe -V -C Debug
|
||||
|
||||
msbuild-visual-studio:
|
||||
strategy:
|
||||
fail-fast: false # 'false' means Don't stop matrix workflows even if some matrix failed.
|
||||
@ -297,7 +320,7 @@ jobs:
|
||||
]
|
||||
runs-on: ${{matrix.runner}}
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Add MSBuild to PATH
|
||||
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # tag=v2.0.0
|
||||
- name: Build ${{matrix.name}}
|
||||
@ -322,7 +345,7 @@ jobs:
|
||||
libzstd-size:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: libzstd size test
|
||||
run: |
|
||||
make clean && make -j -C lib libzstd && ./tests/check_size.py lib/libzstd.so 1100000
|
||||
@ -333,7 +356,7 @@ jobs:
|
||||
minimal-decompressor-macros:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: minimal decompressor macros
|
||||
run: |
|
||||
make clean && make -j all ZSTD_LIB_MINIFY=1 MOREFLAGS="-Werror"
|
||||
@ -350,7 +373,7 @@ jobs:
|
||||
dynamic-bmi2:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: dynamic bmi2 tests
|
||||
run: |
|
||||
make clean && make -j check MOREFLAGS="-O0 -Werror -mbmi2"
|
||||
@ -362,7 +385,7 @@ jobs:
|
||||
test-variants:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: make all variants & validate
|
||||
run: |
|
||||
make -j -C programs allVariants MOREFLAGS=-O0
|
||||
@ -370,13 +393,13 @@ jobs:
|
||||
|
||||
qemu-consistency:
|
||||
name: QEMU ${{ matrix.name }}
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false # 'false' means Don't stop matrix workflows even if some matrix failed.
|
||||
matrix:
|
||||
include: [
|
||||
{ name: ARM, xcc_pkg: gcc-arm-linux-gnueabi, xcc: arm-linux-gnueabi-gcc, xemu_pkg: qemu-system-arm, xemu: qemu-arm-static },
|
||||
{ name: ARM64, xcc_pkg: gcc-aarch64-linux-gnu, xcc: aarch64-linux-gnu-gcc, xemu_pkg: qemu-system-arm, xemu: qemu-aarch64-static },
|
||||
{ name: ARM64, xcc_pkg: gcc-aarch64-linux-gnu, xcc: aarch64-linux-gnu-gcc, xemu_pkg: qemu-system-aarch64,xemu: qemu-aarch64-static },
|
||||
{ name: PPC, xcc_pkg: gcc-powerpc-linux-gnu, xcc: powerpc-linux-gnu-gcc, xemu_pkg: qemu-system-ppc, xemu: qemu-ppc-static },
|
||||
{ name: PPC64LE, xcc_pkg: gcc-powerpc64le-linux-gnu, xcc: powerpc64le-linux-gnu-gcc, xemu_pkg: qemu-system-ppc, xemu: qemu-ppc64le-static },
|
||||
{ name: S390X, xcc_pkg: gcc-s390x-linux-gnu, xcc: s390x-linux-gnu-gcc, xemu_pkg: qemu-system-s390x, xemu: qemu-s390x-static },
|
||||
@ -389,7 +412,7 @@ jobs:
|
||||
XCC: ${{ matrix.xcc }}
|
||||
XEMU: ${{ matrix.xemu }}
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: apt update & install
|
||||
run: |
|
||||
sudo apt-get update
|
||||
@ -409,8 +432,15 @@ jobs:
|
||||
- name: ARM64
|
||||
if: ${{ matrix.name == 'ARM64' }}
|
||||
run: |
|
||||
LDFLAGS="-static -z force-bti" MOREFLAGS="-mbranch-protection=standard" CC=$XCC QEMU_SYS=$XEMU make clean check
|
||||
LDFLAGS="-static" CC=$XCC QEMU_SYS=$XEMU make clean check
|
||||
make clean
|
||||
LDFLAGS="-static" CC=$XCC QEMU_SYS=$XEMU make -j check
|
||||
LDFLAGS="-static" CC=$XCC QEMU_SYS=$XEMU make -j -C tests test-cli-tests
|
||||
CFLAGS="-march=armv8.2-a+sve2" LDFLAGS="-static" CC=$XCC QEMU_SYS=$XEMU make -j check
|
||||
CFLAGS="-march=armv8.2-a+sve2" LDFLAGS="-static" CC=$XCC QEMU_SYS=$XEMU make -j -C tests test-cli-tests
|
||||
# This test is only compatible with standard libraries that support BTI (Branch Target Identification).
|
||||
# Unfortunately, the standard library provided on Ubuntu 24.04 does not have this feature enabled.
|
||||
# make clean
|
||||
# LDFLAGS="-static -z force-bti" MOREFLAGS="-mbranch-protection=standard" CC=$XCC QEMU_SYS=$XEMU make check V=1
|
||||
- name: PPC
|
||||
if: ${{ matrix.name == 'PPC' }}
|
||||
run: |
|
||||
@ -454,8 +484,8 @@ jobs:
|
||||
run:
|
||||
shell: msys2 {0}
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: msys2/setup-msys2@cc11e9188b693c2b100158c3322424c4cc1dadea # tag=v2.22.0
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- uses: msys2/setup-msys2@40677d36a502eb2cf0fb808cc9dec31bf6152638 # tag=v2.28.0
|
||||
with:
|
||||
msystem: ${{ matrix.msystem }}
|
||||
install: make diffutils
|
||||
@ -490,7 +520,7 @@ jobs:
|
||||
platform: [x64, Win32]
|
||||
configuration: [Release]
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Add MSBuild to PATH
|
||||
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # tag=v2.0.0
|
||||
- name: Build and run tests
|
||||
@ -511,8 +541,8 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- run: git config --global core.autocrlf input
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: cygwin/cygwin-install-action@006ad0b0946ca6d0a3ea2d4437677fa767392401 # tag=master
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- uses: cygwin/cygwin-install-action@f61179d72284ceddc397ed07ddb444d82bf9e559 # tag=v5
|
||||
with:
|
||||
platform: x86_64
|
||||
packages: >-
|
||||
@ -532,13 +562,18 @@ jobs:
|
||||
make -j allzstd &&
|
||||
make -C tests fuzzer &&
|
||||
./tests/fuzzer.exe -v -T1m
|
||||
- name: cygwin install test
|
||||
shell: C:\cygwin\bin\bash.exe --noprofile --norc -eo pipefail '{0}'
|
||||
run: >-
|
||||
make -j &&
|
||||
make install
|
||||
|
||||
pkg-config:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: debian:testing
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt -y update
|
||||
@ -553,7 +588,7 @@ jobs:
|
||||
versions-compatibility:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Versions Compatibility Test
|
||||
run: |
|
||||
make -C tests versionsTest
|
||||
@ -561,27 +596,15 @@ jobs:
|
||||
clangbuild:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: make clangbuild
|
||||
run: |
|
||||
make clangbuild
|
||||
|
||||
clang-pgo:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- name: Build PGO Zstd with Clang
|
||||
env:
|
||||
CC: clang-14
|
||||
LLVM_PROFDATA: llvm-profdata-14
|
||||
run: |
|
||||
make -C programs zstd-pgo
|
||||
./programs/zstd -b
|
||||
|
||||
gcc-pgo:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Build PGO Zstd with GCC
|
||||
env:
|
||||
CC: gcc
|
||||
@ -589,10 +612,34 @@ jobs:
|
||||
make -C programs zstd-pgo
|
||||
./programs/zstd -b
|
||||
|
||||
clang-pgo:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Build PGO Zstd with Clang
|
||||
env:
|
||||
CC: clang
|
||||
run: |
|
||||
sudo apt install -y llvm
|
||||
llvm-profdata --version
|
||||
make -C programs zstd-pgo
|
||||
./programs/zstd -b
|
||||
|
||||
musl-build:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Install musl-tools
|
||||
run: |
|
||||
sudo apt install -y musl-tools
|
||||
- name: Compile with musl-gcc and test-zstd
|
||||
run: |
|
||||
CC=musl-gcc CFLAGS="-Werror -O3" CPPFLAGS=-DZDICT_QSORT=ZDICT_QSORT_C90 make -j -C tests test-zstd V=1
|
||||
|
||||
intel-cet-compatibility:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: Build Zstd
|
||||
run: |
|
||||
make -j zstd V=1
|
||||
@ -608,26 +655,24 @@ jobs:
|
||||
run: |
|
||||
sde-external-9.33.0-2024-01-07-lin/sde -cet -cet-raise 0 -cet-endbr-exe -cet-stderr -cet-abort -- ./zstd -b3
|
||||
|
||||
icx:
|
||||
# install instructions: https://www.intel.com/content/www/us/en/docs/oneapi/installation-guide-linux/2025-0/apt-005.html
|
||||
name: icx-check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: install icx
|
||||
run: |
|
||||
# download the key to system keyring
|
||||
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
|
||||
| gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
|
||||
|
||||
# Failing tests, for reference
|
||||
|
||||
# icc tests are currently failing on Github Actions, likely to issues during installation stage
|
||||
#
|
||||
# icc:
|
||||
# name: icc-check
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - name: install icc
|
||||
# run: |
|
||||
# export DEBIAN_FRONTEND=noninteractive
|
||||
# sudo apt-get -qqq update
|
||||
# sudo apt-get install -y wget build-essential pkg-config cmake ca-certificates gnupg
|
||||
# sudo wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
|
||||
# sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
|
||||
# sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
|
||||
# sudo apt-get update
|
||||
# sudo apt-get install -y intel-basekit intel-hpckit
|
||||
# - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
|
||||
# - name: make check
|
||||
# run: |
|
||||
# make CC=/opt/intel/oneapi/compiler/latest/linux/bin/intel64/icc check
|
||||
# add signed entry to apt sources and configure the APT client to use Intel repository:
|
||||
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y intel-basekit intel-hpckit
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- name: make check
|
||||
run: |
|
||||
source /opt/intel/oneapi/setvars.sh
|
||||
make CC=icx check
|
||||
make CC=icx -C tests test-cli-tests
|
||||
|
39
.github/workflows/nightly.yml
vendored
39
.github/workflows/nightly.yml
vendored
@ -1,51 +1,24 @@
|
||||
name: facebook/zstd/nightly
|
||||
on:
|
||||
schedule:
|
||||
- cron: 0 0 * * *
|
||||
- cron: '0 0 * * *'
|
||||
push:
|
||||
branches:
|
||||
- release
|
||||
- dev
|
||||
- master
|
||||
- release
|
||||
- dev
|
||||
- '*nightly*'
|
||||
permissions: read-all
|
||||
jobs:
|
||||
regression-test:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
docker:
|
||||
image: fbopensource/zstd-circleci-primary:0.0.1
|
||||
options: --entrypoint /bin/bash
|
||||
env:
|
||||
CIRCLE_ARTIFACTS: "/tmp/circleci-artifacts"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
key: regression-cache-{{ checksum "tests/regression/data.c" }}-v0
|
||||
path: tests/regression/cache
|
||||
restore-keys: regression-cache-{{ checksum "tests/regression/data.c" }}-v0
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
path: "/tmp/circleci-artifacts"
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install libcurl4-gnutls-dev
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
|
||||
- name: Regression Test
|
||||
run: |
|
||||
make -C programs zstd
|
||||
make -C tests/regression test
|
||||
mkdir -p $CIRCLE_ARTIFACTS
|
||||
./tests/regression/test \
|
||||
--cache tests/regression/cache \
|
||||
--output $CIRCLE_ARTIFACTS/results.csv \
|
||||
--zstd programs/zstd
|
||||
echo "NOTE: The new results.csv is uploaded as an artifact to this job"
|
||||
echo " If this fails, go to the Artifacts pane in CircleCI, "
|
||||
echo " download /tmp/circleci-artifacts/results.csv, and if they "
|
||||
echo " are still good, copy it into the repo and commit it."
|
||||
echo "> diff tests/regression/results.csv $CIRCLE_ARTIFACTS/results.csv"
|
||||
diff tests/regression/results.csv $CIRCLE_ARTIFACTS/results.csv
|
||||
|
||||
# Longer tests
|
||||
#- make -C tests test-zstd-nolegacy && make clean
|
||||
|
@ -17,7 +17,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v3
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
|
||||
- name: Archive
|
||||
env:
|
||||
|
64
.github/workflows/release_check.yml
vendored
Normal file
64
.github/workflows/release_check.yml
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
name: release_checks
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- release
|
||||
pull_request:
|
||||
branches:
|
||||
- release
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
verify-manual:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Save current manual
|
||||
run: mv doc/zstd_manual.html doc/zstd_manual_saved.html
|
||||
|
||||
- name: Generate new manual
|
||||
run: make manual
|
||||
|
||||
- name: Compare manuals
|
||||
run: |
|
||||
if ! cmp -s doc/zstd_manual.html doc/zstd_manual_saved.html; then
|
||||
echo "The API manual was not updated before release !"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
verify-man-pages:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ruby ruby-dev
|
||||
sudo gem install ronn
|
||||
|
||||
- name: Display ronn version
|
||||
run: ronn --version
|
||||
|
||||
- name: Save current man pages
|
||||
run: |
|
||||
mv programs/zstd.1 programs/zstd.1.saved
|
||||
mv programs/zstdgrep.1 programs/zstdgrep.1.saved
|
||||
mv programs/zstdless.1 programs/zstdless.1.saved
|
||||
|
||||
- name: Generate new manual pages
|
||||
run: make -C programs man
|
||||
|
||||
- name: Compare man pages
|
||||
run: |
|
||||
for file in zstd.1 zstdgrep.1 zstdless.1; do
|
||||
if ! cmp -s programs/$file programs/$file.saved; then
|
||||
echo "The man page $file should have been updated."
|
||||
exit 1
|
||||
fi
|
||||
done
|
6
.github/workflows/scorecards.yml
vendored
6
.github/workflows/scorecards.yml
vendored
@ -27,12 +27,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v3
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # tag=v2.3.1
|
||||
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # tag=v2.4.1
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
@ -59,6 +59,6 @@ jobs:
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@3ab4101902695724f9365a384f86c1074d94e18c # tag=v3.24.7
|
||||
uses: github/codeql-action/upload-sarif@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # tag=v3.28.9
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
47
.github/workflows/windows-artifacts.yml
vendored
47
.github/workflows/windows-artifacts.yml
vendored
@ -2,7 +2,7 @@ name: windows-artifacts
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ test_artifacts, win_artifacts ]
|
||||
branches: [ test_artifacts, win_artifacts, release ]
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
@ -11,6 +11,8 @@ permissions: read-all
|
||||
|
||||
jobs:
|
||||
windows-artifacts:
|
||||
permissions:
|
||||
contents: write # to fetch code and upload artifacts
|
||||
# see https://ariya.io/2020/07/on-github-actions-with-msys2
|
||||
runs-on: windows-latest
|
||||
# see https://github.com/msys2/setup-msys2
|
||||
@ -23,11 +25,11 @@ jobs:
|
||||
run:
|
||||
shell: msys2 {0}
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v3
|
||||
- uses: msys2/setup-msys2@5beef6d11f48bba68b9eb503e3adc60b23c0cc36 # tag=v2
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
|
||||
- uses: msys2/setup-msys2@40677d36a502eb2cf0fb808cc9dec31bf6152638 # tag=v2.28.0
|
||||
with:
|
||||
msystem: ${{ matrix.msystem }}
|
||||
install: make zlib git p7zip mingw-w64-${{matrix.env}}-gcc
|
||||
install: make p7zip git mingw-w64-${{matrix.env}}-gcc
|
||||
update: true
|
||||
|
||||
- name: display versions
|
||||
@ -37,22 +39,43 @@ jobs:
|
||||
|
||||
- name: Building zlib to static link
|
||||
run: |
|
||||
git clone --depth 1 --branch v1.2.11 https://github.com/madler/zlib
|
||||
git clone --depth 1 --branch v1.3.1 https://github.com/madler/zlib
|
||||
make -C zlib -f win32/Makefile.gcc libz.a
|
||||
|
||||
- name: Building lz4 to static link
|
||||
run: |
|
||||
git clone --depth 1 --branch v1.10.0 https://github.com/lz4/lz4
|
||||
# ensure both libraries use the same version of libxxhash
|
||||
cp lib/common/xxhash.* lz4/lib
|
||||
CPPFLAGS=-DXXH_NAMESPACE=LZ4_ make -C lz4/lib liblz4.a V=1
|
||||
|
||||
- name: Building zstd programs
|
||||
run: |
|
||||
CPPFLAGS=-I../zlib LDFLAGS=../zlib/libz.a make -j allzstd MOREFLAGS=-static V=1
|
||||
CPPFLAGS="-I../zlib -I../lz4/lib" LDFLAGS=-static make -j allzstd V=1 HAVE_ZLIB=1 HAVE_LZ4=1 HAVE_LZMA=0 LDLIBS="../zlib/libz.a ../lz4/lib/liblz4.a"
|
||||
|
||||
- name: Create artifacts
|
||||
run: |
|
||||
./lib/dll/example/build_package.bat
|
||||
./lib/dll/example/build_package.bat || exit 1
|
||||
mv bin/ zstd-${{ github.ref_name }}-${{matrix.ziparch}}/
|
||||
7z a -tzip -mx9 zstd-${{ github.ref_name }}-${{matrix.ziparch}}.zip zstd-${{ github.ref_name }}-${{matrix.ziparch}}/
|
||||
cd ..
|
||||
|
||||
- name: Publish zstd-$VERSION-${{matrix.ziparch}}.zip
|
||||
- name: Publish zstd-$VERSION-${{matrix.ziparch}}.zip for manual inspection
|
||||
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # tag=v4.3.1
|
||||
with:
|
||||
path: ${{ github.workspace }}/zstd-${{ github.ref_name }}-${{matrix.ziparch}}.zip
|
||||
name: zstd-${{ github.ref_name }}-${{matrix.ziparch}}.zip
|
||||
compression-level: 9 # maximum compression
|
||||
if-no-files-found: error # defaults to `warn`
|
||||
path: ${{ github.workspace }}/zstd-${{ github.ref_name }}-${{matrix.ziparch}}/
|
||||
name: zstd-${{ github.ref_name }}-${{matrix.ziparch}}
|
||||
|
||||
- name: Package artifact for upload
|
||||
run: |
|
||||
7z a -tzip -mx9 "$(cygpath -u '${{ github.workspace }}/zstd-${{ github.ref_name }}-${{ matrix.ziparch }}.zip')" "$(cygpath -u '${{ github.workspace }}/zstd-${{ github.ref_name }}-${{ matrix.ziparch }}')"
|
||||
|
||||
- name: Upload release asset
|
||||
if: github.event_name == 'release'
|
||||
shell: pwsh
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
gh release upload "${{ github.ref_name }}" "$env:GITHUB_WORKSPACE/zstd-${{ github.ref_name }}-${{ matrix.ziparch }}.zip" --clobber
|
||||
|
||||
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -12,6 +12,8 @@
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
*.framework
|
||||
*.xcframework
|
||||
|
||||
# Executables
|
||||
/zstd
|
||||
|
30
CHANGELOG
30
CHANGELOG
@ -1,9 +1,35 @@
|
||||
V1.5.7 (Feb 2025)
|
||||
fix: compression bug in 32-bit mode associated with long-lasting sessions
|
||||
api: new method `ZSTD_compressSequencesAndLiterals()` (#4217, #4232)
|
||||
api: `ZSTD_getFrameHeader()` works on skippable frames (#4228)
|
||||
perf: substantial compression speed improvements (up to +30%) on small data, by @TocarIP (#4144) and @cyan4973 (#4165)
|
||||
perf: improved compression speed (~+5%) for dictionary compression at low levels (#4170)
|
||||
perf: much faster speed for `--patch-from` at high compression levels (#4276)
|
||||
perf: higher `--patch-from` compression ratios, notably at high levels (#4288)
|
||||
perf: better speed for binaries on Windows (@pps83) and when compiled with Visual Studio (@MessyHack)
|
||||
perf: slight compression ratio improvement thanks to better block boundaries (#4136, #4176, #4178)
|
||||
perf: slight compression ratio improvement for `dfast`, aka levels 3 and 4 (#4171)
|
||||
perf: runtime bmi2 detection enabled on x86 32-bit mode (#4251)
|
||||
cli: multi-threading as default CLI setting, by @daniellerozenblit
|
||||
cli: new `--max` command (#4290)
|
||||
build: improve `msbuild` version autodetection, support VS2022, by @ManuelBlanc
|
||||
build: fix `meson` build by @artem and @Victor-C-Zhang, and on Windows by @bgilbert
|
||||
build: compatibility with Apple Framework, by @Treata11
|
||||
build: improve icc/icx compatibility, by @josepho0918 and @luau-project
|
||||
build: improve compatibility with Android NDK, by Adenilson Cavalcanti
|
||||
portability: linux kernel branch, with improved support for Sequence producers (@embg, @gcabiddu, @cyan4973)
|
||||
portability: improved qnx compatibility, suggested by @rainbowball
|
||||
portability: improved install script for FreeBSD, by @sunpoet
|
||||
portability: fixed test suite compatibility with gnu hurd, by @diegonc
|
||||
doc: clarify specification, by @elasota
|
||||
misc: improved tests/decodecorpus validation tool (#4102), by antmicro
|
||||
|
||||
V1.5.6 (Mar 2024)
|
||||
api: Promote `ZSTD_c_targetCBlockSize` to Stable API by @felixhandte
|
||||
api: new `ZSTD_d_maxBlockSize` experimental parameter, to reduce streaming decompression memory, by @terrelln
|
||||
perf: improve performance of param `ZSTD_c_targetCBlockSize`, by @Cyan4973
|
||||
perf: improved compression of arrays of integers at high compression, by @Cyan4973
|
||||
lib: reduce binary size with selective built-time exclusion, by @felixhandte
|
||||
lib: reduce binary size with selective build-time exclusion, by @felixhandte
|
||||
lib: improved huffman speed on small data and linux kernel, by @terrelln
|
||||
lib: accept dictionaries with partial literal tables, by @terrelln
|
||||
lib: fix CCtx size estimation with external sequence producer, by @embg
|
||||
@ -489,7 +515,7 @@ misc: added /contrib/docker script by @gyscos
|
||||
|
||||
v1.3.3 (Dec 21, 2017)
|
||||
perf: faster zstd_opt strategy (levels 16-19)
|
||||
fix : bug #944 : multithreading with shared ditionary and large data, reported by @gsliepen
|
||||
fix : bug #944 : multithreading with shared dictionary and large data, reported by @gsliepen
|
||||
cli : fix : content size written in header by default
|
||||
cli : fix : improved LZ4 format support, by @felixhandte
|
||||
cli : new : hidden command `-S`, to benchmark multiple files while generating one result per file
|
||||
|
@ -60,7 +60,7 @@ Our contribution process works in three main stages:
|
||||
* Note: run local tests to ensure that your changes didn't break existing functionality
|
||||
* Quick check
|
||||
```
|
||||
make shortest
|
||||
make check
|
||||
```
|
||||
* Longer check
|
||||
```
|
||||
|
56
Makefile
56
Makefile
@ -85,14 +85,10 @@ test:
|
||||
$(MAKE) -C $(TESTDIR) $@
|
||||
ZSTD=../../programs/zstd $(MAKE) -C doc/educational_decoder $@
|
||||
|
||||
## shortest: same as `make check`
|
||||
.PHONY: shortest
|
||||
shortest:
|
||||
$(Q)$(MAKE) -C $(TESTDIR) $@
|
||||
|
||||
## check: run basic tests for `zstd` cli
|
||||
.PHONY: check
|
||||
check: shortest
|
||||
check:
|
||||
$(Q)$(MAKE) -C $(TESTDIR) $@
|
||||
|
||||
.PHONY: automated_benchmarking
|
||||
automated_benchmarking:
|
||||
@ -145,13 +141,13 @@ clean:
|
||||
$(Q)$(MAKE) -C contrib/largeNbDicts $@ > $(VOID)
|
||||
$(Q)$(MAKE) -C contrib/externalSequenceProducer $@ > $(VOID)
|
||||
$(Q)$(RM) zstd$(EXT) zstdmt$(EXT) tmp*
|
||||
$(Q)$(RM) -r lz4 cmakebuild install
|
||||
$(Q)$(RM) -r lz4 cmakebuild mesonbuild install
|
||||
@echo Cleaning completed
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# make install is validated only for Linux, macOS, Hurd and some BSD targets
|
||||
#------------------------------------------------------------------------------
|
||||
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD DragonFly NetBSD MSYS_NT CYGWIN_NT Haiku AIX))
|
||||
ifneq (,$(filter Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD DragonFly NetBSD MSYS_NT% CYGWIN_NT% Haiku AIX,$(shell sh -c 'MSYSTEM="MSYS" uname') ))
|
||||
|
||||
HOST_OS = POSIX
|
||||
|
||||
@ -200,9 +196,9 @@ travis-install:
|
||||
.PHONY: clangbuild-darwin-fat
|
||||
clangbuild-darwin-fat: clean
|
||||
clang -v
|
||||
CXX=clang++ CC=clang CFLAGS="-Werror -Wconversion -Wno-sign-conversion -Wdocumentation -arch arm64" $(MAKE) zstd-release
|
||||
CXX=clang++ CC=clang CFLAGS+="-Werror -Wconversion -Wno-sign-conversion -Wdocumentation -arch arm64" $(MAKE) zstd-release
|
||||
mv programs/zstd programs/zstd_arm64
|
||||
CXX=clang++ CC=clang CFLAGS="-Werror -Wconversion -Wno-sign-conversion -Wdocumentation -arch x86_64" $(MAKE) zstd-release
|
||||
CXX=clang++ CC=clang CFLAGS+="-Werror -Wconversion -Wno-sign-conversion -Wdocumentation -arch x86_64" $(MAKE) zstd-release
|
||||
mv programs/zstd programs/zstd_x64
|
||||
lipo -create programs/zstd_x64 programs/zstd_arm64 -output programs/zstd
|
||||
|
||||
@ -293,16 +289,16 @@ regressiontest:
|
||||
$(MAKE) -C $(FUZZDIR) regressiontest
|
||||
|
||||
uasanregressiontest:
|
||||
$(MAKE) -C $(FUZZDIR) regressiontest CC=clang CXX=clang++ CFLAGS="-O3 -fsanitize=address,undefined" CXXFLAGS="-O3 -fsanitize=address,undefined"
|
||||
$(MAKE) -C $(FUZZDIR) regressiontest CC=clang CXX=clang++ CFLAGS="-O3 -fsanitize=address,undefined -Werror" CXXFLAGS="-O3 -fsanitize=address,undefined -Werror"
|
||||
|
||||
msanregressiontest:
|
||||
$(MAKE) -C $(FUZZDIR) regressiontest CC=clang CXX=clang++ CFLAGS="-O3 -fsanitize=memory" CXXFLAGS="-O3 -fsanitize=memory"
|
||||
$(MAKE) -C $(FUZZDIR) regressiontest CC=clang CXX=clang++ CFLAGS="-O3 -fsanitize=memory -Werror" CXXFLAGS="-O3 -fsanitize=memory -Werror"
|
||||
|
||||
update_regressionResults : REGRESS_RESULTS_DIR := /tmp/regress_results_dir/
|
||||
update_regressionResults:
|
||||
$(MAKE) -C programs zstd
|
||||
$(MAKE) -C tests/regression test
|
||||
$(RM) -rf $(REGRESS_RESULTS_DIR)
|
||||
$(MAKE) -j -C programs zstd
|
||||
$(MAKE) -j -C tests/regression test
|
||||
$(RM) -r $(REGRESS_RESULTS_DIR)
|
||||
$(MKDIR) $(REGRESS_RESULTS_DIR)
|
||||
./tests/regression/test \
|
||||
--cache tests/regression/cache \
|
||||
@ -355,7 +351,7 @@ apt-add-repo:
|
||||
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||
sudo apt-get update -y -qq
|
||||
|
||||
.PHONY: ppcinstall arminstall valgrindinstall libc6install gcc6install gcc7install gcc8install gpp6install clang38install lz4install
|
||||
.PHONY: ppcinstall arminstall valgrindinstall libc6install gcc6install gcc7install gcc8install gpp6install clang38install
|
||||
ppcinstall:
|
||||
APT_PACKAGES="qemu-system-ppc qemu-user-static gcc-powerpc-linux-gnu" $(MAKE) apt-install
|
||||
|
||||
@ -383,26 +379,22 @@ gpp6install: apt-add-repo
|
||||
clang38install:
|
||||
APT_PACKAGES="clang-3.8" $(MAKE) apt-install
|
||||
|
||||
# Ubuntu 14.04 ships a too-old lz4
|
||||
lz4install:
|
||||
[ -e lz4 ] || git clone https://github.com/lz4/lz4 && sudo $(MAKE) -C lz4 install
|
||||
|
||||
endif
|
||||
|
||||
|
||||
ifneq (,$(filter MSYS%,$(shell uname)))
|
||||
ifneq (,$(filter MSYS%,$(shell sh -c 'MSYSTEM="MSYS" uname') ))
|
||||
HOST_OS = MSYS
|
||||
endif
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# target specific tests
|
||||
#------------------------------------------------------------------------
|
||||
ifneq (,$(filter $(HOST_OS),MSYS POSIX))
|
||||
ifneq (,$(filter MSYS POSIX,$(HOST_OS)))
|
||||
|
||||
CMAKE ?= cmake
|
||||
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
|
||||
|
||||
ifneq (,$(filter MSYS%,$(shell uname)))
|
||||
ifneq (,$(filter MSYS%,$(shell sh -c 'MSYSTEM="MSYS" uname')))
|
||||
CMAKE_PARAMS = -G"MSYS Makefiles" -DZSTD_MULTITHREAD_SUPPORT:BOOL=OFF -DZSTD_BUILD_STATIC:BOOL=ON -DZSTD_BUILD_TESTS:BOOL=ON
|
||||
endif
|
||||
|
||||
@ -415,6 +407,24 @@ cmakebuild:
|
||||
$(CMAKE) --build cmakebuild --target install -- -j V=1
|
||||
cd cmakebuild; ctest -V -L Medium
|
||||
|
||||
MESON ?= meson
|
||||
NINJA ?= ninja
|
||||
|
||||
.PHONY: mesonbuild
|
||||
mesonbuild:
|
||||
$(MESON) setup \
|
||||
--buildtype=debugoptimized \
|
||||
-Db_lundef=false \
|
||||
-Dauto_features=enabled \
|
||||
-Dbin_programs=true \
|
||||
-Dbin_tests=true \
|
||||
-Dbin_contrib=true \
|
||||
-Ddefault_library=both \
|
||||
build/meson mesonbuild
|
||||
$(NINJA) -C mesonbuild/
|
||||
$(MESON) test -C mesonbuild/ --print-errorlogs
|
||||
$(MESON) install -C mesonbuild --destdir staging/
|
||||
|
||||
.PHONY: c89build gnu90build c99build gnu99build c11build bmix64build bmix32build bmi32build staticAnalyze
|
||||
c89build: clean
|
||||
$(CC) -v
|
||||
|
40
README.md
40
README.md
@ -29,10 +29,10 @@ a list of known ports and bindings is provided on [Zstandard homepage](https://f
|
||||
## Benchmarks
|
||||
|
||||
For reference, several fast compression algorithms were tested and compared
|
||||
on a desktop running Ubuntu 20.04 (`Linux 5.11.0-41-generic`),
|
||||
with a Core i7-9700K CPU @ 4.9GHz,
|
||||
on a desktop featuring a Core i7-9700K CPU @ 4.9GHz
|
||||
and running Ubuntu 24.04 (`Linux 6.8.0-53-generic`),
|
||||
using [lzbench], an open-source in-memory benchmark by @inikep
|
||||
compiled with [gcc] 9.3.0,
|
||||
compiled with [gcc] 14.2.0,
|
||||
on the [Silesia compression corpus].
|
||||
|
||||
[lzbench]: https://github.com/inikep/lzbench
|
||||
@ -41,24 +41,23 @@ on the [Silesia compression corpus].
|
||||
|
||||
| Compressor name | Ratio | Compression| Decompress.|
|
||||
| --------------- | ------| -----------| ---------- |
|
||||
| **zstd 1.5.1 -1** | 2.887 | 530 MB/s | 1700 MB/s |
|
||||
| [zlib] 1.2.11 -1 | 2.743 | 95 MB/s | 400 MB/s |
|
||||
| brotli 1.0.9 -0 | 2.702 | 395 MB/s | 450 MB/s |
|
||||
| **zstd 1.5.1 --fast=1** | 2.437 | 600 MB/s | 2150 MB/s |
|
||||
| **zstd 1.5.1 --fast=3** | 2.239 | 670 MB/s | 2250 MB/s |
|
||||
| quicklz 1.5.0 -1 | 2.238 | 540 MB/s | 760 MB/s |
|
||||
| **zstd 1.5.1 --fast=4** | 2.148 | 710 MB/s | 2300 MB/s |
|
||||
| lzo1x 2.10 -1 | 2.106 | 660 MB/s | 845 MB/s |
|
||||
| [lz4] 1.9.3 | 2.101 | 740 MB/s | 4500 MB/s |
|
||||
| lzf 3.6 -1 | 2.077 | 410 MB/s | 830 MB/s |
|
||||
| snappy 1.1.9 | 2.073 | 550 MB/s | 1750 MB/s |
|
||||
| **zstd 1.5.7 -1** | 2.896 | 510 MB/s | 1550 MB/s |
|
||||
| brotli 1.1.0 -1 | 2.883 | 290 MB/s | 425 MB/s |
|
||||
| [zlib] 1.3.1 -1 | 2.743 | 105 MB/s | 390 MB/s |
|
||||
| **zstd 1.5.7 --fast=1** | 2.439 | 545 MB/s | 1850 MB/s |
|
||||
| quicklz 1.5.0 -1 | 2.238 | 520 MB/s | 750 MB/s |
|
||||
| **zstd 1.5.7 --fast=4** | 2.146 | 665 MB/s | 2050 MB/s |
|
||||
| lzo1x 2.10 -1 | 2.106 | 650 MB/s | 780 MB/s |
|
||||
| [lz4] 1.10.0 | 2.101 | 675 MB/s | 3850 MB/s |
|
||||
| snappy 1.2.1 | 2.089 | 520 MB/s | 1500 MB/s |
|
||||
| lzf 3.6 -1 | 2.077 | 410 MB/s | 820 MB/s |
|
||||
|
||||
[zlib]: https://www.zlib.net/
|
||||
[lz4]: https://lz4.github.io/lz4/
|
||||
|
||||
The negative compression levels, specified with `--fast=#`,
|
||||
offer faster compression and decompression speed
|
||||
at the cost of compression ratio (compared to level 1).
|
||||
at the cost of compression ratio.
|
||||
|
||||
Zstd can also offer stronger compression ratios at the cost of compression speed.
|
||||
Speed vs Compression trade-off is configurable by small increments.
|
||||
@ -185,6 +184,17 @@ You can build and install zstd [vcpkg](https://github.com/Microsoft/vcpkg/) depe
|
||||
The zstd port in vcpkg is kept up to date by Microsoft team members and community contributors.
|
||||
If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||
|
||||
### Conan
|
||||
|
||||
You can install pre-built binaries for zstd or build it from source using [Conan](https://conan.io/). Use the following command:
|
||||
|
||||
```bash
|
||||
conan install --requires="zstd/[*]" --build=missing
|
||||
```
|
||||
|
||||
The zstd Conan recipe is kept up to date by Conan maintainers and community contributors.
|
||||
If the version is out of date, please [create an issue or pull request](https://github.com/conan-io/conan-center-index) on the ConanCenterIndex repository.
|
||||
|
||||
### Visual Studio (Windows)
|
||||
|
||||
Going into `build` directory, you will find additional possibilities:
|
||||
|
@ -1,189 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{00000000-1CC8-4FD7-9281-6B8DBB9D3DF8}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>fullbench-dll</RootNamespace>
|
||||
<OutDir>$(SolutionDir)bin\$(Platform)_$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>$(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath);</IncludePath>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>$(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath);</IncludePath>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>$(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath);</IncludePath>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>$(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath);</IncludePath>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;ZSTD_DLL_IMPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<EnablePREfast>false</EnablePREfast>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>libzstd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;ZSTD_DLL_IMPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<EnablePREfast>false</EnablePREfast>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>libzstd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;ZSTD_DLL_IMPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<EnablePREfast>false</EnablePREfast>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>libzstd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;ZSTD_DLL_IMPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<EnablePREfast>false</EnablePREfast>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>libzstd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\lib\common\xxhash.c" />
|
||||
<ClCompile Include="..\..\..\programs\util.c" />
|
||||
<ClCompile Include="..\..\..\programs\timefn.c" />
|
||||
<ClCompile Include="..\..\..\programs\datagen.c" />
|
||||
<ClCompile Include="..\..\..\programs\benchfn.c" />
|
||||
<ClCompile Include="..\..\..\tests\fullbench.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\lib\zstd.h" />
|
||||
<ClInclude Include="..\..\..\programs\datagen.h" />
|
||||
<ClInclude Include="..\..\..\programs\benchfn.h" />
|
||||
<ClInclude Include="..\..\..\programs\util.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\libzstd-dll\libzstd-dll.vcxproj">
|
||||
<Project>{00000000-94d5-4bf9-8a50-7bd9929a0850}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -170,6 +170,7 @@
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_compress_literals.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_compress_sequences.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_compress_superblock.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_preSplit.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstdmt_compress.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_fast.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_double_fast.c" />
|
||||
@ -183,6 +184,7 @@
|
||||
<ClCompile Include="..\..\..\programs\util.c" />
|
||||
<ClCompile Include="..\..\..\programs\timefn.c" />
|
||||
<ClCompile Include="..\..\..\programs\datagen.c" />
|
||||
<ClCompile Include="..\..\..\programs\lorem.c" />
|
||||
<ClCompile Include="..\..\..\programs\benchfn.c" />
|
||||
<ClCompile Include="..\..\..\tests\fullbench.c" />
|
||||
</ItemGroup>
|
||||
|
@ -170,6 +170,7 @@
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_compress_literals.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_compress_sequences.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_compress_superblock.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_preSplit.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_fast.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_double_fast.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_lazy.c" />
|
||||
|
@ -34,6 +34,7 @@
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_compress_literals.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_compress_sequences.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_compress_superblock.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_preSplit.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_fast.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_double_fast.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_lazy.c" />
|
||||
|
@ -34,6 +34,7 @@
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_compress_literals.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_compress_sequences.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_compress_superblock.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_preSplit.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_fast.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_double_fast.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_lazy.c" />
|
||||
|
@ -7,11 +7,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fuzzer", "fuzzer\fuzzer.vcx
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fullbench", "fullbench\fullbench.vcxproj", "{61ABD629-1CC8-4FD7-9281-6B8DBB9D3DF8}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fullbench-dll", "fullbench-dll\fullbench-dll.vcxproj", "{00000000-1CC8-4FD7-9281-6B8DBB9D3DF8}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{00000000-94D5-4BF9-8A50-7BD9929A0850} = {00000000-94D5-4BF9-8A50-7BD9929A0850}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "datagen", "datagen\datagen.vcxproj", "{037E781E-81A6-494B-B1B3-438AB1200523}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libzstd", "libzstd\libzstd.vcxproj", "{8BFD8150-94D5-4BF9-8A50-7BD9929A0850}"
|
||||
|
@ -35,6 +35,7 @@
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_compress_literals.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_compress_sequences.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_compress_superblock.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_preSplit.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_fast.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_double_fast.c" />
|
||||
<ClCompile Include="..\..\..\lib\compress\zstd_lazy.c" />
|
||||
|
7
build/VS_scripts/build.VSPreview.cmd
Normal file
7
build/VS_scripts/build.VSPreview.cmd
Normal file
@ -0,0 +1,7 @@
|
||||
@echo off
|
||||
|
||||
rem build 32-bit
|
||||
call "%~p0%build.generic.cmd" preview Win32 Release v143
|
||||
|
||||
rem build 64-bit
|
||||
call "%~p0%build.generic.cmd" preview x64 Release v143
|
@ -2,7 +2,7 @@
|
||||
|
||||
IF "%1%" == "" GOTO display_help
|
||||
|
||||
SETLOCAL
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
|
||||
SET msbuild_version=%1
|
||||
|
||||
@ -19,39 +19,34 @@ GOTO build
|
||||
:display_help
|
||||
|
||||
echo Syntax: build.generic.cmd msbuild_version msbuild_platform msbuild_configuration msbuild_toolset
|
||||
echo msbuild_version: VS installed version (VS2012, VS2013, VS2015, VS2017, VS2019, ...)
|
||||
echo msbuild_version: VS installed version (latest, VS2012, VS2013, VS2015, VS2017, VS2019, VS2022, ...)
|
||||
echo msbuild_platform: Platform (x64 or Win32)
|
||||
echo msbuild_configuration: VS configuration (Release or Debug)
|
||||
echo msbuild_toolset: Platform Toolset (v100, v110, v120, v140, v141, v142, ...)
|
||||
echo msbuild_toolset: Platform Toolset (v100, v110, v120, v140, v141, v142, v143, ...)
|
||||
|
||||
EXIT /B 1
|
||||
|
||||
:build
|
||||
|
||||
SET msbuild="%windir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"
|
||||
SET msbuild_vs2017community="%programfiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe"
|
||||
SET msbuild_vs2017professional="%programfiles(x86)%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe"
|
||||
SET msbuild_vs2017enterprise="%programfiles(x86)%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe"
|
||||
IF %msbuild_version% == VS2013 SET msbuild="%programfiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe"
|
||||
IF %msbuild_version% == VS2015 SET msbuild="%programfiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
|
||||
IF %msbuild_version% == VS2017Community SET msbuild=%msbuild_vs2017community%
|
||||
IF %msbuild_version% == VS2017Professional SET msbuild=%msbuild_vs2017professional%
|
||||
IF %msbuild_version% == VS2017Enterprise SET msbuild=%msbuild_vs2017enterprise%
|
||||
IF %msbuild_version% == VS2017 (
|
||||
IF EXIST %msbuild_vs2017community% SET msbuild=%msbuild_vs2017community%
|
||||
IF EXIST %msbuild_vs2017professional% SET msbuild=%msbuild_vs2017professional%
|
||||
IF EXIST %msbuild_vs2017enterprise% SET msbuild=%msbuild_vs2017enterprise%
|
||||
)
|
||||
IF %msbuild_version% == VS2017 SET vswhere_params=-version [15,16) -products *
|
||||
IF %msbuild_version% == VS2017Community SET vswhere_params=-version [15,16) -products Community
|
||||
IF %msbuild_version% == VS2017Enterprise SET vswhere_params=-version [15,16) -products Enterprise
|
||||
IF %msbuild_version% == VS2017Professional SET vswhere_params=-version [15,16) -products Professional
|
||||
IF %msbuild_version% == VS2019 SET vswhere_params=-version [16,17) -products *
|
||||
IF %msbuild_version% == VS2022 SET vswhere_params=-version [17,18) -products *
|
||||
REM Add the next Visual Studio version here.
|
||||
IF %msbuild_version% == latest SET vswhere_params=-latest -products *
|
||||
IF %msbuild_version% == preview SET vswhere_params=-prerelease -products *
|
||||
|
||||
:: VS2019
|
||||
SET msbuild_vs2019community="%programfiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe"
|
||||
SET msbuild_vs2019professional="%programfiles(x86)%\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe"
|
||||
SET msbuild_vs2019enterprise="%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe"
|
||||
IF %msbuild_version% == VS2019 (
|
||||
IF EXIST %msbuild_vs2019community% SET msbuild=%msbuild_vs2019community%
|
||||
IF EXIST %msbuild_vs2019professional% SET msbuild=%msbuild_vs2019professional%
|
||||
IF EXIST %msbuild_vs2019enterprise% SET msbuild=%msbuild_vs2019enterprise%
|
||||
IF NOT DEFINED vswhere_params GOTO skip_vswhere
|
||||
SET vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||
FOR /F "USEBACKQ TOKENS=*" %%F IN (`%vswhere% !vswhere_params! -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) DO (
|
||||
SET msbuild="%%F"
|
||||
)
|
||||
:skip_vswhere
|
||||
|
||||
SET project="%~p0\..\VS2010\zstd.sln"
|
||||
|
||||
|
@ -7,210 +7,75 @@
|
||||
# in the COPYING file in the root directory of this source tree).
|
||||
# ################################################################
|
||||
|
||||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
||||
|
||||
# As of 2018-12-26 ZSTD has been validated to build with cmake version 3.13.2 new policies.
|
||||
# Set and use the newest cmake policies that are validated to work
|
||||
set(ZSTD_MAX_VALIDATED_CMAKE_MAJOR_VERSION "3")
|
||||
set(ZSTD_MAX_VALIDATED_CMAKE_MINOR_VERSION "13") #Policies never changed at PATCH level
|
||||
if("${ZSTD_MAX_VALIDATED_CMAKE_MAJOR_VERSION}" EQUAL "${CMAKE_MAJOR_VERSION}" AND
|
||||
"${ZSTD_MAX_VALIDATED_CMAKE_MINOR_VERSION}" GREATER "${CMAKE_MINOR_VERSION}")
|
||||
set(ZSTD_CMAKE_POLICY_VERSION "${CMAKE_VERSION}")
|
||||
else()
|
||||
set(ZSTD_CMAKE_POLICY_VERSION "${ZSTD_MAX_VALIDATED_CMAKE_MAJOR_VERSION}.${ZSTD_MAX_VALIDATED_CMAKE_MINOR_VERSION}.0")
|
||||
endif()
|
||||
cmake_policy(VERSION ${ZSTD_CMAKE_POLICY_VERSION})
|
||||
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH on)
|
||||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Setup CMake environment
|
||||
#-----------------------------------------------------------------------------
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
|
||||
|
||||
# Define project paths
|
||||
set(ZSTD_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
|
||||
set(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib)
|
||||
# Parse version
|
||||
include(GetZstdLibraryVersion)
|
||||
GetZstdLibraryVersion(${LIBRARY_DIR}/zstd.h zstd_VERSION_MAJOR zstd_VERSION_MINOR zstd_VERSION_PATCH)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure CMake policies and version
|
||||
#-----------------------------------------------------------------------------
|
||||
include(ZstdVersion)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Project declaration
|
||||
#-----------------------------------------------------------------------------
|
||||
project(zstd
|
||||
VERSION "${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}"
|
||||
LANGUAGES C # Main library is in C
|
||||
ASM # And ASM
|
||||
CXX # Testing contributed code also utilizes CXX
|
||||
)
|
||||
VERSION "${ZSTD_FULL_VERSION}"
|
||||
LANGUAGES C ASM # Main library is in C and ASM
|
||||
HOMEPAGE_URL "${zstd_HOMEPAGE_URL}"
|
||||
DESCRIPTION "${zstd_DESCRIPTION}"
|
||||
)
|
||||
|
||||
message(STATUS "ZSTD VERSION: ${zstd_VERSION}")
|
||||
set(zstd_HOMEPAGE_URL "https://facebook.github.io/zstd")
|
||||
set(zstd_DESCRIPTION "Zstandard is a real-time compression algorithm, providing high compression ratios.")
|
||||
|
||||
# Set a default build type if none was specified
|
||||
#-----------------------------------------------------------------------------
|
||||
# Build type configuration
|
||||
#-----------------------------------------------------------------------------
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "Setting build type to 'Release' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
message(STATUS "Setting build type to 'Release' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Include standard modules
|
||||
#-----------------------------------------------------------------------------
|
||||
include(GNUInstallDirs)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add extra compilation flags
|
||||
#-----------------------------------------------------------------------------
|
||||
include(AddZstdCompilationFlags)
|
||||
ADD_ZSTD_COMPILATION_FLAGS()
|
||||
|
||||
# Always hide XXHash symbols
|
||||
add_definitions(-DXXH_NAMESPACE=ZSTD_)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Installation variables
|
||||
# Display installation information
|
||||
#-----------------------------------------------------------------------------
|
||||
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
|
||||
message(STATUS "CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Options
|
||||
# Configure build options
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Legacy support
|
||||
option(ZSTD_LEGACY_SUPPORT "LEGACY SUPPORT" ON)
|
||||
|
||||
if (ZSTD_LEGACY_SUPPORT)
|
||||
message(STATUS "ZSTD_LEGACY_SUPPORT defined!")
|
||||
set(ZSTD_LEGACY_LEVEL 5 CACHE STRING "")
|
||||
add_definitions(-DZSTD_LEGACY_SUPPORT=${ZSTD_LEGACY_LEVEL})
|
||||
else ()
|
||||
message(STATUS "ZSTD_LEGACY_SUPPORT not defined!")
|
||||
add_definitions(-DZSTD_LEGACY_SUPPORT=0)
|
||||
endif ()
|
||||
|
||||
if (ANDROID)
|
||||
set(ZSTD_MULTITHREAD_SUPPORT_DEFAULT OFF)
|
||||
else()
|
||||
set(ZSTD_MULTITHREAD_SUPPORT_DEFAULT ON)
|
||||
endif()
|
||||
|
||||
# Multi-threading support
|
||||
option(ZSTD_MULTITHREAD_SUPPORT "MULTITHREADING SUPPORT" ${ZSTD_MULTITHREAD_SUPPORT_DEFAULT})
|
||||
|
||||
if (ZSTD_MULTITHREAD_SUPPORT)
|
||||
message(STATUS "ZSTD_MULTITHREAD_SUPPORT is enabled")
|
||||
else ()
|
||||
message(STATUS "ZSTD_MULTITHREAD_SUPPORT is disabled")
|
||||
endif ()
|
||||
|
||||
option(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" ON)
|
||||
option(ZSTD_BUILD_CONTRIB "BUILD CONTRIB" OFF)
|
||||
|
||||
# Respect the conventional CMake option for enabling tests if it was specified on the first configure
|
||||
if (BUILD_TESTING)
|
||||
set(ZSTD_BUILD_TESTS_default ON)
|
||||
else()
|
||||
set(ZSTD_BUILD_TESTS_default OFF)
|
||||
endif()
|
||||
option(ZSTD_BUILD_TESTS "BUILD TESTS" ${ZSTD_BUILD_TESTS_default})
|
||||
if (MSVC)
|
||||
option(ZSTD_USE_STATIC_RUNTIME "LINK TO STATIC RUN-TIME LIBRARIES" OFF)
|
||||
endif ()
|
||||
include(ZstdOptions)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# External dependencies
|
||||
# Configure compilation flags
|
||||
#-----------------------------------------------------------------------------
|
||||
# Define a function to handle special thread settings for HP-UX
|
||||
# See https://github.com/facebook/zstd/pull/3862 for details.
|
||||
function(setup_hpux_threads)
|
||||
find_package(Threads)
|
||||
if (NOT Threads_FOUND)
|
||||
set(CMAKE_USE_PTHREADS_INIT 1 PARENT_SCOPE)
|
||||
set(CMAKE_THREAD_LIBS_INIT -lpthread PARENT_SCOPE)
|
||||
set(CMAKE_HAVE_THREADS_LIBRARY 1 PARENT_SCOPE)
|
||||
set(Threads_FOUND TRUE PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if (ZSTD_MULTITHREAD_SUPPORT AND UNIX)
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "HP-UX")
|
||||
setup_hpux_threads()
|
||||
else()
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
endif()
|
||||
if (CMAKE_USE_PTHREADS_INIT)
|
||||
set(THREADS_LIBS "${CMAKE_THREAD_LIBS_INIT}")
|
||||
else()
|
||||
message(SEND_ERROR "ZSTD currently does not support thread libraries other than pthreads")
|
||||
endif()
|
||||
endif ()
|
||||
include(AddZstdCompilationFlags)
|
||||
ADD_ZSTD_COMPILATION_FLAGS(ON ZSTD_ENABLE_CXX ON)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add source directories
|
||||
# Configure dependencies
|
||||
#-----------------------------------------------------------------------------
|
||||
add_subdirectory(lib)
|
||||
|
||||
option(ZSTD_PROGRAMS_LINK_SHARED "PROGRAMS LINK SHARED" OFF)
|
||||
|
||||
if (ZSTD_BUILD_PROGRAMS)
|
||||
if (NOT ZSTD_BUILD_STATIC AND NOT ZSTD_PROGRAMS_LINK_SHARED)
|
||||
message(SEND_ERROR "You need to build static library to build zstd CLI")
|
||||
elseif(NOT ZSTD_BUILD_SHARED AND ZSTD_PROGRAMS_LINK_SHARED)
|
||||
message(SEND_ERROR "You need to build shared library to build zstd CLI")
|
||||
endif ()
|
||||
|
||||
add_subdirectory(programs)
|
||||
endif ()
|
||||
|
||||
if (ZSTD_BUILD_TESTS)
|
||||
enable_testing()
|
||||
if (NOT ZSTD_BUILD_STATIC)
|
||||
message(SEND_ERROR "You need to build static library to build tests")
|
||||
endif ()
|
||||
|
||||
add_subdirectory(tests)
|
||||
endif ()
|
||||
|
||||
if (ZSTD_BUILD_CONTRIB)
|
||||
add_subdirectory(contrib)
|
||||
endif ()
|
||||
include(ZstdDependencies)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add clean-all target
|
||||
# Configure build targets
|
||||
#-----------------------------------------------------------------------------
|
||||
add_custom_target(clean-all
|
||||
COMMAND ${CMAKE_BUILD_TOOL} clean
|
||||
COMMAND rm -rf ${CMAKE_BINARY_DIR}/
|
||||
)
|
||||
include(ZstdBuild)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Generate Package Config files
|
||||
#
|
||||
# This section is based on the boiler plate code from:
|
||||
# https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-packages
|
||||
# Configure package generation
|
||||
#-----------------------------------------------------------------------------
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/zstdConfigVersion.cmake"
|
||||
VERSION ${zstd_VERSION}
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
# A Package Config file that works from the build directory
|
||||
export(EXPORT zstdExports
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/zstdTargets.cmake"
|
||||
NAMESPACE zstd::
|
||||
)
|
||||
|
||||
# A Package Config file that works from the installation directory
|
||||
set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/zstd)
|
||||
install(EXPORT zstdExports
|
||||
FILE zstdTargets.cmake
|
||||
NAMESPACE zstd::
|
||||
DESTINATION ${ConfigPackageLocation}
|
||||
)
|
||||
configure_package_config_file(
|
||||
zstdConfig.cmake.in
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/zstdConfig.cmake"
|
||||
INSTALL_DESTINATION ${ConfigPackageLocation}
|
||||
)
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/zstdConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/zstdConfigVersion.cmake"
|
||||
DESTINATION ${ConfigPackageLocation}
|
||||
)
|
||||
include(ZstdPackage)
|
||||
|
@ -1,11 +1,12 @@
|
||||
include(CheckCXXCompilerFlag)
|
||||
include(CheckCCompilerFlag)
|
||||
# VERSION_GREATER_EQUAL requires CMake 3.7 or later.
|
||||
# https://cmake.org/cmake/help/latest/command/if.html#version-greater-equal
|
||||
if (CMAKE_VERSION VERSION_LESS 3.18)
|
||||
set(ZSTD_HAVE_CHECK_LINKER_FLAG false)
|
||||
else ()
|
||||
if(CMAKE_CXX_COMPILER)
|
||||
include(CheckCXXCompilerFlag)
|
||||
endif()
|
||||
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)
|
||||
set(ZSTD_HAVE_CHECK_LINKER_FLAG true)
|
||||
else ()
|
||||
set(ZSTD_HAVE_CHECK_LINKER_FLAG false)
|
||||
endif ()
|
||||
if (ZSTD_HAVE_CHECK_LINKER_FLAG)
|
||||
include(CheckLinkerFlag)
|
||||
@ -22,7 +23,7 @@ function(EnableCompilerFlag _flag _C _CXX _LD)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flag}" PARENT_SCOPE)
|
||||
endif ()
|
||||
endif ()
|
||||
if (_CXX)
|
||||
if (_CXX AND CMAKE_CXX_COMPILER)
|
||||
CHECK_CXX_COMPILER_FLAG(${_flag} CXX_FLAG_${varname})
|
||||
if (CXX_FLAG_${varname})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}" PARENT_SCOPE)
|
||||
@ -50,49 +51,65 @@ function(EnableCompilerFlag _flag _C _CXX _LD)
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
macro(ADD_ZSTD_COMPILATION_FLAGS)
|
||||
macro(ADD_ZSTD_COMPILATION_FLAGS _C _CXX _LD)
|
||||
# We set ZSTD_HAS_NOEXECSTACK if we are certain we've set all the required
|
||||
# compiler flags to mark the stack as non-executable.
|
||||
set(ZSTD_HAS_NOEXECSTACK false)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" OR MINGW) #Not only UNIX but also WIN32 for MinGW
|
||||
# It's possible to select the exact standard used for compilation.
|
||||
# It's not necessary, but can be employed for specific purposes.
|
||||
# Note that zstd source code is compatible with both C++98 and above
|
||||
# and C-gnu90 (c90 + long long + variadic macros ) and above
|
||||
# EnableCompilerFlag("-std=c++11" false true) # Set C++ compilation to c++11 standard
|
||||
# EnableCompilerFlag("-std=c99" true false) # Set C compiation to c99 standard
|
||||
# EnableCompilerFlag("-std=c99" true false) # Set C compilation to c99 standard
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND MSVC)
|
||||
# clang-cl normally maps -Wall to -Weverything.
|
||||
EnableCompilerFlag("/clang:-Wall" true true false)
|
||||
EnableCompilerFlag("/clang:-Wall" _C _CXX false)
|
||||
else ()
|
||||
EnableCompilerFlag("-Wall" true true false)
|
||||
EnableCompilerFlag("-Wall" _C _CXX false)
|
||||
endif ()
|
||||
EnableCompilerFlag("-Wextra" true true false)
|
||||
EnableCompilerFlag("-Wundef" true true false)
|
||||
EnableCompilerFlag("-Wshadow" true true false)
|
||||
EnableCompilerFlag("-Wcast-align" true true false)
|
||||
EnableCompilerFlag("-Wcast-qual" true true false)
|
||||
EnableCompilerFlag("-Wstrict-prototypes" true false false)
|
||||
EnableCompilerFlag("-Wextra" _C _CXX false)
|
||||
EnableCompilerFlag("-Wundef" _C _CXX false)
|
||||
EnableCompilerFlag("-Wshadow" _C _CXX false)
|
||||
EnableCompilerFlag("-Wcast-align" _C _CXX false)
|
||||
EnableCompilerFlag("-Wcast-qual" _C _CXX false)
|
||||
EnableCompilerFlag("-Wstrict-prototypes" _C false false)
|
||||
# Enable asserts in Debug mode
|
||||
if (CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
EnableCompilerFlag("-DDEBUGLEVEL=1" true true false)
|
||||
EnableCompilerFlag("-DDEBUGLEVEL=1" _C _CXX false)
|
||||
endif ()
|
||||
# Add noexecstack flags
|
||||
# LDFLAGS
|
||||
EnableCompilerFlag("-z noexecstack" false false true)
|
||||
EnableCompilerFlag("-Wl,-z,noexecstack" false false _LD)
|
||||
# CFLAGS & CXXFLAGS
|
||||
EnableCompilerFlag("-Qunused-arguments" true true false)
|
||||
EnableCompilerFlag("-Wa,--noexecstack" true true false)
|
||||
EnableCompilerFlag("-Qunused-arguments" _C _CXX false)
|
||||
EnableCompilerFlag("-Wa,--noexecstack" _C _CXX false)
|
||||
# NOTE: Using 3 nested ifs because the variables are sometimes
|
||||
# empty if the condition is false, and sometimes equal to false.
|
||||
# This implicitly converts them to truthy values. There may be
|
||||
# a better way to do this, but this reliably works.
|
||||
if (${LD_FLAG_WL_Z_NOEXECSTACK})
|
||||
if (${C_FLAG_WA_NOEXECSTACK})
|
||||
if (${CXX_FLAG_WA_NOEXECSTACK})
|
||||
# We've succeeded in marking the stack as non-executable
|
||||
set(ZSTD_HAS_NOEXECSTACK true)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
elseif (MSVC) # Add specific compilation flags for Windows Visual
|
||||
|
||||
set(ACTIVATE_MULTITHREADED_COMPILATION "ON" CACHE BOOL "activate multi-threaded compilation (/MP flag)")
|
||||
if (CMAKE_GENERATOR MATCHES "Visual Studio" AND ACTIVATE_MULTITHREADED_COMPILATION)
|
||||
EnableCompilerFlag("/MP" true true false)
|
||||
EnableCompilerFlag("/MP" _C _CXX false)
|
||||
endif ()
|
||||
|
||||
# UNICODE SUPPORT
|
||||
EnableCompilerFlag("/D_UNICODE" true true false)
|
||||
EnableCompilerFlag("/DUNICODE" true true false)
|
||||
EnableCompilerFlag("/D_UNICODE" _C _CXX false)
|
||||
EnableCompilerFlag("/DUNICODE" _C _CXX false)
|
||||
# Enable asserts in Debug mode
|
||||
if (CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
EnableCompilerFlag("/DDEBUGLEVEL=1" true true false)
|
||||
EnableCompilerFlag("/DDEBUGLEVEL=1" _C _CXX false)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
42
build/cmake/CMakeModules/ZstdBuild.cmake
Normal file
42
build/cmake/CMakeModules/ZstdBuild.cmake
Normal file
@ -0,0 +1,42 @@
|
||||
# ################################################################
|
||||
# ZSTD Build Targets Configuration
|
||||
# ################################################################
|
||||
|
||||
# Always build the library first (this defines ZSTD_BUILD_STATIC/SHARED options)
|
||||
add_subdirectory(lib)
|
||||
|
||||
# Validate build configuration after lib options are defined
|
||||
if(ZSTD_BUILD_PROGRAMS)
|
||||
if(NOT ZSTD_BUILD_STATIC AND NOT ZSTD_PROGRAMS_LINK_SHARED)
|
||||
message(SEND_ERROR "Static library required to build zstd CLI programs")
|
||||
elseif(NOT ZSTD_BUILD_SHARED AND ZSTD_PROGRAMS_LINK_SHARED)
|
||||
message(SEND_ERROR "Shared library required to build zstd CLI programs")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ZSTD_BUILD_TESTS AND NOT ZSTD_BUILD_STATIC)
|
||||
message(SEND_ERROR "Static library required to build test suite")
|
||||
endif()
|
||||
|
||||
# Add programs if requested
|
||||
if(ZSTD_BUILD_PROGRAMS)
|
||||
add_subdirectory(programs)
|
||||
endif()
|
||||
|
||||
# Add tests if requested
|
||||
if(ZSTD_BUILD_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
# Add contrib utilities if requested
|
||||
if(ZSTD_BUILD_CONTRIB)
|
||||
add_subdirectory(contrib)
|
||||
endif()
|
||||
|
||||
# Clean-all target for thorough cleanup
|
||||
add_custom_target(clean-all
|
||||
COMMAND ${CMAKE_BUILD_TOOL} clean
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/
|
||||
COMMENT "Performing complete clean including build directory"
|
||||
)
|
30
build/cmake/CMakeModules/ZstdDependencies.cmake
Normal file
30
build/cmake/CMakeModules/ZstdDependencies.cmake
Normal file
@ -0,0 +1,30 @@
|
||||
# ################################################################
|
||||
# ZSTD Dependencies Configuration
|
||||
# ################################################################
|
||||
|
||||
# Function to handle HP-UX thread configuration
|
||||
function(setup_hpux_threads)
|
||||
find_package(Threads)
|
||||
if(NOT Threads_FOUND)
|
||||
set(CMAKE_USE_PTHREADS_INIT 1 PARENT_SCOPE)
|
||||
set(CMAKE_THREAD_LIBS_INIT -lpthread PARENT_SCOPE)
|
||||
set(CMAKE_HAVE_THREADS_LIBRARY 1 PARENT_SCOPE)
|
||||
set(Threads_FOUND TRUE PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Configure threading support
|
||||
if(ZSTD_MULTITHREAD_SUPPORT AND UNIX)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
|
||||
setup_hpux_threads()
|
||||
else()
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
endif()
|
||||
|
||||
if(CMAKE_USE_PTHREADS_INIT)
|
||||
set(THREADS_LIBS "${CMAKE_THREAD_LIBS_INIT}")
|
||||
else()
|
||||
message(SEND_ERROR "ZSTD currently does not support thread libraries other than pthreads")
|
||||
endif()
|
||||
endif()
|
68
build/cmake/CMakeModules/ZstdOptions.cmake
Normal file
68
build/cmake/CMakeModules/ZstdOptions.cmake
Normal file
@ -0,0 +1,68 @@
|
||||
# ################################################################
|
||||
# ZSTD Build Options Configuration
|
||||
# ################################################################
|
||||
|
||||
# Legacy support configuration
|
||||
option(ZSTD_LEGACY_SUPPORT "Enable legacy format support" ON)
|
||||
|
||||
if(ZSTD_LEGACY_SUPPORT)
|
||||
message(STATUS "ZSTD_LEGACY_SUPPORT enabled")
|
||||
set(ZSTD_LEGACY_LEVEL 5 CACHE STRING "Legacy support level")
|
||||
add_definitions(-DZSTD_LEGACY_SUPPORT=${ZSTD_LEGACY_LEVEL})
|
||||
else()
|
||||
message(STATUS "ZSTD_LEGACY_SUPPORT disabled")
|
||||
add_definitions(-DZSTD_LEGACY_SUPPORT=0)
|
||||
endif()
|
||||
|
||||
# Platform-specific options
|
||||
if(APPLE)
|
||||
option(ZSTD_FRAMEWORK "Build as Apple Framework" OFF)
|
||||
endif()
|
||||
|
||||
# Android-specific configuration
|
||||
if(ANDROID)
|
||||
set(ZSTD_MULTITHREAD_SUPPORT_DEFAULT OFF)
|
||||
# Handle old Android API levels
|
||||
if((NOT ANDROID_PLATFORM_LEVEL) OR (ANDROID_PLATFORM_LEVEL VERSION_LESS 24))
|
||||
message(STATUS "Configuring for old Android API - disabling fseeko/ftello")
|
||||
add_compile_definitions(LIBC_NO_FSEEKO)
|
||||
endif()
|
||||
else()
|
||||
set(ZSTD_MULTITHREAD_SUPPORT_DEFAULT ON)
|
||||
endif()
|
||||
|
||||
# Multi-threading support
|
||||
option(ZSTD_MULTITHREAD_SUPPORT "Enable multi-threading support" ${ZSTD_MULTITHREAD_SUPPORT_DEFAULT})
|
||||
|
||||
if(ZSTD_MULTITHREAD_SUPPORT)
|
||||
message(STATUS "Multi-threading support enabled")
|
||||
else()
|
||||
message(STATUS "Multi-threading support disabled")
|
||||
endif()
|
||||
|
||||
# Build component options
|
||||
option(ZSTD_BUILD_PROGRAMS "Build command-line programs" ON)
|
||||
option(ZSTD_BUILD_CONTRIB "Build contrib utilities" OFF)
|
||||
option(ZSTD_PROGRAMS_LINK_SHARED "Link programs against shared library" OFF)
|
||||
|
||||
# Test configuration
|
||||
if(BUILD_TESTING)
|
||||
set(ZSTD_BUILD_TESTS_default ON)
|
||||
else()
|
||||
set(ZSTD_BUILD_TESTS_default OFF)
|
||||
endif()
|
||||
option(ZSTD_BUILD_TESTS "Build test suite" ${ZSTD_BUILD_TESTS_default})
|
||||
|
||||
# MSVC-specific options
|
||||
if(MSVC)
|
||||
option(ZSTD_USE_STATIC_RUNTIME "Link to static runtime libraries" OFF)
|
||||
endif()
|
||||
|
||||
# C++ support (needed for tests)
|
||||
set(ZSTD_ENABLE_CXX ${ZSTD_BUILD_TESTS})
|
||||
if(ZSTD_ENABLE_CXX)
|
||||
enable_language(CXX)
|
||||
endif()
|
||||
|
||||
# Set global definitions
|
||||
add_definitions(-DXXH_NAMESPACE=ZSTD_)
|
42
build/cmake/CMakeModules/ZstdPackage.cmake
Normal file
42
build/cmake/CMakeModules/ZstdPackage.cmake
Normal file
@ -0,0 +1,42 @@
|
||||
# ################################################################
|
||||
# ZSTD Package Configuration
|
||||
# ################################################################
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
# Generate version file
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/zstdConfigVersion.cmake"
|
||||
VERSION ${zstd_VERSION}
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
# Export targets for build directory
|
||||
export(EXPORT zstdExports
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/zstdTargets.cmake"
|
||||
NAMESPACE zstd::
|
||||
)
|
||||
|
||||
# Configure package for installation
|
||||
set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/zstd)
|
||||
|
||||
# Install exported targets
|
||||
install(EXPORT zstdExports
|
||||
FILE zstdTargets.cmake
|
||||
NAMESPACE zstd::
|
||||
DESTINATION ${ConfigPackageLocation}
|
||||
)
|
||||
|
||||
# Configure and install package config file
|
||||
configure_package_config_file(
|
||||
zstdConfig.cmake.in
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/zstdConfig.cmake"
|
||||
INSTALL_DESTINATION ${ConfigPackageLocation}
|
||||
)
|
||||
|
||||
# Install config files
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/zstdConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/zstdConfigVersion.cmake"
|
||||
DESTINATION ${ConfigPackageLocation}
|
||||
)
|
31
build/cmake/CMakeModules/ZstdVersion.cmake
Normal file
31
build/cmake/CMakeModules/ZstdVersion.cmake
Normal file
@ -0,0 +1,31 @@
|
||||
# ################################################################
|
||||
# ZSTD Version Configuration
|
||||
# ################################################################
|
||||
|
||||
# Setup CMake policy version
|
||||
set(ZSTD_MAX_VALIDATED_CMAKE_MAJOR_VERSION "3")
|
||||
set(ZSTD_MAX_VALIDATED_CMAKE_MINOR_VERSION "13")
|
||||
|
||||
# Determine appropriate policy version
|
||||
if("${ZSTD_MAX_VALIDATED_CMAKE_MAJOR_VERSION}" EQUAL "${CMAKE_MAJOR_VERSION}" AND
|
||||
"${ZSTD_MAX_VALIDATED_CMAKE_MINOR_VERSION}" GREATER "${CMAKE_MINOR_VERSION}")
|
||||
set(ZSTD_CMAKE_POLICY_VERSION "${CMAKE_VERSION}")
|
||||
else()
|
||||
set(ZSTD_CMAKE_POLICY_VERSION "${ZSTD_MAX_VALIDATED_CMAKE_MAJOR_VERSION}.${ZSTD_MAX_VALIDATED_CMAKE_MINOR_VERSION}.0")
|
||||
endif()
|
||||
|
||||
cmake_policy(VERSION ${ZSTD_CMAKE_POLICY_VERSION})
|
||||
|
||||
# Parse version from header file
|
||||
include(GetZstdLibraryVersion)
|
||||
GetZstdLibraryVersion(${LIBRARY_DIR}/zstd.h zstd_VERSION_MAJOR zstd_VERSION_MINOR zstd_VERSION_PATCH)
|
||||
|
||||
# Set version variables
|
||||
set(ZSTD_SHORT_VERSION "${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}")
|
||||
set(ZSTD_FULL_VERSION "${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}")
|
||||
|
||||
# Project metadata
|
||||
set(zstd_HOMEPAGE_URL "https://facebook.github.io/zstd")
|
||||
set(zstd_DESCRIPTION "Zstandard is a real-time compression algorithm, providing high compression ratios.")
|
||||
|
||||
message(STATUS "ZSTD VERSION: ${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}")
|
@ -41,6 +41,16 @@ cmake -DZSTD_BUILD_TESTS=ON -DZSTD_LEGACY_SUPPORT=OFF ..
|
||||
make
|
||||
```
|
||||
|
||||
**Apple Frameworks**
|
||||
It's generally recommended to have CMake with versions higher than 3.14 for [iOS-derived platforms](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#id27).
|
||||
```sh
|
||||
cmake -S. -B build-cmake -DZSTD_FRAMEWORK=ON -DCMAKE_SYSTEM_NAME=iOS
|
||||
```
|
||||
Or you can utilize [iOS-CMake](https://github.com/leetal/ios-cmake) toolchain for CMake versions lower than 3.14
|
||||
```sh
|
||||
cmake -B build -G Xcode -DCMAKE_TOOLCHAIN_FILE=<Path To ios.toolchain.cmake> -DPLATFORM=OS64 -DZSTD_FRAMEWORK=ON
|
||||
```
|
||||
|
||||
### how to use it with CMake FetchContent
|
||||
|
||||
For all options available, you can see it on <https://github.com/facebook/zstd/blob/dev/build/cmake/lib/CMakeLists.txt>
|
||||
|
@ -39,7 +39,7 @@ file(GLOB DecompressSources ${LIBRARY_DIR}/decompress/*.c)
|
||||
if (MSVC)
|
||||
add_compile_options(-DZSTD_DISABLE_ASM)
|
||||
else ()
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|AMD64.*|x86_64.*|X86_64.*")
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|AMD64.*|x86_64.*|X86_64.*" AND ${ZSTD_HAS_NOEXECSTACK})
|
||||
set(DecompressSources ${DecompressSources} ${LIBRARY_DIR}/decompress/huf_decompress_amd64.S)
|
||||
else()
|
||||
add_compile_options(-DZSTD_DISABLE_ASM)
|
||||
@ -97,9 +97,11 @@ if (ZSTD_LEGACY_SUPPORT)
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v07.h)
|
||||
endif ()
|
||||
|
||||
if (MSVC)
|
||||
if (MSVC AND NOT (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
|
||||
set(MSVC_RESOURCE_DIR ${ZSTD_SOURCE_DIR}/build/VS2010/libzstd-dll)
|
||||
set(PlatformDependResources ${MSVC_RESOURCE_DIR}/libzstd-dll.rc)
|
||||
else()
|
||||
set(PlatformDependResources)
|
||||
endif ()
|
||||
|
||||
# Explicitly set the language to C for all files, including ASM files.
|
||||
@ -112,13 +114,13 @@ endif()
|
||||
|
||||
macro (add_definition target var)
|
||||
if (NOT ("${${var}}" STREQUAL ""))
|
||||
set_property(TARGET ${target} APPEND PROPERTY COMPILE_DEFINITIONS "${var}=__attribute__((visibility(\"${${var}}\")))")
|
||||
target_compile_definitions(${target} PUBLIC "${var}=__attribute__((visibility(\"${${var}}\")))")
|
||||
endif ()
|
||||
endmacro ()
|
||||
|
||||
# Define directories containing the library's public headers
|
||||
set(PUBLIC_INCLUDE_DIRS ${LIBRARY_DIR})
|
||||
|
||||
set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} /I \"${LIBRARY_DIR}\"")
|
||||
# Split project to static and shared libraries build
|
||||
set(library_targets)
|
||||
if (ZSTD_BUILD_SHARED)
|
||||
@ -126,7 +128,7 @@ if (ZSTD_BUILD_SHARED)
|
||||
target_include_directories(libzstd_shared INTERFACE $<BUILD_INTERFACE:${PUBLIC_INCLUDE_DIRS}>)
|
||||
list(APPEND library_targets libzstd_shared)
|
||||
if (ZSTD_MULTITHREAD_SUPPORT)
|
||||
set_property(TARGET libzstd_shared APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
|
||||
target_compile_definitions(libzstd_shared PUBLIC ZSTD_MULTITHREAD)
|
||||
if (UNIX)
|
||||
target_link_libraries(libzstd_shared ${THREADS_LIBS})
|
||||
endif ()
|
||||
@ -140,7 +142,7 @@ if (ZSTD_BUILD_STATIC)
|
||||
target_include_directories(libzstd_static INTERFACE $<BUILD_INTERFACE:${PUBLIC_INCLUDE_DIRS}>)
|
||||
list(APPEND library_targets libzstd_static)
|
||||
if (ZSTD_MULTITHREAD_SUPPORT)
|
||||
set_property(TARGET libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
|
||||
target_compile_definitions(libzstd_static PUBLIC ZSTD_MULTITHREAD)
|
||||
if (UNIX)
|
||||
target_link_libraries(libzstd_static ${THREADS_LIBS})
|
||||
endif ()
|
||||
@ -205,8 +207,28 @@ if (ZSTD_BUILD_SHARED)
|
||||
libzstd_shared
|
||||
PROPERTIES
|
||||
OUTPUT_NAME zstd
|
||||
VERSION ${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}
|
||||
VERSION ${ZSTD_FULL_VERSION}
|
||||
SOVERSION ${zstd_VERSION_MAJOR})
|
||||
|
||||
if (ZSTD_FRAMEWORK)
|
||||
set_target_properties(
|
||||
libzstd_shared
|
||||
PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
FRAMEWORK_VERSION "${ZSTD_FULL_VERSION}"
|
||||
PRODUCT_BUNDLE_IDENTIFIER "github.com/facebook/zstd"
|
||||
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
|
||||
PUBLIC_HEADER "${PublicHeaders}"
|
||||
OUTPUT_NAME "zstd"
|
||||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
|
||||
XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
|
||||
XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO"
|
||||
MACOSX_FRAMEWORK_IDENTIFIER "github.com/facebook/zstd"
|
||||
MACOSX_FRAMEWORK_BUNDLE_VERSION "${ZSTD_FULL_VERSION}"
|
||||
MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${ZSTD_SHORT_VERSION}"
|
||||
MACOSX_RPATH TRUE
|
||||
RESOURCE ${PublicHeaders})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (ZSTD_BUILD_STATIC)
|
||||
@ -215,6 +237,26 @@ if (ZSTD_BUILD_STATIC)
|
||||
PROPERTIES
|
||||
POSITION_INDEPENDENT_CODE On
|
||||
OUTPUT_NAME ${STATIC_LIBRARY_BASE_NAME})
|
||||
|
||||
if (ZSTD_FRAMEWORK)
|
||||
set_target_properties(
|
||||
libzstd_static
|
||||
PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
FRAMEWORK_VERSION "${ZSTD_FULL_VERSION}"
|
||||
PRODUCT_BUNDLE_IDENTIFIER "github.com/facebook/zstd/${STATIC_LIBRARY_BASE_NAME}"
|
||||
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
|
||||
PUBLIC_HEADER "${PublicHeaders}"
|
||||
OUTPUT_NAME "${STATIC_LIBRARY_BASE_NAME}"
|
||||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
|
||||
XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
|
||||
XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO"
|
||||
MACOSX_FRAMEWORK_IDENTIFIER "github.com/facebook/zstd/${STATIC_LIBRARY_BASE_NAME}"
|
||||
MACOSX_FRAMEWORK_BUNDLE_VERSION "${ZSTD_FULL_VERSION}"
|
||||
MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${ZSTD_SHORT_VERSION}"
|
||||
MACOSX_RPATH TRUE
|
||||
RESOURCE ${PublicHeaders})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# pkg-config
|
||||
@ -239,6 +281,8 @@ install(TARGETS ${library_targets}
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
FRAMEWORK DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT runtime OPTIONAL
|
||||
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
)
|
||||
|
||||
# uninstall target
|
||||
|
@ -20,6 +20,6 @@ pzstd = executable('pzstd',
|
||||
pzstd_sources,
|
||||
cpp_args: pzstd_warning_flags,
|
||||
include_directories: pzstd_includes,
|
||||
dependencies: [ libzstd_dep, thread_dep ],
|
||||
dependencies: [ libzstd_internal_dep, thread_dep ],
|
||||
override_options: ['b_ndebug=true'],
|
||||
install: true)
|
||||
|
@ -30,6 +30,7 @@ libzstd_sources = [join_paths(zstd_rootdir, 'lib/common/entropy_common.c'),
|
||||
join_paths(zstd_rootdir, 'lib/compress/zstd_compress_literals.c'),
|
||||
join_paths(zstd_rootdir, 'lib/compress/zstd_compress_sequences.c'),
|
||||
join_paths(zstd_rootdir, 'lib/compress/zstd_compress_superblock.c'),
|
||||
join_paths(zstd_rootdir, 'lib/compress/zstd_preSplit.c'),
|
||||
join_paths(zstd_rootdir, 'lib/compress/zstdmt_compress.c'),
|
||||
join_paths(zstd_rootdir, 'lib/compress/zstd_fast.c'),
|
||||
join_paths(zstd_rootdir, 'lib/compress/zstd_double_fast.c'),
|
||||
@ -124,7 +125,7 @@ libzstd = library('zstd',
|
||||
version: zstd_libversion)
|
||||
|
||||
libzstd_dep = declare_dependency(link_with: libzstd,
|
||||
include_directories: libzstd_includes)
|
||||
include_directories: join_paths(zstd_rootdir,'lib')) # Do not expose private headers
|
||||
|
||||
# we link to both:
|
||||
# - the shared library (for public symbols)
|
||||
@ -134,7 +135,8 @@ libzstd_dep = declare_dependency(link_with: libzstd,
|
||||
# -fvisibility=hidden means those cannot be found
|
||||
if get_option('default_library') == 'static'
|
||||
libzstd_static = libzstd
|
||||
libzstd_internal_dep = libzstd_dep
|
||||
libzstd_internal_dep = declare_dependency(link_with: libzstd,
|
||||
include_directories: libzstd_includes)
|
||||
else
|
||||
if get_option('default_library') == 'shared'
|
||||
libzstd_static = static_library('zstd_objlib',
|
||||
@ -147,11 +149,13 @@ else
|
||||
if cc_id == compiler_msvc
|
||||
# msvc does not actually support linking to both, but errors out with:
|
||||
# error LNK2005: ZSTD_<foo> already defined in zstd.lib(zstd-1.dll)
|
||||
libzstd_internal_dep = declare_dependency(link_with: libzstd_static)
|
||||
libzstd_internal_dep = declare_dependency(link_with: libzstd_static,
|
||||
include_directories: libzstd_includes)
|
||||
else
|
||||
libzstd_internal_dep = declare_dependency(link_with: libzstd,
|
||||
# the static library must be linked after the shared one
|
||||
dependencies: declare_dependency(link_with: libzstd_static))
|
||||
dependencies: declare_dependency(link_with: libzstd_static),
|
||||
include_directories: libzstd_includes)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
project('zstd',
|
||||
['c', 'cpp'],
|
||||
license: ['BSD', 'GPLv2'],
|
||||
license: 'BSD-3-Clause OR GPL-2.0-only',
|
||||
default_options : [
|
||||
# There shouldn't be any need to force a C standard convention for zstd
|
||||
# but in case one would want that anyway, this can be done here.
|
||||
@ -65,7 +65,6 @@ zstd_docdir = join_paths(zstd_datadir, 'doc', meson.project_name())
|
||||
|
||||
# Built-in options
|
||||
use_debug = get_option('debug')
|
||||
buildtype = get_option('buildtype')
|
||||
default_library_type = get_option('default_library')
|
||||
|
||||
# Custom options
|
||||
@ -88,8 +87,13 @@ feature_lz4 = get_option('lz4')
|
||||
# =============================================================================
|
||||
|
||||
libm_dep = cc.find_library('m', required: false)
|
||||
thread_dep = dependency('threads', required: feature_multi_thread)
|
||||
use_multi_thread = thread_dep.found()
|
||||
if host_machine_os == os_windows
|
||||
thread_dep = dependency('', required: false)
|
||||
use_multi_thread = not feature_multi_thread.disabled()
|
||||
else
|
||||
thread_dep = dependency('threads', required: feature_multi_thread)
|
||||
use_multi_thread = thread_dep.found()
|
||||
endif
|
||||
# Arguments in dependency should be equivalent to those passed to pkg-config
|
||||
zlib_dep = dependency('zlib', required: feature_zlib)
|
||||
use_zlib = zlib_dep.found()
|
||||
@ -111,10 +115,16 @@ if [compiler_gcc, compiler_clang].contains(cc_id)
|
||||
if cc_id == compiler_clang
|
||||
common_warning_flags += ['-Wconversion', '-Wno-sign-conversion', '-Wdocumentation']
|
||||
endif
|
||||
cc_compile_flags = cc.get_supported_arguments(common_warning_flags + ['-Wstrict-prototypes'])
|
||||
cxx_compile_flags = cxx.get_supported_arguments(common_warning_flags)
|
||||
noexecstack_flags = ['-Wa,--noexecstack' ]
|
||||
noexecstack_link_flags = ['-Wl,-z,noexecstack']
|
||||
cc_compile_flags = cc.get_supported_arguments(common_warning_flags + noexecstack_flags + ['-Wstrict-prototypes'])
|
||||
cxx_compile_flags = cxx.get_supported_arguments(common_warning_flags + noexecstack_flags)
|
||||
add_project_arguments(cc_compile_flags, language : 'c')
|
||||
add_project_arguments(cxx_compile_flags, language : 'cpp')
|
||||
cc_link_flags = cc.get_supported_link_arguments(noexecstack_link_flags)
|
||||
cxx_link_flags = cxx.get_supported_link_arguments(noexecstack_link_flags)
|
||||
add_project_link_arguments(cc_link_flags, language: 'c')
|
||||
add_project_link_arguments(cxx_link_flags, language: 'cpp')
|
||||
elif cc_id == compiler_msvc
|
||||
msvc_compile_flags = [ '/D_UNICODE', '/DUNICODE' ]
|
||||
if use_multi_thread
|
||||
|
@ -27,7 +27,7 @@ option('bin_contrib', type: 'boolean', value: false,
|
||||
description: 'Enable contrib build')
|
||||
|
||||
option('multi_thread', type: 'feature', value: 'enabled',
|
||||
description: 'Enable multi-threading when pthread is detected')
|
||||
description: 'Enable multi-threading when pthread or Windows is detected')
|
||||
option('zlib', type: 'feature', value: 'auto',
|
||||
description: 'Enable zlib support')
|
||||
option('lzma', type: 'feature', value: 'auto',
|
||||
|
@ -93,7 +93,7 @@ roundTripCrash = executable('roundTripCrash',
|
||||
longmatch_sources = [join_paths(zstd_rootdir, 'tests/longmatch.c')]
|
||||
longmatch = executable('longmatch',
|
||||
longmatch_sources,
|
||||
dependencies: [ libzstd_dep ],
|
||||
dependencies: [ libzstd_internal_dep ],
|
||||
install: false)
|
||||
|
||||
invalidDictionaries_sources = [join_paths(zstd_rootdir, 'tests/invalidDictionaries.c')]
|
||||
|
1
build/single_file_libs/.gitignore
vendored
1
build/single_file_libs/.gitignore
vendored
@ -4,6 +4,7 @@ zstddeclib.c
|
||||
zstdenclib.c
|
||||
zstd.c
|
||||
zstd.h
|
||||
zstd_errors.h
|
||||
|
||||
# test artifacts
|
||||
temp*
|
||||
|
@ -70,6 +70,7 @@ echo "Single file library creation script: PASSED"
|
||||
|
||||
# Copy the header to here (for the tests)
|
||||
cp "$ZSTD_SRC_ROOT/zstd.h" examples/zstd.h
|
||||
cp "$ZSTD_SRC_ROOT/zstd_errors.h" examples/zstd_errors.h
|
||||
|
||||
# Compile the generated output
|
||||
cc -Wall -Wextra -Werror -Wshadow -pthread -I. -Os -g0 -o $OUT_FILE zstd.c examples/roundtrip.c
|
||||
|
@ -69,6 +69,7 @@
|
||||
#include "compress/zstd_compress_literals.c"
|
||||
#include "compress/zstd_compress_sequences.c"
|
||||
#include "compress/zstd_compress_superblock.c"
|
||||
#include "compress/zstd_preSplit.c"
|
||||
#include "compress/zstd_compress.c"
|
||||
#include "compress/zstd_double_fast.c"
|
||||
#include "compress/zstd_fast.c"
|
||||
|
@ -27,6 +27,7 @@ do { \
|
||||
} while (0) \
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int retn = 0;
|
||||
if (argc != 2) {
|
||||
printf("Usage: externalSequenceProducer <file>\n");
|
||||
return 1;
|
||||
@ -96,12 +97,12 @@ int main(int argc, char *argv[]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
retn = 1;
|
||||
}
|
||||
|
||||
ZSTD_freeCCtx(zc);
|
||||
free(src);
|
||||
free(dst);
|
||||
free(val);
|
||||
return 0;
|
||||
return retn;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ gen_html: gen_html.cpp
|
||||
|
||||
$(ZSTDMANUAL): gen_html $(ZSTDAPI)
|
||||
echo "Update zstd manual in /doc"
|
||||
./gen_html $(LIBVER) $(ZSTDAPI) $(ZSTDMANUAL)
|
||||
./gen_html$(EXT) $(LIBVER) $(ZSTDAPI) $(ZSTDMANUAL)
|
||||
|
||||
.PHONY: manual
|
||||
manual: gen_html $(ZSTDMANUAL)
|
||||
|
@ -211,6 +211,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
ostream << "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n<title>" << version << "</title>\n</head>\n<body>" << endl;
|
||||
ostream << "<h1>" << version << "</h1>\n";
|
||||
ostream << "Note: the content of this file has been automatically generated by parsing \"zstd.h\" \n";
|
||||
|
||||
ostream << "<hr>\n<a name=\"Contents\"></a><h2>Contents</h2>\n<ol>\n";
|
||||
for (size_t i=0; i<chapters.size(); i++)
|
||||
|
@ -739,6 +739,8 @@ static int benchMem(slice_collection_t dstBlocks, slice_collection_t srcBlocks,
|
||||
/* BMK_benchTimedFn may not run exactly nbRounds iterations */
|
||||
double speedAggregated =
|
||||
aggregateData(speedPerRound, roundNb + 1, metricAggregatePref);
|
||||
free(speedPerRound);
|
||||
|
||||
if (metricAggregatePref == fastest)
|
||||
DISPLAY("Fastest Speed : %.1f MB/s \n", speedAggregated);
|
||||
else
|
||||
@ -1025,7 +1027,7 @@ int main (int argc, const char** argv)
|
||||
unsigned nbBlocks = 0; /* determine nbBlocks automatically, from source and blockSize */
|
||||
ZSTD_dictContentType_e dictContentType = ZSTD_dct_auto;
|
||||
ZSTD_dictAttachPref_e dictAttachPref = ZSTD_dictDefaultAttach;
|
||||
ZSTD_paramSwitch_e prefetchCDictTables = ZSTD_ps_auto;
|
||||
ZSTD_ParamSwitch_e prefetchCDictTables = ZSTD_ps_auto;
|
||||
metricAggregatePref_e metricAggregatePref = fastest;
|
||||
|
||||
for (int argNb = 1; argNb < argc ; argNb++) {
|
||||
|
@ -26,6 +26,7 @@ zstd_compress-y := \
|
||||
compress/zstd_lazy.o \
|
||||
compress/zstd_ldm.o \
|
||||
compress/zstd_opt.o \
|
||||
compress/zstd_preSplit.o \
|
||||
|
||||
zstd_decompress-y := \
|
||||
zstd_decompress_module.o \
|
||||
|
@ -77,6 +77,30 @@ int zstd_min_clevel(void);
|
||||
*/
|
||||
int zstd_max_clevel(void);
|
||||
|
||||
/**
|
||||
* zstd_default_clevel() - default compression level
|
||||
*
|
||||
* Return: Default compression level.
|
||||
*/
|
||||
int zstd_default_clevel(void);
|
||||
|
||||
/**
|
||||
* struct zstd_custom_mem - custom memory allocation
|
||||
*/
|
||||
typedef ZSTD_customMem zstd_custom_mem;
|
||||
|
||||
/**
|
||||
* struct zstd_dict_load_method - Dictionary load method.
|
||||
* See zstd_lib.h.
|
||||
*/
|
||||
typedef ZSTD_dictLoadMethod_e zstd_dict_load_method;
|
||||
|
||||
/**
|
||||
* struct zstd_dict_content_type - Dictionary context type.
|
||||
* See zstd_lib.h.
|
||||
*/
|
||||
typedef ZSTD_dictContentType_e zstd_dict_content_type;
|
||||
|
||||
/* ====== Parameter Selection ====== */
|
||||
|
||||
/**
|
||||
@ -136,9 +160,32 @@ typedef ZSTD_parameters zstd_parameters;
|
||||
zstd_parameters zstd_get_params(int level,
|
||||
unsigned long long estimated_src_size);
|
||||
|
||||
/* ====== Single-pass Compression ====== */
|
||||
/**
|
||||
* zstd_get_cparams() - returns zstd_compression_parameters for selected level
|
||||
* @level: The compression level
|
||||
* @estimated_src_size: The estimated source size to compress or 0
|
||||
* if unknown.
|
||||
* @dict_size: Dictionary size.
|
||||
*
|
||||
* Return: The selected zstd_compression_parameters.
|
||||
*/
|
||||
zstd_compression_parameters zstd_get_cparams(int level,
|
||||
unsigned long long estimated_src_size, size_t dict_size);
|
||||
|
||||
typedef ZSTD_CCtx zstd_cctx;
|
||||
typedef ZSTD_cParameter zstd_cparameter;
|
||||
|
||||
/**
|
||||
* zstd_cctx_set_param() - sets a compression parameter
|
||||
* @cctx: The context. Must have been initialized with zstd_init_cctx().
|
||||
* @param: The parameter to set.
|
||||
* @value: The value to set the parameter to.
|
||||
*
|
||||
* Return: Zero or an error, which can be checked using zstd_is_error().
|
||||
*/
|
||||
size_t zstd_cctx_set_param(zstd_cctx *cctx, zstd_cparameter param, int value);
|
||||
|
||||
/* ====== Single-pass Compression ====== */
|
||||
|
||||
/**
|
||||
* zstd_cctx_workspace_bound() - max memory needed to initialize a zstd_cctx
|
||||
@ -153,6 +200,20 @@ typedef ZSTD_CCtx zstd_cctx;
|
||||
*/
|
||||
size_t zstd_cctx_workspace_bound(const zstd_compression_parameters *parameters);
|
||||
|
||||
/**
|
||||
* zstd_cctx_workspace_bound_with_ext_seq_prod() - max memory needed to
|
||||
* initialize a zstd_cctx when using the block-level external sequence
|
||||
* producer API.
|
||||
* @parameters: The compression parameters to be used.
|
||||
*
|
||||
* If multiple compression parameters might be used, the caller must call
|
||||
* this function for each set of parameters and use the maximum size.
|
||||
*
|
||||
* Return: A lower bound on the size of the workspace that is passed to
|
||||
* zstd_init_cctx().
|
||||
*/
|
||||
size_t zstd_cctx_workspace_bound_with_ext_seq_prod(const zstd_compression_parameters *parameters);
|
||||
|
||||
/**
|
||||
* zstd_init_cctx() - initialize a zstd compression context
|
||||
* @workspace: The workspace to emplace the context into. It must outlive
|
||||
@ -180,6 +241,71 @@ zstd_cctx *zstd_init_cctx(void *workspace, size_t workspace_size);
|
||||
size_t zstd_compress_cctx(zstd_cctx *cctx, void *dst, size_t dst_capacity,
|
||||
const void *src, size_t src_size, const zstd_parameters *parameters);
|
||||
|
||||
/**
|
||||
* zstd_create_cctx_advanced() - Create compression context
|
||||
* @custom_mem: Custom allocator.
|
||||
*
|
||||
* Return: NULL on error, pointer to compression context otherwise.
|
||||
*/
|
||||
zstd_cctx *zstd_create_cctx_advanced(zstd_custom_mem custom_mem);
|
||||
|
||||
/**
|
||||
* zstd_free_cctx() - Free compression context
|
||||
* @cdict: Pointer to compression context.
|
||||
*
|
||||
* Return: Always 0.
|
||||
*/
|
||||
size_t zstd_free_cctx(zstd_cctx* cctx);
|
||||
|
||||
/**
|
||||
* struct zstd_cdict - Compression dictionary.
|
||||
* See zstd_lib.h.
|
||||
*/
|
||||
typedef ZSTD_CDict zstd_cdict;
|
||||
|
||||
/**
|
||||
* zstd_create_cdict_byreference() - Create compression dictionary
|
||||
* @dict: Pointer to dictionary buffer.
|
||||
* @dict_size: Size of the dictionary buffer.
|
||||
* @dict_load_method: Dictionary load method.
|
||||
* @dict_content_type: Dictionary content type.
|
||||
* @custom_mem: Memory allocator.
|
||||
*
|
||||
* Note, this uses @dict by reference (ZSTD_dlm_byRef), so it should be
|
||||
* free before zstd_cdict is destroyed.
|
||||
*
|
||||
* Return: NULL on error, pointer to compression dictionary
|
||||
* otherwise.
|
||||
*/
|
||||
zstd_cdict *zstd_create_cdict_byreference(const void *dict, size_t dict_size,
|
||||
zstd_compression_parameters cparams,
|
||||
zstd_custom_mem custom_mem);
|
||||
|
||||
/**
|
||||
* zstd_free_cdict() - Free compression dictionary
|
||||
* @cdict: Pointer to compression dictionary.
|
||||
*
|
||||
* Return: Always 0.
|
||||
*/
|
||||
size_t zstd_free_cdict(zstd_cdict* cdict);
|
||||
|
||||
/**
|
||||
* zstd_compress_using_cdict() - compress src into dst using a dictionary
|
||||
* @cctx: The context. Must have been initialized with zstd_init_cctx().
|
||||
* @dst: The buffer to compress src into.
|
||||
* @dst_capacity: The size of the destination buffer. May be any size, but
|
||||
* ZSTD_compressBound(srcSize) is guaranteed to be large enough.
|
||||
* @src: The data to compress.
|
||||
* @src_size: The size of the data to compress.
|
||||
* @cdict: The dictionary to be used.
|
||||
*
|
||||
* Return: The compressed size or an error, which can be checked using
|
||||
* zstd_is_error().
|
||||
*/
|
||||
size_t zstd_compress_using_cdict(zstd_cctx *cctx, void *dst,
|
||||
size_t dst_capacity, const void *src, size_t src_size,
|
||||
const zstd_cdict *cdict);
|
||||
|
||||
/* ====== Single-pass Decompression ====== */
|
||||
|
||||
typedef ZSTD_DCtx zstd_dctx;
|
||||
@ -220,6 +346,71 @@ zstd_dctx *zstd_init_dctx(void *workspace, size_t workspace_size);
|
||||
size_t zstd_decompress_dctx(zstd_dctx *dctx, void *dst, size_t dst_capacity,
|
||||
const void *src, size_t src_size);
|
||||
|
||||
/**
|
||||
* struct zstd_ddict - Decompression dictionary.
|
||||
* See zstd_lib.h.
|
||||
*/
|
||||
typedef ZSTD_DDict zstd_ddict;
|
||||
|
||||
/**
|
||||
* zstd_create_ddict_byreference() - Create decompression dictionary
|
||||
* @dict: Pointer to dictionary buffer.
|
||||
* @dict_size: Size of the dictionary buffer.
|
||||
* @dict_load_method: Dictionary load method.
|
||||
* @dict_content_type: Dictionary content type.
|
||||
* @custom_mem: Memory allocator.
|
||||
*
|
||||
* Note, this uses @dict by reference (ZSTD_dlm_byRef), so it should be
|
||||
* free before zstd_ddict is destroyed.
|
||||
*
|
||||
* Return: NULL on error, pointer to decompression dictionary
|
||||
* otherwise.
|
||||
*/
|
||||
zstd_ddict *zstd_create_ddict_byreference(const void *dict, size_t dict_size,
|
||||
zstd_custom_mem custom_mem);
|
||||
/**
|
||||
* zstd_free_ddict() - Free decompression dictionary
|
||||
* @dict: Pointer to the dictionary.
|
||||
*
|
||||
* Return: Always 0.
|
||||
*/
|
||||
size_t zstd_free_ddict(zstd_ddict *ddict);
|
||||
|
||||
/**
|
||||
* zstd_create_dctx_advanced() - Create decompression context
|
||||
* @custom_mem: Custom allocator.
|
||||
*
|
||||
* Return: NULL on error, pointer to decompression context otherwise.
|
||||
*/
|
||||
zstd_dctx *zstd_create_dctx_advanced(zstd_custom_mem custom_mem);
|
||||
|
||||
/**
|
||||
* zstd_free_dctx() -- Free decompression context
|
||||
* @dctx: Pointer to decompression context.
|
||||
* Return: Always 0.
|
||||
*/
|
||||
size_t zstd_free_dctx(zstd_dctx *dctx);
|
||||
|
||||
/**
|
||||
* zstd_decompress_using_ddict() - decompress src into dst using a dictionary
|
||||
* @dctx: The decompression context.
|
||||
* @dst: The buffer to decompress src into.
|
||||
* @dst_capacity: The size of the destination buffer. Must be at least as large
|
||||
* as the decompressed size. If the caller cannot upper bound the
|
||||
* decompressed size, then it's better to use the streaming API.
|
||||
* @src: The zstd compressed data to decompress. Multiple concatenated
|
||||
* frames and skippable frames are allowed.
|
||||
* @src_size: The exact size of the data to decompress.
|
||||
* @ddict: The dictionary to be used.
|
||||
*
|
||||
* Return: The decompressed size or an error, which can be checked using
|
||||
* zstd_is_error().
|
||||
*/
|
||||
size_t zstd_decompress_using_ddict(zstd_dctx *dctx,
|
||||
void *dst, size_t dst_capacity, const void *src, size_t src_size,
|
||||
const zstd_ddict *ddict);
|
||||
|
||||
|
||||
/* ====== Streaming Buffers ====== */
|
||||
|
||||
/**
|
||||
@ -257,6 +448,16 @@ typedef ZSTD_CStream zstd_cstream;
|
||||
*/
|
||||
size_t zstd_cstream_workspace_bound(const zstd_compression_parameters *cparams);
|
||||
|
||||
/**
|
||||
* zstd_cstream_workspace_bound_with_ext_seq_prod() - memory needed to initialize
|
||||
* a zstd_cstream when using the block-level external sequence producer API.
|
||||
* @cparams: The compression parameters to be used for compression.
|
||||
*
|
||||
* Return: A lower bound on the size of the workspace that is passed to
|
||||
* zstd_init_cstream().
|
||||
*/
|
||||
size_t zstd_cstream_workspace_bound_with_ext_seq_prod(const zstd_compression_parameters *cparams);
|
||||
|
||||
/**
|
||||
* zstd_init_cstream() - initialize a zstd streaming compression context
|
||||
* @parameters The zstd parameters to use for compression.
|
||||
@ -416,6 +617,18 @@ size_t zstd_decompress_stream(zstd_dstream *dstream, zstd_out_buffer *output,
|
||||
*/
|
||||
size_t zstd_find_frame_compressed_size(const void *src, size_t src_size);
|
||||
|
||||
/**
|
||||
* zstd_register_sequence_producer() - exposes the zstd library function
|
||||
* ZSTD_registerSequenceProducer(). This is used for the block-level external
|
||||
* sequence producer API. See upstream zstd.h for detailed documentation.
|
||||
*/
|
||||
typedef ZSTD_sequenceProducer_F zstd_sequence_producer_f;
|
||||
void zstd_register_sequence_producer(
|
||||
zstd_cctx *cctx,
|
||||
void* sequence_producer_state,
|
||||
zstd_sequence_producer_f sequence_producer
|
||||
);
|
||||
|
||||
/**
|
||||
* struct zstd_frame_params - zstd frame parameters stored in the frame header
|
||||
* @frameContentSize: The frame content size, or ZSTD_CONTENTSIZE_UNKNOWN if not
|
||||
@ -429,7 +642,7 @@ size_t zstd_find_frame_compressed_size(const void *src, size_t src_size);
|
||||
*
|
||||
* See zstd_lib.h.
|
||||
*/
|
||||
typedef ZSTD_frameHeader zstd_frame_header;
|
||||
typedef ZSTD_FrameHeader zstd_frame_header;
|
||||
|
||||
/**
|
||||
* zstd_get_frame_header() - extracts parameters from a zstd or skippable frame
|
||||
@ -444,4 +657,35 @@ typedef ZSTD_frameHeader zstd_frame_header;
|
||||
size_t zstd_get_frame_header(zstd_frame_header *params, const void *src,
|
||||
size_t src_size);
|
||||
|
||||
/**
|
||||
* struct zstd_sequence - a sequence of literals or a match
|
||||
*
|
||||
* @offset: The offset of the match
|
||||
* @litLength: The literal length of the sequence
|
||||
* @matchLength: The match length of the sequence
|
||||
* @rep: Represents which repeat offset is used
|
||||
*/
|
||||
typedef ZSTD_Sequence zstd_sequence;
|
||||
|
||||
/**
|
||||
* zstd_compress_sequences_and_literals() - compress an array of zstd_sequence and literals
|
||||
*
|
||||
* @cctx: The zstd compression context.
|
||||
* @dst: The buffer to compress the data into.
|
||||
* @dst_capacity: The size of the destination buffer.
|
||||
* @in_seqs: The array of zstd_sequence to compress.
|
||||
* @in_seqs_size: The number of sequences in in_seqs.
|
||||
* @literals: The literals associated to the sequences to be compressed.
|
||||
* @lit_size: The size of the literals in the literals buffer.
|
||||
* @lit_capacity: The size of the literals buffer.
|
||||
* @decompressed_size: The size of the input data
|
||||
*
|
||||
* Return: The compressed size or an error, which can be checked using
|
||||
* zstd_is_error().
|
||||
*/
|
||||
size_t zstd_compress_sequences_and_literals(zstd_cctx *cctx, void* dst, size_t dst_capacity,
|
||||
const zstd_sequence *in_seqs, size_t in_seqs_size,
|
||||
const void* literals, size_t lit_size, size_t lit_capacity,
|
||||
size_t decompressed_size);
|
||||
|
||||
#endif /* LINUX_ZSTD_H */
|
||||
|
@ -15,7 +15,7 @@
|
||||
/*-****************************************
|
||||
* Dependencies
|
||||
******************************************/
|
||||
#include <asm/unaligned.h> /* get_unaligned, put_unaligned* */
|
||||
#include <linux/unaligned.h> /* get_unaligned, put_unaligned* */
|
||||
#include <linux/compiler.h> /* inline */
|
||||
#include <linux/swab.h> /* swab32, swab64 */
|
||||
#include <linux/types.h> /* size_t, ptrdiff_t */
|
||||
|
@ -296,7 +296,7 @@ XXH_API void xxh64_copy_state(struct xxh64_state *dst, const struct xxh64_state
|
||||
* - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
#include <asm/unaligned.h>
|
||||
#include <linux/unaligned.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "common/zstd_deps.h"
|
||||
#include "common/zstd_internal.h"
|
||||
#include "compress/zstd_compress_internal.h"
|
||||
|
||||
#define ZSTD_FORWARD_IF_ERR(ret) \
|
||||
do { \
|
||||
@ -66,6 +67,12 @@ int zstd_max_clevel(void)
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_max_clevel);
|
||||
|
||||
int zstd_default_clevel(void)
|
||||
{
|
||||
return ZSTD_defaultCLevel();
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_default_clevel);
|
||||
|
||||
size_t zstd_compress_bound(size_t src_size)
|
||||
{
|
||||
return ZSTD_compressBound(src_size);
|
||||
@ -79,12 +86,71 @@ zstd_parameters zstd_get_params(int level,
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_get_params);
|
||||
|
||||
zstd_compression_parameters zstd_get_cparams(int level,
|
||||
unsigned long long estimated_src_size, size_t dict_size)
|
||||
{
|
||||
return ZSTD_getCParams(level, estimated_src_size, dict_size);
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_get_cparams);
|
||||
|
||||
size_t zstd_cctx_set_param(zstd_cctx *cctx, ZSTD_cParameter param, int value)
|
||||
{
|
||||
return ZSTD_CCtx_setParameter(cctx, param, value);
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_cctx_set_param);
|
||||
|
||||
size_t zstd_cctx_workspace_bound(const zstd_compression_parameters *cparams)
|
||||
{
|
||||
return ZSTD_estimateCCtxSize_usingCParams(*cparams);
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_cctx_workspace_bound);
|
||||
|
||||
// Used by zstd_cctx_workspace_bound_with_ext_seq_prod()
|
||||
static size_t dummy_external_sequence_producer(
|
||||
void *sequenceProducerState,
|
||||
ZSTD_Sequence *outSeqs, size_t outSeqsCapacity,
|
||||
const void *src, size_t srcSize,
|
||||
const void *dict, size_t dictSize,
|
||||
int compressionLevel,
|
||||
size_t windowSize)
|
||||
{
|
||||
(void)sequenceProducerState;
|
||||
(void)outSeqs; (void)outSeqsCapacity;
|
||||
(void)src; (void)srcSize;
|
||||
(void)dict; (void)dictSize;
|
||||
(void)compressionLevel;
|
||||
(void)windowSize;
|
||||
return ZSTD_SEQUENCE_PRODUCER_ERROR;
|
||||
}
|
||||
|
||||
static void init_cctx_params_from_compress_params(
|
||||
ZSTD_CCtx_params *cctx_params,
|
||||
const zstd_compression_parameters *compress_params)
|
||||
{
|
||||
ZSTD_parameters zstd_params;
|
||||
memset(&zstd_params, 0, sizeof(zstd_params));
|
||||
zstd_params.cParams = *compress_params;
|
||||
ZSTD_CCtxParams_init_advanced(cctx_params, zstd_params);
|
||||
}
|
||||
|
||||
size_t zstd_cctx_workspace_bound_with_ext_seq_prod(const zstd_compression_parameters *compress_params)
|
||||
{
|
||||
ZSTD_CCtx_params cctx_params;
|
||||
init_cctx_params_from_compress_params(&cctx_params, compress_params);
|
||||
ZSTD_CCtxParams_registerSequenceProducer(&cctx_params, NULL, dummy_external_sequence_producer);
|
||||
return ZSTD_estimateCCtxSize_usingCCtxParams(&cctx_params);
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_cctx_workspace_bound_with_ext_seq_prod);
|
||||
|
||||
size_t zstd_cstream_workspace_bound_with_ext_seq_prod(const zstd_compression_parameters *compress_params)
|
||||
{
|
||||
ZSTD_CCtx_params cctx_params;
|
||||
init_cctx_params_from_compress_params(&cctx_params, compress_params);
|
||||
ZSTD_CCtxParams_registerSequenceProducer(&cctx_params, NULL, dummy_external_sequence_producer);
|
||||
return ZSTD_estimateCStreamSize_usingCCtxParams(&cctx_params);
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_cstream_workspace_bound_with_ext_seq_prod);
|
||||
|
||||
zstd_cctx *zstd_init_cctx(void *workspace, size_t workspace_size)
|
||||
{
|
||||
if (workspace == NULL)
|
||||
@ -93,6 +159,33 @@ zstd_cctx *zstd_init_cctx(void *workspace, size_t workspace_size)
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_init_cctx);
|
||||
|
||||
zstd_cctx *zstd_create_cctx_advanced(zstd_custom_mem custom_mem)
|
||||
{
|
||||
return ZSTD_createCCtx_advanced(custom_mem);
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_create_cctx_advanced);
|
||||
|
||||
size_t zstd_free_cctx(zstd_cctx *cctx)
|
||||
{
|
||||
return ZSTD_freeCCtx(cctx);
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_free_cctx);
|
||||
|
||||
zstd_cdict *zstd_create_cdict_byreference(const void *dict, size_t dict_size,
|
||||
zstd_compression_parameters cparams,
|
||||
zstd_custom_mem custom_mem)
|
||||
{
|
||||
return ZSTD_createCDict_advanced(dict, dict_size, ZSTD_dlm_byRef,
|
||||
ZSTD_dct_auto, cparams, custom_mem);
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_create_cdict_byreference);
|
||||
|
||||
size_t zstd_free_cdict(zstd_cdict *cdict)
|
||||
{
|
||||
return ZSTD_freeCDict(cdict);
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_free_cdict);
|
||||
|
||||
size_t zstd_compress_cctx(zstd_cctx *cctx, void *dst, size_t dst_capacity,
|
||||
const void *src, size_t src_size, const zstd_parameters *parameters)
|
||||
{
|
||||
@ -101,6 +194,15 @@ size_t zstd_compress_cctx(zstd_cctx *cctx, void *dst, size_t dst_capacity,
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_compress_cctx);
|
||||
|
||||
size_t zstd_compress_using_cdict(zstd_cctx *cctx, void *dst,
|
||||
size_t dst_capacity, const void *src, size_t src_size,
|
||||
const ZSTD_CDict *cdict)
|
||||
{
|
||||
return ZSTD_compress_usingCDict(cctx, dst, dst_capacity,
|
||||
src, src_size, cdict);
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_compress_using_cdict);
|
||||
|
||||
size_t zstd_cstream_workspace_bound(const zstd_compression_parameters *cparams)
|
||||
{
|
||||
return ZSTD_estimateCStreamSize_usingCParams(*cparams);
|
||||
@ -160,5 +262,25 @@ size_t zstd_end_stream(zstd_cstream *cstream, zstd_out_buffer *output)
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_end_stream);
|
||||
|
||||
void zstd_register_sequence_producer(
|
||||
zstd_cctx *cctx,
|
||||
void* sequence_producer_state,
|
||||
zstd_sequence_producer_f sequence_producer
|
||||
) {
|
||||
ZSTD_registerSequenceProducer(cctx, sequence_producer_state, sequence_producer);
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_register_sequence_producer);
|
||||
|
||||
size_t zstd_compress_sequences_and_literals(zstd_cctx *cctx, void* dst, size_t dst_capacity,
|
||||
const zstd_sequence *in_seqs, size_t in_seqs_size,
|
||||
const void* literals, size_t lit_size, size_t lit_capacity,
|
||||
size_t decompressed_size)
|
||||
{
|
||||
return ZSTD_compressSequencesAndLiterals(cctx, dst, dst_capacity, in_seqs,
|
||||
in_seqs_size, literals, lit_size,
|
||||
lit_capacity, decompressed_size);
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_compress_sequences_and_literals);
|
||||
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
MODULE_DESCRIPTION("Zstd Compressor");
|
||||
|
@ -44,6 +44,33 @@ size_t zstd_dctx_workspace_bound(void)
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_dctx_workspace_bound);
|
||||
|
||||
zstd_dctx *zstd_create_dctx_advanced(zstd_custom_mem custom_mem)
|
||||
{
|
||||
return ZSTD_createDCtx_advanced(custom_mem);
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_create_dctx_advanced);
|
||||
|
||||
size_t zstd_free_dctx(zstd_dctx *dctx)
|
||||
{
|
||||
return ZSTD_freeDCtx(dctx);
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_free_dctx);
|
||||
|
||||
zstd_ddict *zstd_create_ddict_byreference(const void *dict, size_t dict_size,
|
||||
zstd_custom_mem custom_mem)
|
||||
{
|
||||
return ZSTD_createDDict_advanced(dict, dict_size, ZSTD_dlm_byRef,
|
||||
ZSTD_dct_auto, custom_mem);
|
||||
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_create_ddict_byreference);
|
||||
|
||||
size_t zstd_free_ddict(zstd_ddict *ddict)
|
||||
{
|
||||
return ZSTD_freeDDict(ddict);
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_free_ddict);
|
||||
|
||||
zstd_dctx *zstd_init_dctx(void *workspace, size_t workspace_size)
|
||||
{
|
||||
if (workspace == NULL)
|
||||
@ -59,6 +86,15 @@ size_t zstd_decompress_dctx(zstd_dctx *dctx, void *dst, size_t dst_capacity,
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_decompress_dctx);
|
||||
|
||||
size_t zstd_decompress_using_ddict(zstd_dctx *dctx,
|
||||
void *dst, size_t dst_capacity, const void* src, size_t src_size,
|
||||
const zstd_ddict* ddict)
|
||||
{
|
||||
return ZSTD_decompress_usingDDict(dctx, dst, dst_capacity, src,
|
||||
src_size, ddict);
|
||||
}
|
||||
EXPORT_SYMBOL(zstd_decompress_using_ddict);
|
||||
|
||||
size_t zstd_dstream_workspace_bound(size_t max_window_size)
|
||||
{
|
||||
return ZSTD_estimateDStreamSize(max_window_size);
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <cstdio>
|
||||
#include <mutex>
|
||||
#include <chrono>
|
||||
|
||||
namespace pzstd {
|
||||
|
||||
|
@ -322,7 +322,7 @@ Options::Status Options::parse(int argc, const char **argv) {
|
||||
g_utilDisplayLevel = verbosity;
|
||||
// Remove local input files that are symbolic links
|
||||
if (!followLinks) {
|
||||
std::remove_if(localInputFiles.begin(), localInputFiles.end(),
|
||||
localInputFiles.erase(std::remove_if(localInputFiles.begin(), localInputFiles.end(),
|
||||
[&](const char *path) {
|
||||
bool isLink = UTIL_isLink(path);
|
||||
if (isLink && verbosity >= 2) {
|
||||
@ -332,7 +332,7 @@ Options::Status Options::parse(int argc, const char **argv) {
|
||||
path);
|
||||
}
|
||||
return isLink;
|
||||
});
|
||||
}), localInputFiles.end());
|
||||
}
|
||||
|
||||
// Translate input files/directories into files to (de)compress
|
||||
|
@ -269,7 +269,10 @@ static void compress(
|
||||
std::shared_ptr<BufferWorkQueue> out,
|
||||
size_t maxInputSize) {
|
||||
auto& errorHolder = state.errorHolder;
|
||||
auto guard = makeScopeGuard([&] { out->finish(); });
|
||||
auto guard = makeScopeGuard([&] {
|
||||
in->finish();
|
||||
out->finish();
|
||||
});
|
||||
// Initialize the CCtx
|
||||
auto ctx = state.cStreamPool->get();
|
||||
if (!errorHolder.check(ctx != nullptr, "Failed to allocate ZSTD_CStream")) {
|
||||
@ -431,7 +434,10 @@ static void decompress(
|
||||
std::shared_ptr<BufferWorkQueue> in,
|
||||
std::shared_ptr<BufferWorkQueue> out) {
|
||||
auto& errorHolder = state.errorHolder;
|
||||
auto guard = makeScopeGuard([&] { out->finish(); });
|
||||
auto guard = makeScopeGuard([&] {
|
||||
in->finish();
|
||||
out->finish();
|
||||
});
|
||||
// Initialize the DCtx
|
||||
auto ctx = state.dStreamPool->get();
|
||||
if (!errorHolder.check(ctx != nullptr, "Failed to allocate ZSTD_DStream")) {
|
||||
@ -578,6 +584,7 @@ std::uint64_t writeFile(
|
||||
FILE* outputFd,
|
||||
bool decompress) {
|
||||
auto& errorHolder = state.errorHolder;
|
||||
auto outsFinishGuard = makeScopeGuard([&outs] { outs.finish(); });
|
||||
auto lineClearGuard = makeScopeGuard([&state] {
|
||||
state.log.clear(kLogInfo);
|
||||
});
|
||||
@ -585,6 +592,7 @@ std::uint64_t writeFile(
|
||||
std::shared_ptr<BufferWorkQueue> out;
|
||||
// Grab the output queue for each decompression job (in order).
|
||||
while (outs.pop(out)) {
|
||||
auto outFinishGuard = makeScopeGuard([&out] { out->finish(); });
|
||||
if (errorHolder.hasError()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -7,9 +7,7 @@
|
||||
* in the COPYING file in the root directory of this source tree).
|
||||
*/
|
||||
#include "Pzstd.h"
|
||||
extern "C" {
|
||||
#include "datagen.h"
|
||||
}
|
||||
#include "test/RoundTrip.h"
|
||||
#include "utils/ScopeGuard.h"
|
||||
|
||||
|
@ -6,9 +6,7 @@
|
||||
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||
* in the COPYING file in the root directory of this source tree).
|
||||
*/
|
||||
extern "C" {
|
||||
#include "datagen.h"
|
||||
}
|
||||
#include "Options.h"
|
||||
#include "test/RoundTrip.h"
|
||||
#include "utils/ScopeGuard.h"
|
||||
|
@ -115,13 +115,14 @@ class WorkQueue {
|
||||
}
|
||||
|
||||
/**
|
||||
* Promise that `push()` won't be called again, so once the queue is empty
|
||||
* there will never any more work.
|
||||
* Promise that either the reader side or the writer side is done.
|
||||
* If the writer is done, `push()` won't be called again, so once the queue
|
||||
* is empty there will never be any more work. If the reader is done, `pop()`
|
||||
* won't be called again, so further items pushed will just be ignored.
|
||||
*/
|
||||
void finish() {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
assert(!done_);
|
||||
done_ = true;
|
||||
}
|
||||
readerCv_.notify_all();
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
ZSTDLIB_PATH = ../../../lib
|
||||
ZSTDLIB_NAME = libzstd.a
|
||||
# Parallel tools only make sense against multi-threaded libzstd
|
||||
ZSTDLIB_TARGET = $(ZSTDLIB_NAME)-mt
|
||||
ZSTDLIB = $(ZSTDLIB_PATH)/$(ZSTDLIB_NAME)
|
||||
|
||||
CPPFLAGS += -DXXH_NAMESPACE=ZSTD_ -I../ -I../../../lib -I../../../lib/common
|
||||
@ -28,7 +30,7 @@ all: seekable_compression seekable_decompression seekable_decompression_mem \
|
||||
parallel_processing
|
||||
|
||||
$(ZSTDLIB):
|
||||
make -C $(ZSTDLIB_PATH) $(ZSTDLIB_NAME)
|
||||
$(MAKE) -C $(ZSTDLIB_PATH) $(ZSTDLIB_TARGET)
|
||||
|
||||
seekable_compression : seekable_compression.c $(SEEKABLE_OBJS)
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
#include "xxhash.h"
|
||||
|
||||
#define ZSTD_MULTITHREAD 1
|
||||
#include "threading.h"
|
||||
#include "pool.h" // use zstd thread pool for demo
|
||||
|
||||
#include "../zstd_seekable.h"
|
||||
@ -72,114 +74,87 @@ static size_t fclose_orDie(FILE* file)
|
||||
exit(6);
|
||||
}
|
||||
|
||||
static void fseek_orDie(FILE* file, long int offset, int origin)
|
||||
{
|
||||
if (!fseek(file, offset, origin)) {
|
||||
if (!fflush(file)) return;
|
||||
}
|
||||
/* error */
|
||||
perror("fseek");
|
||||
exit(7);
|
||||
}
|
||||
|
||||
static long int ftell_orDie(FILE* file)
|
||||
{
|
||||
long int off = ftell(file);
|
||||
if (off != -1) return off;
|
||||
/* error */
|
||||
perror("ftell");
|
||||
exit(8);
|
||||
}
|
||||
struct state {
|
||||
FILE* fout;
|
||||
ZSTD_pthread_mutex_t mutex;
|
||||
size_t nextID;
|
||||
struct job* pending;
|
||||
ZSTD_frameLog* frameLog;
|
||||
const int compressionLevel;
|
||||
};
|
||||
|
||||
struct job {
|
||||
const void* src;
|
||||
size_t id;
|
||||
struct job* next;
|
||||
struct state* state;
|
||||
|
||||
void* src;
|
||||
size_t srcSize;
|
||||
void* dst;
|
||||
size_t dstSize;
|
||||
|
||||
unsigned checksum;
|
||||
|
||||
int compressionLevel;
|
||||
int done;
|
||||
};
|
||||
|
||||
static void addPending_inmutex(struct state* state, struct job* job)
|
||||
{
|
||||
struct job** p = &state->pending;
|
||||
while (*p && (*p)->id < job->id)
|
||||
p = &(*p)->next;
|
||||
job->next = *p;
|
||||
*p = job;
|
||||
}
|
||||
|
||||
static void flushFrame(struct state* state, struct job* job)
|
||||
{
|
||||
fwrite_orDie(job->dst, job->dstSize, state->fout);
|
||||
free(job->dst);
|
||||
|
||||
size_t ret = ZSTD_seekable_logFrame(state->frameLog, (unsigned)job->dstSize, (unsigned)job->srcSize, job->checksum);
|
||||
if (ZSTD_isError(ret)) {
|
||||
fprintf(stderr, "ZSTD_seekable_logFrame() error : %s \n", ZSTD_getErrorName(ret));
|
||||
exit(12);
|
||||
}
|
||||
}
|
||||
|
||||
static void flushPending_inmutex(struct state* state)
|
||||
{
|
||||
while (state->pending && state->pending->id == state->nextID) {
|
||||
struct job* p = state->pending;
|
||||
state->pending = p->next;
|
||||
flushFrame(state, p);
|
||||
free(p);
|
||||
state->nextID++;
|
||||
}
|
||||
}
|
||||
|
||||
static void finishFrame(struct job* job)
|
||||
{
|
||||
struct state *state = job->state;
|
||||
ZSTD_pthread_mutex_lock(&state->mutex);
|
||||
addPending_inmutex(state, job);
|
||||
flushPending_inmutex(state);
|
||||
ZSTD_pthread_mutex_unlock(&state->mutex);
|
||||
}
|
||||
|
||||
static void compressFrame(void* opaque)
|
||||
{
|
||||
struct job* job = opaque;
|
||||
|
||||
job->checksum = XXH64(job->src, job->srcSize, 0);
|
||||
job->checksum = (unsigned)XXH64(job->src, job->srcSize, 0);
|
||||
|
||||
size_t ret = ZSTD_compress(job->dst, job->dstSize, job->src, job->srcSize, job->compressionLevel);
|
||||
size_t ret = ZSTD_compress(job->dst, job->dstSize, job->src, job->srcSize, job->state->compressionLevel);
|
||||
if (ZSTD_isError(ret)) {
|
||||
fprintf(stderr, "ZSTD_compress() error : %s \n", ZSTD_getErrorName(ret));
|
||||
exit(20);
|
||||
}
|
||||
|
||||
job->dstSize = ret;
|
||||
job->done = 1;
|
||||
}
|
||||
|
||||
static void compressFile_orDie(const char* fname, const char* outName, int cLevel, unsigned frameSize, int nbThreads)
|
||||
{
|
||||
POOL_ctx* pool = POOL_create(nbThreads, nbThreads);
|
||||
if (pool == NULL) { fprintf(stderr, "POOL_create() error \n"); exit(9); }
|
||||
// No longer need
|
||||
free(job->src);
|
||||
job->src = NULL;
|
||||
|
||||
FILE* const fin = fopen_orDie(fname, "rb");
|
||||
FILE* const fout = fopen_orDie(outName, "wb");
|
||||
|
||||
if (ZSTD_compressBound(frameSize) > 0xFFFFFFFFU) { fprintf(stderr, "Frame size too large \n"); exit(10); }
|
||||
unsigned dstSize = ZSTD_compressBound(frameSize);
|
||||
|
||||
|
||||
fseek_orDie(fin, 0, SEEK_END);
|
||||
long int length = ftell_orDie(fin);
|
||||
fseek_orDie(fin, 0, SEEK_SET);
|
||||
|
||||
size_t numFrames = (length + frameSize - 1) / frameSize;
|
||||
|
||||
struct job* jobs = malloc_orDie(sizeof(struct job) * numFrames);
|
||||
|
||||
size_t i;
|
||||
for(i = 0; i < numFrames; i++) {
|
||||
void* in = malloc_orDie(frameSize);
|
||||
void* out = malloc_orDie(dstSize);
|
||||
|
||||
size_t inSize = fread_orDie(in, frameSize, fin);
|
||||
|
||||
jobs[i].src = in;
|
||||
jobs[i].srcSize = inSize;
|
||||
jobs[i].dst = out;
|
||||
jobs[i].dstSize = dstSize;
|
||||
jobs[i].compressionLevel = cLevel;
|
||||
jobs[i].done = 0;
|
||||
POOL_add(pool, compressFrame, &jobs[i]);
|
||||
}
|
||||
|
||||
ZSTD_frameLog* fl = ZSTD_seekable_createFrameLog(1);
|
||||
if (fl == NULL) { fprintf(stderr, "ZSTD_seekable_createFrameLog() failed \n"); exit(11); }
|
||||
for (i = 0; i < numFrames; i++) {
|
||||
while (!jobs[i].done) SLEEP(5); /* wake up every 5 milliseconds to check */
|
||||
fwrite_orDie(jobs[i].dst, jobs[i].dstSize, fout);
|
||||
free((void*)jobs[i].src);
|
||||
free(jobs[i].dst);
|
||||
|
||||
size_t ret = ZSTD_seekable_logFrame(fl, jobs[i].dstSize, jobs[i].srcSize, jobs[i].checksum);
|
||||
if (ZSTD_isError(ret)) { fprintf(stderr, "ZSTD_seekable_logFrame() error : %s \n", ZSTD_getErrorName(ret)); }
|
||||
}
|
||||
|
||||
{ unsigned char seekTableBuff[1024];
|
||||
ZSTD_outBuffer out = {seekTableBuff, 1024, 0};
|
||||
while (ZSTD_seekable_writeSeekTable(fl, &out) != 0) {
|
||||
fwrite_orDie(seekTableBuff, out.pos, fout);
|
||||
out.pos = 0;
|
||||
}
|
||||
fwrite_orDie(seekTableBuff, out.pos, fout);
|
||||
}
|
||||
|
||||
ZSTD_seekable_freeFrameLog(fl);
|
||||
free(jobs);
|
||||
fclose_orDie(fout);
|
||||
fclose_orDie(fin);
|
||||
finishFrame(job);
|
||||
}
|
||||
|
||||
static const char* createOutFilename_orDie(const char* filename)
|
||||
@ -193,6 +168,72 @@ static const char* createOutFilename_orDie(const char* filename)
|
||||
return (const char*)outSpace;
|
||||
}
|
||||
|
||||
static void openInOut_orDie(const char* fname, FILE** fin, FILE** fout) {
|
||||
if (strcmp(fname, "-") == 0) {
|
||||
*fin = stdin;
|
||||
*fout = stdout;
|
||||
} else {
|
||||
*fin = fopen_orDie(fname, "rb");
|
||||
const char* outName = createOutFilename_orDie(fname);
|
||||
*fout = fopen_orDie(outName, "wb");
|
||||
}
|
||||
}
|
||||
|
||||
static void compressFile_orDie(const char* fname, int cLevel, unsigned frameSize, size_t nbThreads)
|
||||
{
|
||||
struct state state = {
|
||||
.nextID = 0,
|
||||
.pending = NULL,
|
||||
.compressionLevel = cLevel,
|
||||
};
|
||||
ZSTD_pthread_mutex_init(&state.mutex, NULL);
|
||||
state.frameLog = ZSTD_seekable_createFrameLog(1);
|
||||
if (state.frameLog == NULL) { fprintf(stderr, "ZSTD_seekable_createFrameLog() failed \n"); exit(11); }
|
||||
|
||||
POOL_ctx* pool = POOL_create(nbThreads, nbThreads);
|
||||
if (pool == NULL) { fprintf(stderr, "POOL_create() error \n"); exit(9); }
|
||||
|
||||
FILE* fin;
|
||||
openInOut_orDie(fname, &fin, &state.fout);
|
||||
|
||||
if (ZSTD_compressBound(frameSize) > 0xFFFFFFFFU) { fprintf(stderr, "Frame size too large \n"); exit(10); }
|
||||
size_t dstSize = ZSTD_compressBound(frameSize);
|
||||
|
||||
for (size_t id = 0; 1; id++) {
|
||||
struct job* job = malloc_orDie(sizeof(struct job));
|
||||
job->id = id;
|
||||
job->next = NULL;
|
||||
job->state = &state;
|
||||
job->src = malloc_orDie(frameSize);
|
||||
job->dst = malloc_orDie(dstSize);
|
||||
job->srcSize = fread_orDie(job->src, frameSize, fin);
|
||||
job->dstSize = dstSize;
|
||||
POOL_add(pool, compressFrame, job);
|
||||
if (feof(fin))
|
||||
break;
|
||||
}
|
||||
|
||||
POOL_joinJobs(pool);
|
||||
POOL_free(pool);
|
||||
if (state.pending) {
|
||||
fprintf(stderr, "Unexpected leftover output blocks!\n");
|
||||
exit(13);
|
||||
}
|
||||
|
||||
{ unsigned char seekTableBuff[1024];
|
||||
ZSTD_outBuffer out = {seekTableBuff, 1024, 0};
|
||||
while (ZSTD_seekable_writeSeekTable(state.frameLog, &out) != 0) {
|
||||
fwrite_orDie(seekTableBuff, out.pos, state.fout);
|
||||
out.pos = 0;
|
||||
}
|
||||
fwrite_orDie(seekTableBuff, out.pos, state.fout);
|
||||
}
|
||||
|
||||
ZSTD_seekable_freeFrameLog(state.frameLog);
|
||||
fclose_orDie(state.fout);
|
||||
fclose_orDie(fin);
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
const char* const exeName = argv[0];
|
||||
if (argc!=4) {
|
||||
@ -204,10 +245,9 @@ int main(int argc, const char** argv) {
|
||||
|
||||
{ const char* const inFileName = argv[1];
|
||||
unsigned const frameSize = (unsigned)atoi(argv[2]);
|
||||
int const nbThreads = atoi(argv[3]);
|
||||
size_t const nbThreads = (size_t)atoi(argv[3]);
|
||||
|
||||
const char* const outFileName = createOutFilename_orDie(inFileName);
|
||||
compressFile_orDie(inFileName, outFileName, 5, frameSize, nbThreads);
|
||||
compressFile_orDie(inFileName, 5, frameSize, nbThreads);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -100,13 +100,11 @@ struct sum_job {
|
||||
const char* fname;
|
||||
unsigned long long sum;
|
||||
unsigned frameNb;
|
||||
int done;
|
||||
};
|
||||
|
||||
static void sumFrame(void* opaque)
|
||||
{
|
||||
struct sum_job* job = (struct sum_job*)opaque;
|
||||
job->done = 0;
|
||||
|
||||
FILE* const fin = fopen_orDie(job->fname, "rb");
|
||||
|
||||
@ -128,7 +126,6 @@ static void sumFrame(void* opaque)
|
||||
sum += data[i];
|
||||
}
|
||||
job->sum = sum;
|
||||
job->done = 1;
|
||||
|
||||
fclose(fin);
|
||||
ZSTD_seekable_free(seekable);
|
||||
@ -153,14 +150,14 @@ static void sumFile_orDie(const char* fname, int nbThreads)
|
||||
|
||||
unsigned fnb;
|
||||
for (fnb = 0; fnb < numFrames; fnb++) {
|
||||
jobs[fnb] = (struct sum_job){ fname, 0, fnb, 0 };
|
||||
jobs[fnb] = (struct sum_job){ fname, 0, fnb };
|
||||
POOL_add(pool, sumFrame, &jobs[fnb]);
|
||||
}
|
||||
POOL_joinJobs(pool);
|
||||
|
||||
unsigned long long total = 0;
|
||||
|
||||
for (fnb = 0; fnb < numFrames; fnb++) {
|
||||
while (!jobs[fnb].done) SLEEP(5); /* wake up every 5 milliseconds to check */
|
||||
total += jobs[fnb].sum;
|
||||
}
|
||||
|
||||
|
1
contrib/seekable_format/tests/.gitignore
vendored
1
contrib/seekable_format/tests/.gitignore
vendored
@ -1 +1,2 @@
|
||||
seekable_tests
|
||||
data.txt
|
||||
|
@ -24,7 +24,7 @@ SEEKABLE_OBJS = ../zstdseek_compress.c ../zstdseek_decompress.c $(ZSTDLIB)
|
||||
.PHONY: default clean test
|
||||
default: test
|
||||
|
||||
test: seekable_tests
|
||||
test: seekable_tests parallel_compression_test
|
||||
./seekable_tests
|
||||
|
||||
$(ZSTDLIB):
|
||||
@ -32,7 +32,27 @@ $(ZSTDLIB):
|
||||
|
||||
seekable_tests : $(SEEKABLE_OBJS)
|
||||
|
||||
EXAMPLES_PATH = ../examples
|
||||
PARALLEL_COMPRESSION = $(EXAMPLES_PATH)/parallel_compression
|
||||
|
||||
DATAGEN_PATH = ../../../tests
|
||||
DATAGEN = $(DATAGEN_PATH)/datagen
|
||||
|
||||
$(PARALLEL_COMPRESSION):
|
||||
$(MAKE) -C $(EXAMPLES_PATH) parallel_compression
|
||||
|
||||
$(DATAGEN):
|
||||
$(MAKE) -C $(DATAGEN_PATH) datagen
|
||||
|
||||
data.txt: $(DATAGEN)
|
||||
$(DATAGEN) -g100M > $@
|
||||
|
||||
parallel_compression_test: $(PARALLEL_COMPRESSION) data.txt
|
||||
ulimit -Sv 102400; $(PARALLEL_COMPRESSION) data.txt 1048576 2
|
||||
|
||||
.PHONY: parallel_compression_test parallel_comp
|
||||
|
||||
clean:
|
||||
@$(RM) core *.o tmp* result* *.zst \
|
||||
seekable_tests
|
||||
seekable_tests data.txt
|
||||
@echo Cleaning completed
|
||||
|
@ -316,6 +316,10 @@ int main(int argc, const char** argv)
|
||||
for (pos = 0; pos < inSize; pos += 2) {
|
||||
size_t const decStatus = ZSTD_seekable_decompress(stream, outBuffer, 1, pos);
|
||||
if (decStatus != 1 || outBuffer[0] != inBuffer[pos]) {
|
||||
free(seekBuffer);
|
||||
free(outBuffer);
|
||||
ZSTD_seekable_freeCStream(zscs);
|
||||
ZSTD_seekable_free(stream);
|
||||
goto _test_error;
|
||||
}
|
||||
}
|
||||
@ -323,6 +327,10 @@ int main(int argc, const char** argv)
|
||||
/* We read more than the compressed size, meaning there were some rereads.
|
||||
This is unneeded because we only seeked forward. */
|
||||
printf("Too much data read: %zu read, with compressed size %zu\n", buffWrapper.totalRead, seekSize);
|
||||
free(seekBuffer);
|
||||
free(outBuffer);
|
||||
ZSTD_seekable_freeCStream(zscs);
|
||||
ZSTD_seekable_free(stream);
|
||||
goto _test_error;
|
||||
}
|
||||
|
||||
@ -342,6 +350,10 @@ int main(int argc, const char** argv)
|
||||
for (idx = 0; idx < sizeof(tests) / sizeof(tests[0]); idx++) {
|
||||
size_t const decStatus = ZSTD_seekable_decompress(stream, outBuffer, tests[idx].size, tests[idx].offset);
|
||||
if (decStatus != tests[idx].size || memcmp(outBuffer, inBuffer + tests[idx].offset, tests[idx].size) != 0) {
|
||||
free(seekBuffer);
|
||||
free(outBuffer);
|
||||
ZSTD_seekable_freeCStream(zscs);
|
||||
ZSTD_seekable_free(stream);
|
||||
goto _test_error;
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
#ifndef SEEKABLE_H
|
||||
#define SEEKABLE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "zstd.h" /* ZSTDLIB_API */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "zstd.h" /* ZSTDLIB_API */
|
||||
|
||||
|
||||
#define ZSTD_seekTableFooterSize 9
|
||||
|
||||
|
@ -77,7 +77,10 @@
|
||||
/* ************************************************************
|
||||
* Avoid fseek()'s 2GiB barrier with MSVC, macOS, *BSD, MinGW
|
||||
***************************************************************/
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
#if defined(LIBC_NO_FSEEKO)
|
||||
/* Some older libc implementations don't include these functions (e.g. Bionic < 24) */
|
||||
# define LONG_SEEK fseek
|
||||
#elif defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
# define LONG_SEEK _fseeki64
|
||||
#elif !defined(__64BIT__) && (PLATFORM_POSIX_VERSION >= 200112L) /* No point defining Large file for 64 bit */
|
||||
# define LONG_SEEK fseeko
|
||||
@ -252,6 +255,8 @@ size_t ZSTD_seekable_free(ZSTD_seekable* zs)
|
||||
|
||||
ZSTD_seekTable* ZSTD_seekTable_create_fromSeekable(const ZSTD_seekable* zs)
|
||||
{
|
||||
assert(zs != NULL);
|
||||
if (zs->seekTable.entries == NULL) return NULL;
|
||||
ZSTD_seekTable* const st = (ZSTD_seekTable*)malloc(sizeof(ZSTD_seekTable));
|
||||
if (st==NULL) return NULL;
|
||||
|
||||
|
@ -18,6 +18,26 @@ This document lists a few known cases where invalid data was formerly accepted
|
||||
by the decoder, and what has changed since.
|
||||
|
||||
|
||||
Truncated Huffman states
|
||||
------------------------
|
||||
|
||||
**Last affected version**: v1.5.6
|
||||
|
||||
**Produced by the reference compressor**: No
|
||||
|
||||
**Example Frame**: `28b5 2ffd 0000 5500 0072 8001 0420 7e1f 02aa 00`
|
||||
|
||||
When using FSE-compressed Huffman weights, the compressed weight bitstream
|
||||
could contain fewer bits than necessary to decode the initial states.
|
||||
|
||||
The reference decompressor up to v1.5.6 will decode truncated or missing
|
||||
initial states as zero, which can result in a valid Huffman tree if only
|
||||
the second state is truncated.
|
||||
|
||||
In newer versions, truncated initial states are reported as a corruption
|
||||
error by the decoder.
|
||||
|
||||
|
||||
Offset == 0
|
||||
-----------
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
ZSTD ?= zstd # note: requires zstd installation on local system
|
||||
|
||||
UNAME?= $(shell uname)
|
||||
UNAME?= $(shell sh -c 'MSYSTEM="MSYS" uname')
|
||||
ifeq ($(UNAME), SunOS)
|
||||
DIFF ?= gdiff
|
||||
else
|
||||
|
@ -16,7 +16,7 @@ Distribution of this document is unlimited.
|
||||
|
||||
### Version
|
||||
|
||||
0.4.0 (2023-06-05)
|
||||
0.4.4 (2025-03-22)
|
||||
|
||||
|
||||
Introduction
|
||||
@ -390,7 +390,7 @@ __`Block_Content`__ and __`Block_Maximum_Size`__
|
||||
The size of `Block_Content` is limited by `Block_Maximum_Size`,
|
||||
which is the smallest of:
|
||||
- `Window_Size`
|
||||
- 128 KB
|
||||
- 128 KiB (131.072 bytes)
|
||||
|
||||
`Block_Maximum_Size` is constant for a given frame.
|
||||
This maximum is applicable to both the decompressed size
|
||||
@ -1038,53 +1038,54 @@ and to compress Huffman headers.
|
||||
FSE
|
||||
---
|
||||
FSE, short for Finite State Entropy, is an entropy codec based on [ANS].
|
||||
FSE encoding/decoding involves a state that is carried over between symbols,
|
||||
so decoding must be done in the opposite direction as encoding.
|
||||
FSE encoding/decoding involves a state that is carried over between symbols.
|
||||
Decoding must be done in the opposite direction as encoding.
|
||||
Therefore, all FSE bitstreams are read from end to beginning.
|
||||
Note that the order of the bits in the stream is not reversed,
|
||||
we just read the elements in the reverse order they are written.
|
||||
we just read each multi-bits element in the reverse order they are encoded.
|
||||
|
||||
For additional details on FSE, see [Finite State Entropy].
|
||||
|
||||
[Finite State Entropy]:https://github.com/Cyan4973/FiniteStateEntropy/
|
||||
|
||||
FSE decoding involves a decoding table which has a power of 2 size, and contain three elements:
|
||||
FSE decoding is directed by a decoding table with a power of 2 size, each row containing three elements:
|
||||
`Symbol`, `Num_Bits`, and `Baseline`.
|
||||
The `log2` of the table size is its `Accuracy_Log`.
|
||||
An FSE state value represents an index in this table.
|
||||
|
||||
To obtain the initial state value, consume `Accuracy_Log` bits from the stream as a __little-endian__ value.
|
||||
The next symbol in the stream is the `Symbol` indicated in the table for that state.
|
||||
The first symbol in the stream is the `Symbol` indicated in the table for that state.
|
||||
To obtain the next state value,
|
||||
the decoder should consume `Num_Bits` bits from the stream as a __little-endian__ value and add it to `Baseline`.
|
||||
|
||||
[ANS]: https://en.wikipedia.org/wiki/Asymmetric_Numeral_Systems
|
||||
|
||||
### FSE Table Description
|
||||
To decode FSE streams, it is necessary to construct the decoding table.
|
||||
The Zstandard format encodes FSE table descriptions as follows:
|
||||
To decode an FSE bitstream, it is necessary to build its FSE decoding table.
|
||||
The decoding table is derived from a distribution of Probabilities.
|
||||
The Zstandard format encodes distributions of Probabilities as follows:
|
||||
|
||||
An FSE distribution table describes the probabilities of all symbols
|
||||
from `0` to the last present one (included)
|
||||
on a normalized scale of `1 << Accuracy_Log` .
|
||||
Note that there must be two or more symbols with nonzero probability.
|
||||
The distribution of probabilities is described in a bitstream which is read forward,
|
||||
in __little-endian__ fashion.
|
||||
The amount of bytes consumed from the bitstream to describe the distribution
|
||||
is discovered at the end of the decoding process.
|
||||
|
||||
It's a bitstream which is read forward, in __little-endian__ fashion.
|
||||
It's not necessary to know bitstream exact size,
|
||||
it will be discovered and reported by the decoding process.
|
||||
|
||||
The bitstream starts by reporting on which scale it operates.
|
||||
The bitstream starts by reporting on which scale the distribution operates.
|
||||
Let's `low4Bits` designate the lowest 4 bits of the first byte :
|
||||
`Accuracy_Log = low4bits + 5`.
|
||||
|
||||
Then follows each symbol value, from `0` to last present one.
|
||||
The number of bits used by each field is variable.
|
||||
An FSE distribution table describes the probabilities of all symbols
|
||||
from `0` to the last present one (included) in natural order.
|
||||
The sum of probabilities is normalized to reach a power of 2 total of `1 << Accuracy_Log` .
|
||||
There must be two or more symbols with non-zero probabilities.
|
||||
|
||||
The number of bits used to decode each probability is variable.
|
||||
It depends on :
|
||||
|
||||
- Remaining probabilities + 1 :
|
||||
__example__ :
|
||||
Presuming an `Accuracy_Log` of 8,
|
||||
and presuming 100 probabilities points have already been distributed,
|
||||
and presuming 100 probability points have already been distributed,
|
||||
the decoder may read any value from `0` to `256 - 100 + 1 == 157` (inclusive).
|
||||
Therefore, it may read up to `log2sup(157) == 8` bits, where `log2sup(N)`
|
||||
is the smallest integer `T` that satisfies `(1 << T) > N`.
|
||||
@ -1098,114 +1099,133 @@ It depends on :
|
||||
values from 98 to 157 use 8 bits.
|
||||
This is achieved through this scheme :
|
||||
|
||||
| Value read | Value decoded | Number of bits used |
|
||||
| ---------- | ------------- | ------------------- |
|
||||
| 0 - 97 | 0 - 97 | 7 |
|
||||
| 98 - 127 | 98 - 127 | 8 |
|
||||
| 128 - 225 | 0 - 97 | 7 |
|
||||
| 226 - 255 | 128 - 157 | 8 |
|
||||
| 8-bit field read | Value decoded | Nb of bits consumed |
|
||||
| ---------------- | ------------- | ------------------- |
|
||||
| 0 - 97 | 0 - 97 | 7 |
|
||||
| 98 - 127 | 98 - 127 | 8 |
|
||||
| 128 - 225 | 0 - 97 | 7 |
|
||||
| 226 - 255 | 128 - 157 | 8 |
|
||||
|
||||
Symbols probabilities are read one by one, in order.
|
||||
Probability is derived from Value decoded using the following formula:
|
||||
`Probality = Value - 1`
|
||||
|
||||
Probability is obtained from Value decoded by following formula :
|
||||
`Proba = value - 1`
|
||||
Consequently, a Probability of `0` is described by a Value `1`.
|
||||
|
||||
It means value `0` becomes negative probability `-1`.
|
||||
`-1` is a special probability, which means "less than 1".
|
||||
Its effect on distribution table is described in the [next section].
|
||||
For the purpose of calculating total allocated probability points, it counts as one.
|
||||
A Value `0` is used to signal a special case, named "Probability `-1`".
|
||||
It describes a probability which should have been "less than 1".
|
||||
Its effect on the decoding table building process is described in the [next section].
|
||||
For the purpose of counting total allocated probability points, it counts as one.
|
||||
|
||||
[next section]:#from-normalized-distribution-to-decoding-tables
|
||||
|
||||
When a symbol has a __probability__ of `zero`,
|
||||
Symbols probabilities are read one by one, in order.
|
||||
After each probability is decoded, the total nb of probability points is updated.
|
||||
This is used to determine how many bits must be read to decode the probability of next symbol.
|
||||
|
||||
When a symbol has a __probability__ of `zero` (decoded from reading a Value `1`),
|
||||
it is followed by a 2-bits repeat flag.
|
||||
This repeat flag tells how many probabilities of zeroes follow the current one.
|
||||
It provides a number ranging from 0 to 3.
|
||||
If it is a 3, another 2-bits repeat flag follows, and so on.
|
||||
|
||||
When last symbol reaches cumulated total of `1 << Accuracy_Log`,
|
||||
decoding is complete.
|
||||
If the last symbol makes cumulated total go above `1 << Accuracy_Log`,
|
||||
distribution is considered corrupted.
|
||||
If this process results in a non-zero probability for a value outside of the
|
||||
valid range of values that the FSE table is defined for, even if that value is
|
||||
not used, then the data is considered corrupted.
|
||||
When the Probability for a symbol makes cumulated total reach `1 << Accuracy_Log`,
|
||||
then it's the last symbol, and decoding is complete.
|
||||
|
||||
Then the decoder can tell how many bytes were used in this process,
|
||||
and how many symbols are present.
|
||||
The bitstream consumes a round number of bytes.
|
||||
Any remaining bit within the last byte is just unused.
|
||||
|
||||
If this process results in a non-zero probability for a symbol outside of the
|
||||
valid range of symbols that the FSE table is defined for, even if that symbol is
|
||||
not used, then the data is considered corrupted.
|
||||
For the specific case of offset codes,
|
||||
a decoder implementation may reject a frame containing a non-zero probability
|
||||
for an offset code larger than the largest offset code supported by the decoder
|
||||
implementation.
|
||||
|
||||
#### From normalized distribution to decoding tables
|
||||
|
||||
The distribution of normalized probabilities is enough
|
||||
The normalized distribution of probabilities is enough
|
||||
to create a unique decoding table.
|
||||
|
||||
It follows the following build rule :
|
||||
It is generated using the following build rule :
|
||||
|
||||
The table has a size of `Table_Size = 1 << Accuracy_Log`.
|
||||
Each cell describes the symbol decoded,
|
||||
and instructions to get the next state (`Number_of_Bits` and `Baseline`).
|
||||
Each row specifies the decoded symbol,
|
||||
and instructions to reach the next state (`Number_of_Bits` and `Baseline`).
|
||||
|
||||
Symbols are scanned in their natural order for "less than 1" probabilities.
|
||||
Symbols with this probability are being attributed a single cell,
|
||||
Symbols are first scanned in their natural order for "less than 1" probabilities
|
||||
(previously decoded from a Value of `0`).
|
||||
Symbols with this special probability are being attributed a single row,
|
||||
starting from the end of the table and retreating.
|
||||
These symbols define a full state reset, reading `Accuracy_Log` bits.
|
||||
|
||||
Then, all remaining symbols, sorted in natural order, are allocated cells.
|
||||
Starting from symbol `0` (if it exists), and table position `0`,
|
||||
each symbol gets allocated as many cells as its probability.
|
||||
Cell allocation is spread, not linear :
|
||||
each successor position follows this rule :
|
||||
Then, all remaining symbols, sorted in natural order, are allocated rows.
|
||||
Starting from smallest present symbol, and table position `0`,
|
||||
each symbol gets allocated as many rows as its probability.
|
||||
|
||||
Row allocation is not linear, it follows this order, in modular arithmetic:
|
||||
```
|
||||
position += (tableSize>>1) + (tableSize>>3) + 3;
|
||||
position &= tableSize-1;
|
||||
```
|
||||
|
||||
A position is skipped if already occupied by a "less than 1" probability symbol.
|
||||
`position` does not reset between symbols, it simply iterates through
|
||||
each position in the table, switching to the next symbol when enough
|
||||
states have been allocated to the current one.
|
||||
Using above ordering rule, each symbol gets allocated as many rows as its probability.
|
||||
If a position is already occupied by a "less than 1" probability symbol,
|
||||
it is simply skipped, and the next position is allocated instead.
|
||||
Once enough rows have been allocated for the current symbol,
|
||||
the allocation process continues, using the next symbol, in natural order.
|
||||
This process guarantees that the table is entirely and exactly filled.
|
||||
|
||||
The process guarantees that the table is entirely filled.
|
||||
Each cell corresponds to a state value, which contains the symbol being decoded.
|
||||
Each row specifies a decoded symbol, and is accessed by current state value.
|
||||
It also specifies `Number_of_Bits` and `Baseline`, which are required to determine next state value.
|
||||
|
||||
To add the `Number_of_Bits` and `Baseline` required to retrieve next state,
|
||||
it's first necessary to sort all occurrences of each symbol in state order.
|
||||
Lower states will need 1 more bit than higher ones.
|
||||
The process is repeated for each symbol.
|
||||
To correctly set these fields, it's necessary to sort all occurrences of each symbol in state value order,
|
||||
and then attribute N+1 bits to lower rows, and N bits to higher rows,
|
||||
following the process described below (using an example):
|
||||
|
||||
__Example__ :
|
||||
Presuming a symbol has a probability of 5,
|
||||
it receives 5 cells, corresponding to 5 state values.
|
||||
These state values are then sorted in natural order.
|
||||
Presuming an `Accuracy_Log` of 7,
|
||||
let's imagine a symbol with a Probability of 5:
|
||||
it receives 5 rows, corresponding to 5 state values between `0` and `127`.
|
||||
|
||||
Next power of 2 after 5 is 8.
|
||||
Space of probabilities must be divided into 8 equal parts.
|
||||
Presuming the `Accuracy_Log` is 7, it defines a space of 128 states.
|
||||
Divided by 8, each share is 16 large.
|
||||
In this example, the first state value happens to be `1` (after unspecified previous symbols).
|
||||
The next 4 states are then determined using above modular arithmetic rule,
|
||||
which specifies to add `64+16+3 = 83` modulo `128` to jump to next position,
|
||||
producing the following series: `1`, `84`, `39`, `122`, `77` (modular arithmetic).
|
||||
(note: the next symbol will then start at `32`).
|
||||
|
||||
In order to reach 8 shares, 8-5=3 lowest states will count "double",
|
||||
These state values are then sorted in natural order,
|
||||
resulting in the following series: `1`, `39`, `77`, `84`, `122`.
|
||||
|
||||
The next power of 2 after 5 is 8.
|
||||
Therefore, the probability space will be divided into 8 equal parts.
|
||||
Since the probability space is `1<<7 = 128` large, each share is `128/8 = 16` large.
|
||||
|
||||
In order to reach 8 shares, the `8-5 = 3` lowest states will count "double",
|
||||
doubling their shares (32 in width), hence requiring one more bit.
|
||||
|
||||
Baseline is assigned starting from the higher states using fewer bits,
|
||||
increasing at each state, then resuming at the first state,
|
||||
each state takes its allocated width from Baseline.
|
||||
Baseline is assigned starting from the lowest state using fewer bits,
|
||||
continuing in natural state order, looping back at the beginning.
|
||||
Each state takes its allocated range from Baseline, sized by its `Number_of_Bits`.
|
||||
|
||||
| state order | 0 | 1 | 2 | 3 | 4 |
|
||||
| ---------------- | ----- | ----- | ------ | ---- | ------ |
|
||||
| state value | 1 | 39 | 77 | 84 | 122 |
|
||||
| width | 32 | 32 | 32 | 16 | 16 |
|
||||
| `Number_of_Bits` | 5 | 5 | 5 | 4 | 4 |
|
||||
| range number | 2 | 4 | 6 | 0 | 1 |
|
||||
| allocation order | 3 | 4 | 5 | 1 | 2 |
|
||||
| `Baseline` | 32 | 64 | 96 | 0 | 16 |
|
||||
| range | 32-63 | 64-95 | 96-127 | 0-15 | 16-31 |
|
||||
|
||||
During decoding, the next state value is determined from current state value,
|
||||
by reading the required `Number_of_Bits`, and adding the specified `Baseline`.
|
||||
During decoding, the next state value is determined by using current state value as row number,
|
||||
then reading the required `Number_of_Bits` from the bitstream, and adding the specified `Baseline`.
|
||||
|
||||
See [Appendix A] for the results of this process applied to the default distributions.
|
||||
Note:
|
||||
as a trivial example, it follows that, for a symbol with a Probability of `1`,
|
||||
`Baseline` is necessarily `0`, and `Number_of_Bits` is necessarily `Accuracy_Log`.
|
||||
|
||||
See [Appendix A] to see the outcome of this process applied to the default distributions.
|
||||
|
||||
[Appendix A]: #appendix-a---decoding-tables-for-predefined-codes
|
||||
|
||||
@ -1250,13 +1270,13 @@ This specification limits maximum code length to 11 bits.
|
||||
|
||||
#### Representation
|
||||
|
||||
All literal values from zero (included) to last present one (excluded)
|
||||
All literal symbols from zero (included) to last present one (excluded)
|
||||
are represented by `Weight` with values from `0` to `Max_Number_of_Bits`.
|
||||
Transformation from `Weight` to `Number_of_Bits` follows this formula :
|
||||
```
|
||||
Number_of_Bits = Weight ? (Max_Number_of_Bits + 1 - Weight) : 0
|
||||
```
|
||||
When a literal value is not present, it receives a `Weight` of 0.
|
||||
When a literal symbol is not present, it receives a `Weight` of 0.
|
||||
The least frequent symbol receives a `Weight` of 1.
|
||||
If no literal has a `Weight` of 1, then the data is considered corrupted.
|
||||
If there are not at least two literals with non-zero `Weight`, then the data
|
||||
@ -1273,33 +1293,38 @@ otherwise the representation is considered corrupted.
|
||||
__Example__ :
|
||||
Let's presume the following Huffman tree must be described :
|
||||
|
||||
| literal value | 0 | 1 | 2 | 3 | 4 | 5 |
|
||||
| literal symbol | A | B | C | D | E | F |
|
||||
| ---------------- | --- | --- | --- | --- | --- | --- |
|
||||
| `Number_of_Bits` | 1 | 2 | 3 | 0 | 4 | 4 |
|
||||
|
||||
The tree depth is 4, since its longest elements uses 4 bits
|
||||
(longest elements are the one with smallest frequency).
|
||||
Literal value `5` will not be listed, as it can be determined from previous values 0-4,
|
||||
nor will values above `5` as they are all 0.
|
||||
Values from `0` to `4` will be listed using `Weight` instead of `Number_of_Bits`.
|
||||
(longest elements are the ones with smallest frequency).
|
||||
|
||||
All symbols will now receive a `Weight` instead of `Number_of_Bits`.
|
||||
Weight formula is :
|
||||
```
|
||||
Weight = Number_of_Bits ? (Max_Number_of_Bits + 1 - Number_of_Bits) : 0
|
||||
```
|
||||
It gives the following series of weights :
|
||||
It gives the following series of Weights :
|
||||
|
||||
| literal value | 0 | 1 | 2 | 3 | 4 |
|
||||
| ------------- | --- | --- | --- | --- | --- |
|
||||
| `Weight` | 4 | 3 | 2 | 0 | 1 |
|
||||
| literal symbol | A | B | C | D | E | F |
|
||||
| -------------- | --- | --- | --- | --- | --- | --- |
|
||||
| `Weight` | 4 | 3 | 2 | 0 | 1 | 1 |
|
||||
|
||||
This list will be sent to the decoder, with the following modifications:
|
||||
|
||||
- `F` will not be listed, because it can be determined from previous symbols
|
||||
- nor will symbols above `F` as they are all 0
|
||||
- on the other hand, all symbols before `A`, starting with `\0`, will be listed, with a Weight of 0.
|
||||
|
||||
The decoder will do the inverse operation :
|
||||
having collected weights of literal symbols from `0` to `4`,
|
||||
it knows the last literal, `5`, is present with a non-zero `Weight`.
|
||||
The `Weight` of `5` can be determined by advancing to the next power of 2.
|
||||
having collected weights of literal symbols from `A` to `E`,
|
||||
it knows the last literal, `F`, is present with a non-zero `Weight`.
|
||||
The `Weight` of `F` can be determined by advancing to the next power of 2.
|
||||
The sum of `2^(Weight-1)` (excluding 0's) is :
|
||||
`8 + 4 + 2 + 0 + 1 = 15`.
|
||||
Nearest larger power of 2 value is 16.
|
||||
Therefore, `Max_Number_of_Bits = 4` and `Weight[5] = log_2(16 - 15) + 1 = 1`.
|
||||
Therefore, `Max_Number_of_Bits = log2(16) = 4` and `Weight[F] = log_2(16 - 15) + 1 = 1`.
|
||||
|
||||
#### Huffman Tree header
|
||||
|
||||
@ -1339,7 +1364,7 @@ sharing a single distribution table.
|
||||
To decode an FSE bitstream, it is necessary to know its compressed size.
|
||||
Compressed size is provided by `headerByte`.
|
||||
It's also necessary to know its _maximum possible_ decompressed size,
|
||||
which is `255`, since literal values span from `0` to `255`,
|
||||
which is `255`, since literal symbols span from `0` to `255`,
|
||||
and last symbol's `Weight` is not represented.
|
||||
|
||||
An FSE bitstream starts by a header, describing probabilities distribution.
|
||||
@ -1364,6 +1389,10 @@ symbols for each of the final states are decoded and the process is complete.
|
||||
If this process would produce more weights than the maximum number of decoded
|
||||
weights (255), then the data is considered corrupted.
|
||||
|
||||
If either of the 2 initial states are absent or truncated, then the data is
|
||||
considered corrupted. Consequently, it is not possible to encode fewer than
|
||||
2 weights using this mode.
|
||||
|
||||
#### Conversion from weights to Huffman prefix codes
|
||||
|
||||
All present symbols shall now have a `Weight` value.
|
||||
@ -1371,26 +1400,28 @@ It is possible to transform weights into `Number_of_Bits`, using this formula:
|
||||
```
|
||||
Number_of_Bits = (Weight>0) ? Max_Number_of_Bits + 1 - Weight : 0
|
||||
```
|
||||
Symbols are sorted by `Weight`.
|
||||
Within same `Weight`, symbols keep natural sequential order.
|
||||
In order to determine which prefix code is assigned to each Symbol,
|
||||
Symbols are first sorted by `Weight`, then by natural sequential order.
|
||||
Symbols with a `Weight` of zero are removed.
|
||||
Then, starting from lowest `Weight`, prefix codes are distributed in sequential order.
|
||||
Then, starting from lowest `Weight` (hence highest `Number_of_Bits`),
|
||||
prefix codes are assigned in ascending order.
|
||||
|
||||
__Example__ :
|
||||
Let's presume the following list of weights has been decoded :
|
||||
Let's assume the following list of weights has been decoded:
|
||||
|
||||
| Literal | 0 | 1 | 2 | 3 | 4 | 5 |
|
||||
| Literal | A | B | C | D | E | F |
|
||||
| -------- | --- | --- | --- | --- | --- | --- |
|
||||
| `Weight` | 4 | 3 | 2 | 0 | 1 | 1 |
|
||||
|
||||
Sorted by weight and then natural sequential order,
|
||||
it gives the following distribution :
|
||||
it gives the following prefix codes distribution:
|
||||
|
||||
| Literal | 3 | 4 | 5 | 2 | 1 | 0 |
|
||||
| ---------------- | --- | --- | --- | --- | --- | ---- |
|
||||
| `Weight` | 0 | 1 | 1 | 2 | 3 | 4 |
|
||||
| `Number_of_Bits` | 0 | 4 | 4 | 3 | 2 | 1 |
|
||||
| prefix codes | N/A | 0000| 0001| 001 | 01 | 1 |
|
||||
| Literal | D | E | F | C | B | A |
|
||||
| ---------------- | --- | ---- | ---- | ---- | ---- | ---- |
|
||||
| `Weight` | 0 | 1 | 1 | 2 | 3 | 4 |
|
||||
| `Number_of_Bits` | 0 | 4 | 4 | 3 | 2 | 1 |
|
||||
| prefix code | N/A | 0000 | 0001 | 001 | 01 | 1 |
|
||||
| ascending order | N/A | 0000 | 0001 | 001x | 01xx | 1xxx |
|
||||
|
||||
### Huffman-coded Streams
|
||||
|
||||
@ -1413,10 +1444,10 @@ it's possible to read the bitstream in a __little-endian__ fashion,
|
||||
keeping track of already used bits. Since the bitstream is encoded in reverse
|
||||
order, starting from the end read symbols in forward order.
|
||||
|
||||
For example, if the literal sequence "0145" was encoded using above prefix code,
|
||||
For example, if the literal sequence `ABEF` was encoded using above prefix code,
|
||||
it would be encoded (in reverse order) as:
|
||||
|
||||
|Symbol | 5 | 4 | 1 | 0 | Padding |
|
||||
|Symbol | F | E | B | A | Padding |
|
||||
|--------|------|------|----|---|---------|
|
||||
|Encoding|`0000`|`0001`|`01`|`1`| `00001` |
|
||||
|
||||
@ -1711,6 +1742,10 @@ or at least provide a meaningful error code explaining for which reason it canno
|
||||
|
||||
Version changes
|
||||
---------------
|
||||
- 0.4.4 : minor clarification for block size
|
||||
- 0.4.3 : clarifications for Huffman prefix code assignment example
|
||||
- 0.4.2 : refactor FSE table construction process, inspired by Donald Pian
|
||||
- 0.4.1 : clarifications on a few error scenarios, by Eric Lasota
|
||||
- 0.4.0 : fixed imprecise behavior for nbSeq==0, detected by Igor Pavlov
|
||||
- 0.3.9 : clarifications for Huffman-compressed literal sizes.
|
||||
- 0.3.8 : clarifications for Huffman Blocks and Huffman Tree descriptions.
|
||||
|
@ -1,16 +1,17 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>zstd 1.5.6 Manual</title>
|
||||
<title>zstd 1.5.7 Manual</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>zstd 1.5.6 Manual</h1>
|
||||
<h1>zstd 1.5.7 Manual</h1>
|
||||
Note: the content of this file has been automatically generated by parsing "zstd.h"
|
||||
<hr>
|
||||
<a name="Contents"></a><h2>Contents</h2>
|
||||
<ol>
|
||||
<li><a href="#Chapter1">Introduction</a></li>
|
||||
<li><a href="#Chapter2">Version</a></li>
|
||||
<li><a href="#Chapter3">Simple API</a></li>
|
||||
<li><a href="#Chapter3">Simple Core API</a></li>
|
||||
<li><a href="#Chapter4">Explicit context</a></li>
|
||||
<li><a href="#Chapter5">Advanced compression API (Requires v1.4.0+)</a></li>
|
||||
<li><a href="#Chapter6">Advanced decompression API (Requires v1.4.0+)</a></li>
|
||||
@ -74,7 +75,7 @@
|
||||
</b><p> Return runtime library version, like "1.4.5". Requires v1.3.0+.
|
||||
</p></pre><BR>
|
||||
|
||||
<a name="Chapter3"></a><h2>Simple API</h2><pre></pre>
|
||||
<a name="Chapter3"></a><h2>Simple Core API</h2><pre></pre>
|
||||
|
||||
<pre><b>size_t ZSTD_compress( void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize,
|
||||
@ -88,44 +89,48 @@
|
||||
|
||||
<pre><b>size_t ZSTD_decompress( void* dst, size_t dstCapacity,
|
||||
const void* src, size_t compressedSize);
|
||||
</b><p> `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames.
|
||||
`dstCapacity` is an upper bound of originalSize to regenerate.
|
||||
If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data.
|
||||
@return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
|
||||
or an errorCode if it fails (which can be tested using ZSTD_isError()).
|
||||
</b><p> `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames.
|
||||
Multiple compressed frames can be decompressed at once with this method.
|
||||
The result will be the concatenation of all decompressed frames, back to back.
|
||||
`dstCapacity` is an upper bound of originalSize to regenerate.
|
||||
First frame's decompressed size can be extracted using ZSTD_getFrameContentSize().
|
||||
If maximum upper bound isn't known, prefer using streaming mode to decompress data.
|
||||
@return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
|
||||
or an errorCode if it fails (which can be tested using ZSTD_isError()).
|
||||
</p></pre><BR>
|
||||
|
||||
<h3>Decompression helper functions</h3><pre></pre><b><pre></pre></b><BR>
|
||||
<pre><b>#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
|
||||
#define ZSTD_CONTENTSIZE_ERROR (0ULL - 2)
|
||||
unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize);
|
||||
</b><p> `src` should point to the start of a ZSTD encoded frame.
|
||||
`srcSize` must be at least as large as the frame header.
|
||||
hint : any size >= `ZSTD_frameHeaderSize_max` is large enough.
|
||||
@return : - decompressed size of `src` frame content, if known
|
||||
- ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
|
||||
- ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small)
|
||||
note 1 : a 0 return value means the frame is valid but "empty".
|
||||
note 2 : decompressed size is an optional field, it may not be present, typically in streaming mode.
|
||||
When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
|
||||
In which case, it's necessary to use streaming mode to decompress data.
|
||||
Optionally, application can rely on some implicit limit,
|
||||
as ZSTD_decompress() only needs an upper bound of decompressed size.
|
||||
(For example, data could be necessarily cut into blocks <= 16 KB).
|
||||
note 3 : decompressed size is always present when compression is completed using single-pass functions,
|
||||
such as ZSTD_compress(), ZSTD_compressCCtx() ZSTD_compress_usingDict() or ZSTD_compress_usingCDict().
|
||||
note 4 : decompressed size can be very large (64-bits value),
|
||||
potentially larger than what local system can handle as a single memory segment.
|
||||
In which case, it's necessary to use streaming mode to decompress data.
|
||||
note 5 : If source is untrusted, decompressed size could be wrong or intentionally modified.
|
||||
Always ensure return value fits within application's authorized limits.
|
||||
Each application can set its own limits.
|
||||
note 6 : This function replaces ZSTD_getDecompressedSize()
|
||||
</b><p> `src` should point to the start of a ZSTD encoded frame.
|
||||
`srcSize` must be at least as large as the frame header.
|
||||
hint : any size >= `ZSTD_frameHeaderSize_max` is large enough.
|
||||
@return : - decompressed size of `src` frame content, if known
|
||||
- ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
|
||||
- ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small)
|
||||
note 1 : a 0 return value means the frame is valid but "empty".
|
||||
When invoking this method on a skippable frame, it will return 0.
|
||||
note 2 : decompressed size is an optional field, it may not be present (typically in streaming mode).
|
||||
When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
|
||||
In which case, it's necessary to use streaming mode to decompress data.
|
||||
Optionally, application can rely on some implicit limit,
|
||||
as ZSTD_decompress() only needs an upper bound of decompressed size.
|
||||
(For example, data could be necessarily cut into blocks <= 16 KB).
|
||||
note 3 : decompressed size is always present when compression is completed using single-pass functions,
|
||||
such as ZSTD_compress(), ZSTD_compressCCtx() ZSTD_compress_usingDict() or ZSTD_compress_usingCDict().
|
||||
note 4 : decompressed size can be very large (64-bits value),
|
||||
potentially larger than what local system can handle as a single memory segment.
|
||||
In which case, it's necessary to use streaming mode to decompress data.
|
||||
note 5 : If source is untrusted, decompressed size could be wrong or intentionally modified.
|
||||
Always ensure return value fits within application's authorized limits.
|
||||
Each application can set its own limits.
|
||||
note 6 : This function replaces ZSTD_getDecompressedSize()
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>ZSTD_DEPRECATED("Replaced by ZSTD_getFrameContentSize")
|
||||
ZSTDLIB_API
|
||||
unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
|
||||
</b><p> NOTE: This function is now obsolete, in favor of ZSTD_getFrameContentSize().
|
||||
</b><p> This function is now obsolete, in favor of ZSTD_getFrameContentSize().
|
||||
Both functions work the same way, but ZSTD_getDecompressedSize() blends
|
||||
"empty", "unknown" and "error" results to the same return value (0),
|
||||
while ZSTD_getFrameContentSize() gives them separate return values.
|
||||
@ -137,53 +142,61 @@ unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
|
||||
`srcSize` must be >= first frame size
|
||||
@return : the compressed size of the first frame starting at `src`,
|
||||
suitable to pass as `srcSize` to `ZSTD_decompress` or similar,
|
||||
or an error code if input is invalid
|
||||
or an error code if input is invalid
|
||||
Note 1: this method is called _find*() because it's not enough to read the header,
|
||||
it may have to scan through the frame's content, to reach its end.
|
||||
Note 2: this method also works with Skippable Frames. In which case,
|
||||
it returns the size of the complete skippable frame,
|
||||
which is always equal to its content size + 8 bytes for headers.
|
||||
</p></pre><BR>
|
||||
|
||||
<h3>Helper functions</h3><pre></pre><b><pre></b>/* ZSTD_compressBound() :<b>
|
||||
* maximum compressed size in worst case single-pass scenario.
|
||||
* When invoking `ZSTD_compress()` or any other one-pass compression function,
|
||||
* it's recommended to provide @dstCapacity >= ZSTD_compressBound(srcSize)
|
||||
* as it eliminates one potential failure scenario,
|
||||
* aka not enough room in dst buffer to write the compressed frame.
|
||||
* Note : ZSTD_compressBound() itself can fail, if @srcSize > ZSTD_MAX_INPUT_SIZE .
|
||||
* In which case, ZSTD_compressBound() will return an error code
|
||||
* which can be tested using ZSTD_isError().
|
||||
*
|
||||
* ZSTD_COMPRESSBOUND() :
|
||||
* same as ZSTD_compressBound(), but as a macro.
|
||||
* It can be used to produce constants, which can be useful for static allocation,
|
||||
* for example to size a static array on stack.
|
||||
* Will produce constant value 0 if srcSize too large.
|
||||
*/
|
||||
#define ZSTD_MAX_INPUT_SIZE ((sizeof(size_t)==8) ? 0xFF00FF00FF00FF00ULL : 0xFF00FF00U)
|
||||
<h3>Compression helper functions</h3><pre></pre><b><pre></pre></b><BR>
|
||||
<pre><b>#define ZSTD_MAX_INPUT_SIZE ((sizeof(size_t)==8) ? 0xFF00FF00FF00FF00ULL : 0xFF00FF00U)
|
||||
#define ZSTD_COMPRESSBOUND(srcSize) (((size_t)(srcSize) >= ZSTD_MAX_INPUT_SIZE) ? 0 : (srcSize) + ((srcSize)>>8) + (((srcSize) < (128<<10)) ? (((128<<10) - (srcSize)) >> 11) </b>/* margin, from 64 to 0 */ : 0)) /* this formula ensures that bound(A) + bound(B) <= bound(A+B) as long as A and B >= 128 KB */<b>
|
||||
size_t ZSTD_compressBound(size_t srcSize); </b>/*!< maximum compressed size in worst case single-pass scenario */<b>
|
||||
</b>/* ZSTD_isError() :<b>
|
||||
</b><p> maximum compressed size in worst case single-pass scenario.
|
||||
When invoking `ZSTD_compress()`, or any other one-pass compression function,
|
||||
it's recommended to provide @dstCapacity >= ZSTD_compressBound(srcSize)
|
||||
as it eliminates one potential failure scenario,
|
||||
aka not enough room in dst buffer to write the compressed frame.
|
||||
Note : ZSTD_compressBound() itself can fail, if @srcSize >= ZSTD_MAX_INPUT_SIZE .
|
||||
In which case, ZSTD_compressBound() will return an error code
|
||||
which can be tested using ZSTD_isError().
|
||||
|
||||
ZSTD_COMPRESSBOUND() :
|
||||
same as ZSTD_compressBound(), but as a macro.
|
||||
It can be used to produce constants, which can be useful for static allocation,
|
||||
for example to size a static array on stack.
|
||||
Will produce constant value 0 if srcSize is too large.
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
<h3>Error helper functions</h3><pre></pre><b><pre></b>/* ZSTD_isError() :<b>
|
||||
* Most ZSTD_* functions returning a size_t value can be tested for error,
|
||||
* using ZSTD_isError().
|
||||
* @return 1 if error, 0 otherwise
|
||||
*/
|
||||
unsigned ZSTD_isError(size_t code); </b>/*!< tells if a `size_t` function result is an error code */<b>
|
||||
const char* ZSTD_getErrorName(size_t code); </b>/*!< provides readable string from an error code */<b>
|
||||
int ZSTD_minCLevel(void); </b>/*!< minimum negative compression level allowed, requires v1.4.0+ */<b>
|
||||
int ZSTD_maxCLevel(void); </b>/*!< maximum compression level available */<b>
|
||||
int ZSTD_defaultCLevel(void); </b>/*!< default compression level, specified by ZSTD_CLEVEL_DEFAULT, requires v1.5.0+ */<b>
|
||||
unsigned ZSTD_isError(size_t result); </b>/*!< tells if a `size_t` function result is an error code */<b>
|
||||
ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult); </b>/* convert a result into an error code, which can be compared to error enum list */<b>
|
||||
const char* ZSTD_getErrorName(size_t result); </b>/*!< provides readable string from a function result */<b>
|
||||
int ZSTD_minCLevel(void); </b>/*!< minimum negative compression level allowed, requires v1.4.0+ */<b>
|
||||
int ZSTD_maxCLevel(void); </b>/*!< maximum compression level available */<b>
|
||||
int ZSTD_defaultCLevel(void); </b>/*!< default compression level, specified by ZSTD_CLEVEL_DEFAULT, requires v1.5.0+ */<b>
|
||||
</pre></b><BR>
|
||||
<a name="Chapter4"></a><h2>Explicit context</h2><pre></pre>
|
||||
|
||||
<h3>Compression context</h3><pre> When compressing many times,
|
||||
it is recommended to allocate a context just once,
|
||||
it is recommended to allocate a compression context just once,
|
||||
and reuse it for each successive compression operation.
|
||||
This will make workload friendlier for system's memory.
|
||||
This will make the workload easier for system's memory.
|
||||
Note : re-using context is just a speed / resource optimization.
|
||||
It doesn't change the compression ratio, which remains identical.
|
||||
Note 2 : In multi-threaded environments,
|
||||
use one different context per thread for parallel execution.
|
||||
Note 2: For parallel execution in multi-threaded environments,
|
||||
use one different context per thread .
|
||||
|
||||
</pre><b><pre>typedef struct ZSTD_CCtx_s ZSTD_CCtx;
|
||||
ZSTD_CCtx* ZSTD_createCCtx(void);
|
||||
size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); </b>/* accept NULL pointer */<b>
|
||||
size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); </b>/* compatible with NULL pointer */<b>
|
||||
</pre></b><BR>
|
||||
<pre><b>size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx,
|
||||
void* dst, size_t dstCapacity,
|
||||
@ -194,7 +207,7 @@ size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); </b>/* accept NULL pointer */<b>
|
||||
this function compresses at the requested compression level,
|
||||
__ignoring any other advanced parameter__ .
|
||||
If any advanced parameter was set using the advanced API,
|
||||
they will all be reset. Only `compressionLevel` remains.
|
||||
they will all be reset. Only @compressionLevel remains.
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
@ -298,7 +311,7 @@ size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); </b>/* accept NULL pointer */<b>
|
||||
* Special: value 0 means "use default strategy". */
|
||||
|
||||
ZSTD_c_targetCBlockSize=130, </b>/* v1.5.6+<b>
|
||||
* Attempts to fit compressed block size into approximatively targetCBlockSize.
|
||||
* 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.
|
||||
@ -394,7 +407,8 @@ size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); </b>/* accept NULL pointer */<b>
|
||||
* ZSTD_c_stableOutBuffer
|
||||
* ZSTD_c_blockDelimiters
|
||||
* ZSTD_c_validateSequences
|
||||
* ZSTD_c_useBlockSplitter
|
||||
* ZSTD_c_blockSplitterLevel
|
||||
* ZSTD_c_splitAfterSequences
|
||||
* ZSTD_c_useRowMatchFinder
|
||||
* ZSTD_c_prefetchCDictTables
|
||||
* ZSTD_c_enableSeqProducerFallback
|
||||
@ -421,7 +435,8 @@ size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); </b>/* accept NULL pointer */<b>
|
||||
ZSTD_c_experimentalParam16=1013,
|
||||
ZSTD_c_experimentalParam17=1014,
|
||||
ZSTD_c_experimentalParam18=1015,
|
||||
ZSTD_c_experimentalParam19=1016
|
||||
ZSTD_c_experimentalParam19=1016,
|
||||
ZSTD_c_experimentalParam20=1017
|
||||
} ZSTD_cParameter;
|
||||
</b></pre><BR>
|
||||
<pre><b>typedef struct {
|
||||
@ -718,7 +733,7 @@ size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output);
|
||||
<a name="Chapter9"></a><h2>Streaming decompression - HowTo</h2><pre>
|
||||
A ZSTD_DStream object is required to track streaming operations.
|
||||
Use ZSTD_createDStream() and ZSTD_freeDStream() to create/release resources.
|
||||
ZSTD_DStream objects can be reused multiple times.
|
||||
ZSTD_DStream objects can be re-employed multiple times.
|
||||
|
||||
Use ZSTD_initDStream() to start a new decompression operation.
|
||||
@return : recommended first input size
|
||||
@ -728,16 +743,21 @@ size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output);
|
||||
The function will update both `pos` fields.
|
||||
If `input.pos < input.size`, some input has not been consumed.
|
||||
It's up to the caller to present again remaining data.
|
||||
|
||||
The function tries to flush all data decoded immediately, respecting output buffer size.
|
||||
If `output.pos < output.size`, decoder has flushed everything it could.
|
||||
But if `output.pos == output.size`, there might be some data left within internal buffers.,
|
||||
|
||||
However, when `output.pos == output.size`, it's more difficult to know.
|
||||
If @return > 0, the frame is not complete, meaning
|
||||
either there is still some data left to flush within internal buffers,
|
||||
or there is more input to read to complete the frame (or both).
|
||||
In which case, call ZSTD_decompressStream() again to flush whatever remains in the buffer.
|
||||
Note : with no additional input provided, amount of data flushed is necessarily <= ZSTD_BLOCKSIZE_MAX.
|
||||
@return : 0 when a frame is completely decoded and fully flushed,
|
||||
or an error code, which can be tested using ZSTD_isError(),
|
||||
or any other value > 0, which means there is still some decoding or flushing to do to complete current frame :
|
||||
the return value is a suggested next input size (just a hint for better latency)
|
||||
that will never request more than the remaining frame size.
|
||||
that will never request more than the remaining content of the compressed frame.
|
||||
|
||||
<BR></pre>
|
||||
|
||||
@ -763,9 +783,10 @@ size_t ZSTD_freeDStream(ZSTD_DStream* zds); </b>/* accept NULL pointer */<b>
|
||||
Function will update both input and output `pos` fields exposing current state via these fields:
|
||||
- `input.pos < input.size`, some input remaining and caller should provide remaining input
|
||||
on the next call.
|
||||
- `output.pos < output.size`, decoder finished and flushed all remaining buffers.
|
||||
- `output.pos == output.size`, potentially uncflushed data present in the internal buffers,
|
||||
call ZSTD_decompressStream() again to flush remaining data to output.
|
||||
- `output.pos < output.size`, decoder flushed internal output buffer.
|
||||
- `output.pos == output.size`, unflushed data potentially present in the internal buffers,
|
||||
check ZSTD_decompressStream() @return value,
|
||||
if > 0, invoke it again to flush remaining data to output.
|
||||
Note : with no additional input, amount of data flushed <= ZSTD_BLOCKSIZE_MAX.
|
||||
|
||||
@return : 0 when a frame is completely decoded and fully flushed,
|
||||
@ -1067,7 +1088,7 @@ size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
|
||||
*
|
||||
* Note: This field is optional. ZSTD_generateSequences() will calculate the value of
|
||||
* 'rep', but repeat offsets do not necessarily need to be calculated from an external
|
||||
* sequence provider's perspective. For example, ZSTD_compressSequences() does not
|
||||
* sequence provider perspective. For example, ZSTD_compressSequences() does not
|
||||
* use this 'rep' field at all (as of now).
|
||||
*/
|
||||
} ZSTD_Sequence;
|
||||
@ -1172,14 +1193,14 @@ size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
|
||||
} ZSTD_literalCompressionMode_e;
|
||||
</b></pre><BR>
|
||||
<pre><b>typedef enum {
|
||||
</b>/* Note: This enum controls features which are conditionally beneficial. Zstd typically will make a final<b>
|
||||
* decision on whether or not to enable the feature (ZSTD_ps_auto), but setting the switch to ZSTD_ps_enable
|
||||
* or ZSTD_ps_disable allow for a force enable/disable the feature.
|
||||
</b>/* Note: This enum controls features which are conditionally beneficial.<b>
|
||||
* Zstd can take a decision on whether or not to enable the feature (ZSTD_ps_auto),
|
||||
* but setting the switch to ZSTD_ps_enable or ZSTD_ps_disable force enable/disable the feature.
|
||||
*/
|
||||
ZSTD_ps_auto = 0, </b>/* Let the library automatically determine whether the feature shall be enabled */<b>
|
||||
ZSTD_ps_enable = 1, </b>/* Force-enable the feature */<b>
|
||||
ZSTD_ps_disable = 2 </b>/* Do not use the feature */<b>
|
||||
} ZSTD_paramSwitch_e;
|
||||
} ZSTD_ParamSwitch_e;
|
||||
</b></pre><BR>
|
||||
<a name="Chapter15"></a><h2>Frame header and size functions</h2><pre></pre>
|
||||
|
||||
@ -1222,33 +1243,33 @@ size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>ZSTDLIB_STATIC_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
|
||||
</b><p> srcSize must be >= ZSTD_FRAMEHEADERSIZE_PREFIX.
|
||||
</b><p> srcSize must be large enough, aka >= ZSTD_FRAMEHEADERSIZE_PREFIX.
|
||||
@return : size of the Frame Header,
|
||||
or an error code (if srcSize is too small)
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>typedef enum { ZSTD_frame, ZSTD_skippableFrame } ZSTD_frameType_e;
|
||||
<pre><b>typedef enum { ZSTD_frame, ZSTD_skippableFrame } ZSTD_FrameType_e;
|
||||
</b></pre><BR>
|
||||
<pre><b>typedef struct {
|
||||
unsigned long long frameContentSize; </b>/* if == ZSTD_CONTENTSIZE_UNKNOWN, it means this field is not available. 0 means "empty" */<b>
|
||||
unsigned long long windowSize; </b>/* can be very large, up to <= frameContentSize */<b>
|
||||
unsigned blockSizeMax;
|
||||
ZSTD_frameType_e frameType; </b>/* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */<b>
|
||||
ZSTD_FrameType_e frameType; </b>/* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */<b>
|
||||
unsigned headerSize;
|
||||
unsigned dictID;
|
||||
unsigned dictID; </b>/* for ZSTD_skippableFrame, contains the skippable magic variant [0-15] */<b>
|
||||
unsigned checksumFlag;
|
||||
unsigned _reserved1;
|
||||
unsigned _reserved2;
|
||||
} ZSTD_frameHeader;
|
||||
} ZSTD_FrameHeader;
|
||||
</b></pre><BR>
|
||||
<pre><b>ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize); </b>/**< doesn't consume input */<b>
|
||||
<pre><b>ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader(ZSTD_FrameHeader* zfhPtr, const void* src, size_t srcSize);
|
||||
</b>/*! ZSTD_getFrameHeader_advanced() :<b>
|
||||
* same as ZSTD_getFrameHeader(),
|
||||
* with added capability to select a format (like ZSTD_f_zstd1_magicless) */
|
||||
ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format);
|
||||
</b><p> decode Frame Header, or requires larger `srcSize`.
|
||||
@return : 0, `zfhPtr` is correctly filled,
|
||||
>0, `srcSize` is too small, value is wanted `srcSize` amount,
|
||||
ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader_advanced(ZSTD_FrameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format);
|
||||
</b><p> decode Frame Header into `zfhPtr`, or requires larger `srcSize`.
|
||||
@return : 0 => header is complete, `zfhPtr` is correctly filled,
|
||||
>0 => `srcSize` is too small, @return value is the wanted `srcSize` amount, `zfhPtr` is not filled,
|
||||
or an error code, which can be tested using ZSTD_isError()
|
||||
</p></pre><BR>
|
||||
|
||||
@ -1298,9 +1319,9 @@ ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr,
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>typedef enum {
|
||||
ZSTD_sf_noBlockDelimiters = 0, </b>/* Representation of ZSTD_Sequence has no block delimiters, sequences only */<b>
|
||||
ZSTD_sf_explicitBlockDelimiters = 1 </b>/* Representation of ZSTD_Sequence contains explicit block delimiters */<b>
|
||||
} ZSTD_sequenceFormat_e;
|
||||
ZSTD_sf_noBlockDelimiters = 0, </b>/* ZSTD_Sequence[] has no block delimiters, just sequences */<b>
|
||||
ZSTD_sf_explicitBlockDelimiters = 1 </b>/* ZSTD_Sequence[] contains explicit block delimiters */<b>
|
||||
} ZSTD_SequenceFormat_e;
|
||||
</b></pre><BR>
|
||||
<pre><b>ZSTDLIB_STATIC_API size_t ZSTD_sequenceBound(size_t srcSize);
|
||||
</b><p> `srcSize` : size of the input buffer
|
||||
@ -1311,19 +1332,37 @@ ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr,
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b></b><p> Generate sequences using ZSTD_compress2(), given a source buffer.
|
||||
<pre><b>ZSTD_DEPRECATED("For debugging only, will be replaced by ZSTD_extractSequences()")
|
||||
ZSTDLIB_STATIC_API size_t
|
||||
ZSTD_generateSequences(ZSTD_CCtx* zc,
|
||||
ZSTD_Sequence* outSeqs, size_t outSeqsCapacity,
|
||||
const void* src, size_t srcSize);
|
||||
</b><p> WARNING: This function is meant for debugging and informational purposes ONLY!
|
||||
Its implementation is flawed, and it will be deleted in a future version.
|
||||
It is not guaranteed to succeed, as there are several cases where it will give
|
||||
up and fail. You should NOT use this function in production code.
|
||||
|
||||
This function is deprecated, and will be removed in a future version.
|
||||
|
||||
Generate sequences using ZSTD_compress2(), given a source buffer.
|
||||
|
||||
@param zc The compression context to be used for ZSTD_compress2(). Set any
|
||||
compression parameters you need on this context.
|
||||
@param outSeqs The output sequences buffer of size @p outSeqsSize
|
||||
@param outSeqsCapacity The size of the output sequences buffer.
|
||||
ZSTD_sequenceBound(srcSize) is an upper bound on the number
|
||||
of sequences that can be generated.
|
||||
@param src The source buffer to generate sequences from of size @p srcSize.
|
||||
@param srcSize The size of the source buffer.
|
||||
|
||||
Each block will end with a dummy sequence
|
||||
with offset == 0, matchLength == 0, and litLength == length of last literals.
|
||||
litLength may be == 0, and if so, then the sequence of (of: 0 ml: 0 ll: 0)
|
||||
simply acts as a block delimiter.
|
||||
|
||||
@zc can be used to insert custom compression params.
|
||||
This function invokes ZSTD_compress2().
|
||||
|
||||
The output of this function can be fed into ZSTD_compressSequences() with CCtx
|
||||
setting of ZSTD_c_blockDelimiters as ZSTD_sf_explicitBlockDelimiters
|
||||
@return : number of sequences generated
|
||||
@returns The number of sequences generated, necessarily less than
|
||||
ZSTD_sequenceBound(srcSize), or an error code that can be checked
|
||||
with ZSTD_isError().
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
@ -1341,13 +1380,14 @@ ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr,
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>ZSTDLIB_STATIC_API size_t
|
||||
ZSTD_compressSequences( ZSTD_CCtx* cctx, void* dst, size_t dstSize,
|
||||
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
||||
const void* src, size_t srcSize);
|
||||
ZSTD_compressSequences(ZSTD_CCtx* cctx,
|
||||
void* dst, size_t dstCapacity,
|
||||
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
||||
const void* src, size_t srcSize);
|
||||
</b><p> Compress an array of ZSTD_Sequence, associated with @src buffer, into dst.
|
||||
@src contains the entire input (not just the literals).
|
||||
If @srcSize > sum(sequence.length), the remaining bytes are considered all literals
|
||||
If a dictionary is included, then the cctx should reference the dict. (see: ZSTD_CCtx_refCDict(), ZSTD_CCtx_loadDictionary(), etc.)
|
||||
If a dictionary is included, then the cctx should reference the dict (see: ZSTD_CCtx_refCDict(), ZSTD_CCtx_loadDictionary(), etc.).
|
||||
The entire source is compressed into a single frame.
|
||||
|
||||
The compression behavior changes based on cctx params. In particular:
|
||||
@ -1356,11 +1396,17 @@ ZSTD_compressSequences( ZSTD_CCtx* cctx, void* dst, size_t dstSize,
|
||||
the block size derived from the cctx, and sequences may be split. This is the default setting.
|
||||
|
||||
If ZSTD_c_blockDelimiters == ZSTD_sf_explicitBlockDelimiters, the array of ZSTD_Sequence is expected to contain
|
||||
block delimiters (defined in ZSTD_Sequence). Behavior is undefined if no block delimiters are provided.
|
||||
valid block delimiters (defined in ZSTD_Sequence). Behavior is undefined if no block delimiters are provided.
|
||||
|
||||
If ZSTD_c_validateSequences == 0, this function will blindly accept the sequences provided. Invalid sequences cause undefined
|
||||
behavior. If ZSTD_c_validateSequences == 1, then if sequence is invalid (see doc/zstd_compression_format.md for
|
||||
specifics regarding offset/matchlength requirements) then the function will bail out and return an error.
|
||||
When ZSTD_c_blockDelimiters == ZSTD_sf_explicitBlockDelimiters, it's possible to decide generating repcodes
|
||||
using the advanced parameter ZSTD_c_repcodeResolution. Repcodes will improve compression ratio, though the benefit
|
||||
can vary greatly depending on Sequences. On the other hand, repcode resolution is an expensive operation.
|
||||
By default, it's disabled at low (<10) compression levels, and enabled above the threshold (>=10).
|
||||
ZSTD_c_repcodeResolution makes it possible to directly manage this processing in either direction.
|
||||
|
||||
If ZSTD_c_validateSequences == 0, this function blindly accepts the Sequences provided. Invalid Sequences cause undefined
|
||||
behavior. If ZSTD_c_validateSequences == 1, then the function will detect invalid Sequences (see doc/zstd_compression_format.md for
|
||||
specifics regarding offset/matchlength requirements) and then bail out and return an error.
|
||||
|
||||
In addition to the two adjustable experimental params, there are other important cctx params.
|
||||
- ZSTD_c_minMatch MUST be set as less than or equal to the smallest match generated by the match finder. It has a minimum value of ZSTD_MINMATCH_MIN.
|
||||
@ -1368,21 +1414,47 @@ ZSTD_compressSequences( ZSTD_CCtx* cctx, void* dst, size_t dstSize,
|
||||
- ZSTD_c_windowLog affects offset validation: this function will return an error at higher debug levels if a provided offset
|
||||
is larger than what the spec allows for a given window log and dictionary (if present). See: doc/zstd_compression_format.md
|
||||
|
||||
Note: Repcodes are, as of now, always re-calculated within this function, so ZSTD_Sequence::rep is unused.
|
||||
Note 2: Once we integrate ability to ingest repcodes, the explicit block delims mode must respect those repcodes exactly,
|
||||
and cannot emit an RLE block that disagrees with the repcode history
|
||||
Note: Repcodes are, as of now, always re-calculated within this function, ZSTD_Sequence.rep is effectively unused.
|
||||
Dev Note: Once ability to ingest repcodes become available, the explicit block delims mode must respect those repcodes exactly,
|
||||
and cannot emit an RLE block that disagrees with the repcode history.
|
||||
@return : final compressed size, or a ZSTD error code.
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>ZSTDLIB_STATIC_API size_t
|
||||
ZSTD_compressSequencesAndLiterals(ZSTD_CCtx* cctx,
|
||||
void* dst, size_t dstCapacity,
|
||||
const ZSTD_Sequence* inSeqs, size_t nbSequences,
|
||||
const void* literals, size_t litSize, size_t litBufCapacity,
|
||||
size_t decompressedSize);
|
||||
</b><p> This is a variant of ZSTD_compressSequences() which,
|
||||
instead of receiving (src,srcSize) as input parameter, receives (literals,litSize),
|
||||
aka all the literals, already extracted and laid out into a single continuous buffer.
|
||||
This can be useful if the process generating the sequences also happens to generate the buffer of literals,
|
||||
thus skipping an extraction + caching stage.
|
||||
It's a speed optimization, useful when the right conditions are met,
|
||||
but it also features the following limitations:
|
||||
- Only supports explicit delimiter mode
|
||||
- Currently does not support Sequences validation (so input Sequences are trusted)
|
||||
- Not compatible with frame checksum, which must be disabled
|
||||
- If any block is incompressible, will fail and return an error
|
||||
- @litSize must be == sum of all @.litLength fields in @inSeqs. Any discrepancy will generate an error.
|
||||
- @litBufCapacity is the size of the underlying buffer into which literals are written, starting at address @literals.
|
||||
@litBufCapacity must be at least 8 bytes larger than @litSize.
|
||||
- @decompressedSize must be correct, and correspond to the sum of all Sequences. Any discrepancy will generate an error.
|
||||
@return : final compressed size, or a ZSTD error code.
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>ZSTDLIB_STATIC_API size_t ZSTD_writeSkippableFrame(void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize, unsigned magicVariant);
|
||||
const void* src, size_t srcSize,
|
||||
unsigned magicVariant);
|
||||
</b><p> Generates a zstd skippable frame containing data given by src, and writes it to dst buffer.
|
||||
|
||||
Skippable frames begin with a 4-byte magic number. There are 16 possible choices of magic number,
|
||||
ranging from ZSTD_MAGIC_SKIPPABLE_START to ZSTD_MAGIC_SKIPPABLE_START+15.
|
||||
As such, the parameter magicVariant controls the exact skippable frame magic number variant used, so
|
||||
the magic number used will be ZSTD_MAGIC_SKIPPABLE_START + magicVariant.
|
||||
As such, the parameter magicVariant controls the exact skippable frame magic number variant used,
|
||||
so the magic number used will be ZSTD_MAGIC_SKIPPABLE_START + magicVariant.
|
||||
|
||||
Returns an error if destination buffer is not large enough, if the source size is not representable
|
||||
with a 4-byte unsigned int, or if the parameter magicVariant is greater than 15 (and therefore invalid).
|
||||
@ -1391,13 +1463,14 @@ ZSTD_compressSequences( ZSTD_CCtx* cctx, void* dst, size_t dstSize,
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>size_t ZSTD_readSkippableFrame(void* dst, size_t dstCapacity, unsigned* magicVariant,
|
||||
const void* src, size_t srcSize);
|
||||
</b><p> Retrieves a zstd skippable frame containing data given by src, and writes it to dst buffer.
|
||||
<pre><b>ZSTDLIB_STATIC_API size_t ZSTD_readSkippableFrame(void* dst, size_t dstCapacity,
|
||||
unsigned* magicVariant,
|
||||
const void* src, size_t srcSize);
|
||||
</b><p> Retrieves the content of a zstd skippable frame starting at @src, and writes it to @dst buffer.
|
||||
|
||||
The parameter magicVariant will receive the magicVariant that was supplied when the frame was written,
|
||||
i.e. magicNumber - ZSTD_MAGIC_SKIPPABLE_START. This can be NULL if the caller is not interested
|
||||
in the magicVariant.
|
||||
The parameter @magicVariant will receive the magicVariant that was supplied when the frame was written,
|
||||
i.e. magicNumber - ZSTD_MAGIC_SKIPPABLE_START.
|
||||
This can be NULL if the caller is not interested in the magicVariant.
|
||||
|
||||
Returns an error if destination buffer is not large enough, or if the frame is not skippable.
|
||||
|
||||
@ -1405,7 +1478,7 @@ ZSTD_compressSequences( ZSTD_CCtx* cctx, void* dst, size_t dstSize,
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>unsigned ZSTD_isSkippableFrame(const void* buffer, size_t size);
|
||||
<pre><b>ZSTDLIB_STATIC_API unsigned ZSTD_isSkippableFrame(const void* buffer, size_t size);
|
||||
</b><p> Tells if the content of `buffer` starts with a valid Frame Identifier for a skippable frame.
|
||||
|
||||
</p></pre><BR>
|
||||
@ -1512,13 +1585,14 @@ static
|
||||
#ifdef __GNUC__
|
||||
__attribute__((__unused__))
|
||||
#endif
|
||||
ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; </b>/**< this constant defers to stdlib's functions */<b>
|
||||
</b><p> These prototypes make it possible to pass your own allocation/free functions.
|
||||
ZSTD_customMem is provided at creation time, using ZSTD_create*_advanced() variants listed below.
|
||||
All allocation/free operations will be completed using these custom variants instead of regular <stdlib.h> ones.
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; </b>/**< this constant defers to stdlib's functions */<b>
|
||||
</b></pre><BR>
|
||||
<pre><b>typedef struct POOL_ctx_s ZSTD_threadPool;
|
||||
ZSTDLIB_STATIC_API ZSTD_threadPool* ZSTD_createThreadPool(size_t numThreads);
|
||||
ZSTDLIB_STATIC_API void ZSTD_freeThreadPool (ZSTD_threadPool* pool); </b>/* accept NULL pointer */<b>
|
||||
@ -2057,7 +2131,7 @@ ZSTDLIB_STATIC_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const Z
|
||||
>0 : `srcSize` is too small, please provide at least result bytes on next attempt.
|
||||
errorCode, which can be tested using ZSTD_isError().
|
||||
|
||||
It fills a ZSTD_frameHeader structure with important information to correctly decode the frame,
|
||||
It fills a ZSTD_FrameHeader structure with important information to correctly decode the frame,
|
||||
such as the dictionary ID, content size, or maximum back-reference distance (`windowSize`).
|
||||
Note that these values could be wrong, either because of data corruption, or because a 3rd party deliberately spoofs false information.
|
||||
As a consequence, check that values remain within valid application range.
|
||||
|
36
lib/Makefile
36
lib/Makefile
@ -63,6 +63,8 @@ CPPFLAGS_DYNLIB += -DZSTD_MULTITHREAD # dynamic library build defaults to multi
|
||||
LDFLAGS_DYNLIB += -pthread
|
||||
CPPFLAGS_STATICLIB += # static library build defaults to single-threaded
|
||||
|
||||
# pkg-config Libs.private points to LDFLAGS_DYNLIB
|
||||
PCLIB := $(LDFLAGS_DYNLIB)
|
||||
|
||||
ifeq ($(findstring GCC,$(CCVER)),GCC)
|
||||
decompress/zstd_decompress_block.o : CFLAGS+=-fno-tree-vectorize
|
||||
@ -71,13 +73,15 @@ endif
|
||||
|
||||
# macOS linker doesn't support -soname, and use different extension
|
||||
# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
|
||||
ifeq ($(UNAME), Darwin)
|
||||
UNAME_TARGET_SYSTEM ?= $(UNAME)
|
||||
|
||||
ifeq ($(UNAME_TARGET_SYSTEM), Darwin)
|
||||
SHARED_EXT = dylib
|
||||
SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
|
||||
SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
|
||||
SONAME_FLAGS = -install_name $(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER)
|
||||
else
|
||||
ifeq ($(UNAME), AIX)
|
||||
ifeq ($(UNAME_TARGET_SYSTEM), AIX)
|
||||
SONAME_FLAGS =
|
||||
else
|
||||
SONAME_FLAGS = -Wl,-soname=libzstd.$(SHARED_EXT).$(LIBVER_MAJOR)
|
||||
@ -162,7 +166,7 @@ $(ZSTD_DYNLIB): $(ZSTD_DYNLIB_OBJ)
|
||||
$(if $(filter -DZSTD_MULTITHREAD,$(CPPFLAGS)),\
|
||||
@echo compiling multi-threaded dynamic library $(LIBVER),\
|
||||
@echo compiling single-threaded dynamic library $(LIBVER))
|
||||
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
||||
$(CC) $(FLAGS) $^ $(SONAME_FLAGS) -o $@
|
||||
@echo creating versioned links
|
||||
ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
|
||||
ln -sf $@ libzstd.$(SHARED_EXT)
|
||||
@ -186,12 +190,15 @@ lib : libzstd.a libzstd
|
||||
%-mt : CPPFLAGS_DYNLIB := -DZSTD_MULTITHREAD
|
||||
%-mt : CPPFLAGS_STATICLIB := -DZSTD_MULTITHREAD
|
||||
%-mt : LDFLAGS_DYNLIB := -pthread
|
||||
%-mt : PCLIB :=
|
||||
%-mt : PCMTLIB := $(LDFLAGS_DYNLIB)
|
||||
%-mt : %
|
||||
@echo multi-threaded build completed
|
||||
|
||||
%-nomt : CPPFLAGS_DYNLIB :=
|
||||
%-nomt : LDFLAGS_DYNLIB :=
|
||||
%-nomt : CPPFLAGS_STATICLIB :=
|
||||
%-nomt : PCLIB :=
|
||||
%-nomt : %
|
||||
@echo single-threaded build completed
|
||||
|
||||
@ -248,7 +255,7 @@ libzstd-nomt: $(ZSTD_NOMT_FILES)
|
||||
echo "Error: Found zstdmt in list."; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
||||
$(CC) $(FLAGS) $^ $(SONAME_FLAGS) -o $@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@ -261,7 +268,7 @@ clean:
|
||||
#-----------------------------------------------------------------------------
|
||||
# make install is validated only for below listed environments
|
||||
#-----------------------------------------------------------------------------
|
||||
ifneq (,$(filter $(UNAME),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku AIX MSYS_NT CYGWIN_NT))
|
||||
ifneq (,$(filter Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku AIX MSYS_NT% CYGWIN_NT%,$(UNAME)))
|
||||
|
||||
lib: libzstd.pc
|
||||
|
||||
@ -292,13 +299,21 @@ PCLIBPREFIX := $(if $(findstring $(LIBDIR),$(PCLIBDIR)),,$${exec_prefix})
|
||||
# to PREFIX, rather than as a resolved value.
|
||||
PCEXEC_PREFIX := $(if $(HAS_EXPLICIT_EXEC_PREFIX),$(EXEC_PREFIX),$${prefix})
|
||||
|
||||
ifneq (,$(filter $(UNAME),FreeBSD NetBSD DragonFly))
|
||||
|
||||
ifneq ($(MT),)
|
||||
PCLIB :=
|
||||
PCMTLIB := $(LDFLAGS_DYNLIB)
|
||||
else
|
||||
PCLIB := $(LDFLAGS_DYNLIB)
|
||||
endif
|
||||
|
||||
ifneq (,$(filter FreeBSD NetBSD DragonFly,$(UNAME)))
|
||||
PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
|
||||
else
|
||||
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(UNAME),SunOS))
|
||||
ifneq (,$(filter SunOS,$(UNAME)))
|
||||
INSTALL ?= ginstall
|
||||
else
|
||||
INSTALL ?= install
|
||||
@ -308,6 +323,10 @@ INSTALL_PROGRAM ?= $(INSTALL)
|
||||
INSTALL_DATA ?= $(INSTALL) -m 644
|
||||
|
||||
|
||||
# pkg-config library define.
|
||||
# For static single-threaded library declare -pthread in Libs.private
|
||||
# For static multi-threaded library declare -pthread in Libs and Cflags
|
||||
.PHONY: libzstd.pc
|
||||
libzstd.pc: libzstd.pc.in
|
||||
@echo creating pkgconfig
|
||||
@sed \
|
||||
@ -316,7 +335,8 @@ libzstd.pc: libzstd.pc.in
|
||||
-e 's|@INCLUDEDIR@|$(PCINCPREFIX)$(PCINCDIR)|' \
|
||||
-e 's|@LIBDIR@|$(PCLIBPREFIX)$(PCLIBDIR)|' \
|
||||
-e 's|@VERSION@|$(VERSION)|' \
|
||||
-e 's|@LIBS_PRIVATE@|$(LDFLAGS_DYNLIB)|' \
|
||||
-e 's|@LIBS_MT@|$(PCMTLIB)|' \
|
||||
-e 's|@LIBS_PRIVATE@|$(PCLIB)|' \
|
||||
$< >$@
|
||||
|
||||
.PHONY: install
|
||||
|
@ -27,12 +27,16 @@ Enabling multithreading requires 2 conditions :
|
||||
|
||||
For convenience, we provide a build target to generate multi and single threaded libraries:
|
||||
- Force enable multithreading on both dynamic and static libraries by appending `-mt` to the target, e.g. `make lib-mt`.
|
||||
Note that the `.pc` generated on calling `make lib-mt` will already include the require Libs and Cflags.
|
||||
- Force disable multithreading on both dynamic and static libraries by appending `-nomt` to the target, e.g. `make lib-nomt`.
|
||||
- By default, as mentioned before, dynamic library is multithreaded, and static library is single-threaded, e.g. `make lib`.
|
||||
|
||||
When linking a POSIX program with a multithreaded version of `libzstd`,
|
||||
note that it's necessary to invoke the `-pthread` flag during link stage.
|
||||
|
||||
The `.pc` generated from `make install` or `make install-pc` always assume a single-threaded static library
|
||||
is compiled. To correctly generate a `.pc` for the multi-threaded static library, set `MT=1` as ENV variable.
|
||||
|
||||
Multithreading capabilities are exposed
|
||||
via the [advanced API defined in `lib/zstd.h`](https://github.com/facebook/zstd/blob/v1.4.3/lib/zstd.h#L351).
|
||||
|
||||
@ -145,6 +149,13 @@ The file structure is designed to make this selection manually achievable for an
|
||||
will expose the deprecated `ZSTDMT` API exposed by `zstdmt_compress.h` in
|
||||
the shared library, which is now hidden by default.
|
||||
|
||||
- The build macro `STATIC_BMI2` can be set to 1 to force usage of `bmi2` instructions.
|
||||
It is generally not necessary to set this build macro,
|
||||
because `STATIC_BMI2` will be automatically set to 1
|
||||
on detecting the presence of the corresponding instruction set in the compilation target.
|
||||
It's nonetheless available as an optional manual toggle for better control,
|
||||
and can also be used to forcefully disable `bmi2` instructions by setting it to 0.
|
||||
|
||||
- The build macro `DYNAMIC_BMI2` can be set to 1 or 0 in order to generate binaries
|
||||
which can detect at runtime the presence of BMI2 instructions, and use them only if present.
|
||||
These instructions contribute to better performance, notably on the decoder side.
|
||||
@ -182,6 +193,11 @@ The file structure is designed to make this selection manually achievable for an
|
||||
and assembly decoding loops. You may want to use this macro if these loops are
|
||||
slower on your platform.
|
||||
|
||||
- The macro `ZDICT_QSORT` can enforce selection of a specific sorting variant,
|
||||
which is useful when autodetection fails, for example with older versions of `musl`.
|
||||
For this scenario, it can be set as `ZDICT_QSORT=ZDICT_QSORT_C90`.
|
||||
Other selectable suffixes are `_GNU`, `_APPLE`, `_MSVC` and `_C11`.
|
||||
|
||||
#### Windows : using MinGW+MSYS to create DLL
|
||||
|
||||
DLL can be created using MinGW+MSYS with the `make libzstd` command.
|
||||
|
@ -21,34 +21,36 @@ MEM_STATIC unsigned ZSTD_countTrailingZeros32_fallback(U32 val)
|
||||
30, 22, 20, 15, 25, 17, 4, 8,
|
||||
31, 27, 13, 23, 21, 19, 16, 7,
|
||||
26, 12, 18, 6, 11, 5, 10, 9};
|
||||
return DeBruijnBytePos[((U32) ((val & -(S32) val) * 0x077CB531U)) >> 27];
|
||||
return DeBruijnBytePos[((U32) ((val & (0-val)) * 0x077CB531U)) >> 27];
|
||||
}
|
||||
}
|
||||
|
||||
MEM_STATIC unsigned ZSTD_countTrailingZeros32(U32 val)
|
||||
{
|
||||
assert(val != 0);
|
||||
# if defined(_MSC_VER)
|
||||
# if STATIC_BMI2 == 1
|
||||
return (unsigned)_tzcnt_u32(val);
|
||||
# else
|
||||
if (val != 0) {
|
||||
unsigned long r;
|
||||
_BitScanForward(&r, val);
|
||||
return (unsigned)r;
|
||||
} else {
|
||||
/* Should not reach this code path */
|
||||
__assume(0);
|
||||
}
|
||||
# endif
|
||||
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||
return (unsigned)__builtin_ctz(val);
|
||||
# else
|
||||
return ZSTD_countTrailingZeros32_fallback(val);
|
||||
# endif
|
||||
#if defined(_MSC_VER)
|
||||
# if STATIC_BMI2
|
||||
return (unsigned)_tzcnt_u32(val);
|
||||
# else
|
||||
if (val != 0) {
|
||||
unsigned long r;
|
||||
_BitScanForward(&r, val);
|
||||
return (unsigned)r;
|
||||
} else {
|
||||
__assume(0); /* Should not reach this code path */
|
||||
}
|
||||
# endif
|
||||
#elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||
return (unsigned)__builtin_ctz(val);
|
||||
#elif defined(__ICCARM__)
|
||||
return (unsigned)__builtin_ctz(val);
|
||||
#else
|
||||
return ZSTD_countTrailingZeros32_fallback(val);
|
||||
#endif
|
||||
}
|
||||
|
||||
MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val) {
|
||||
MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val)
|
||||
{
|
||||
assert(val != 0);
|
||||
{
|
||||
static const U32 DeBruijnClz[32] = {0, 9, 1, 10, 13, 21, 2, 29,
|
||||
@ -67,86 +69,89 @@ MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val) {
|
||||
MEM_STATIC unsigned ZSTD_countLeadingZeros32(U32 val)
|
||||
{
|
||||
assert(val != 0);
|
||||
# if defined(_MSC_VER)
|
||||
# if STATIC_BMI2 == 1
|
||||
return (unsigned)_lzcnt_u32(val);
|
||||
# else
|
||||
if (val != 0) {
|
||||
unsigned long r;
|
||||
_BitScanReverse(&r, val);
|
||||
return (unsigned)(31 - r);
|
||||
} else {
|
||||
/* Should not reach this code path */
|
||||
__assume(0);
|
||||
}
|
||||
# endif
|
||||
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||
return (unsigned)__builtin_clz(val);
|
||||
# else
|
||||
return ZSTD_countLeadingZeros32_fallback(val);
|
||||
# endif
|
||||
#if defined(_MSC_VER)
|
||||
# if STATIC_BMI2
|
||||
return (unsigned)_lzcnt_u32(val);
|
||||
# else
|
||||
if (val != 0) {
|
||||
unsigned long r;
|
||||
_BitScanReverse(&r, val);
|
||||
return (unsigned)(31 - r);
|
||||
} else {
|
||||
__assume(0); /* Should not reach this code path */
|
||||
}
|
||||
# endif
|
||||
#elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||
return (unsigned)__builtin_clz(val);
|
||||
#elif defined(__ICCARM__)
|
||||
return (unsigned)__builtin_clz(val);
|
||||
#else
|
||||
return ZSTD_countLeadingZeros32_fallback(val);
|
||||
#endif
|
||||
}
|
||||
|
||||
MEM_STATIC unsigned ZSTD_countTrailingZeros64(U64 val)
|
||||
{
|
||||
assert(val != 0);
|
||||
# if defined(_MSC_VER) && defined(_WIN64)
|
||||
# if STATIC_BMI2 == 1
|
||||
return (unsigned)_tzcnt_u64(val);
|
||||
# else
|
||||
if (val != 0) {
|
||||
unsigned long r;
|
||||
_BitScanForward64(&r, val);
|
||||
return (unsigned)r;
|
||||
} else {
|
||||
/* Should not reach this code path */
|
||||
__assume(0);
|
||||
}
|
||||
# endif
|
||||
# elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
|
||||
return (unsigned)__builtin_ctzll(val);
|
||||
# else
|
||||
{
|
||||
U32 mostSignificantWord = (U32)(val >> 32);
|
||||
U32 leastSignificantWord = (U32)val;
|
||||
if (leastSignificantWord == 0) {
|
||||
return 32 + ZSTD_countTrailingZeros32(mostSignificantWord);
|
||||
} else {
|
||||
return ZSTD_countTrailingZeros32(leastSignificantWord);
|
||||
}
|
||||
#if defined(_MSC_VER) && defined(_WIN64)
|
||||
# if STATIC_BMI2
|
||||
return (unsigned)_tzcnt_u64(val);
|
||||
# else
|
||||
if (val != 0) {
|
||||
unsigned long r;
|
||||
_BitScanForward64(&r, val);
|
||||
return (unsigned)r;
|
||||
} else {
|
||||
__assume(0); /* Should not reach this code path */
|
||||
}
|
||||
# endif
|
||||
#elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
|
||||
return (unsigned)__builtin_ctzll(val);
|
||||
#elif defined(__ICCARM__)
|
||||
return (unsigned)__builtin_ctzll(val);
|
||||
#else
|
||||
{
|
||||
U32 mostSignificantWord = (U32)(val >> 32);
|
||||
U32 leastSignificantWord = (U32)val;
|
||||
if (leastSignificantWord == 0) {
|
||||
return 32 + ZSTD_countTrailingZeros32(mostSignificantWord);
|
||||
} else {
|
||||
return ZSTD_countTrailingZeros32(leastSignificantWord);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
MEM_STATIC unsigned ZSTD_countLeadingZeros64(U64 val)
|
||||
{
|
||||
assert(val != 0);
|
||||
# if defined(_MSC_VER) && defined(_WIN64)
|
||||
# if STATIC_BMI2 == 1
|
||||
return (unsigned)_lzcnt_u64(val);
|
||||
# else
|
||||
if (val != 0) {
|
||||
unsigned long r;
|
||||
_BitScanReverse64(&r, val);
|
||||
return (unsigned)(63 - r);
|
||||
} else {
|
||||
/* Should not reach this code path */
|
||||
__assume(0);
|
||||
}
|
||||
# endif
|
||||
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||
return (unsigned)(__builtin_clzll(val));
|
||||
# else
|
||||
{
|
||||
U32 mostSignificantWord = (U32)(val >> 32);
|
||||
U32 leastSignificantWord = (U32)val;
|
||||
if (mostSignificantWord == 0) {
|
||||
return 32 + ZSTD_countLeadingZeros32(leastSignificantWord);
|
||||
} else {
|
||||
return ZSTD_countLeadingZeros32(mostSignificantWord);
|
||||
}
|
||||
#if defined(_MSC_VER) && defined(_WIN64)
|
||||
# if STATIC_BMI2
|
||||
return (unsigned)_lzcnt_u64(val);
|
||||
# else
|
||||
if (val != 0) {
|
||||
unsigned long r;
|
||||
_BitScanReverse64(&r, val);
|
||||
return (unsigned)(63 - r);
|
||||
} else {
|
||||
__assume(0); /* Should not reach this code path */
|
||||
}
|
||||
# endif
|
||||
#elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||
return (unsigned)(__builtin_clzll(val));
|
||||
#elif defined(__ICCARM__)
|
||||
return (unsigned)(__builtin_clzll(val));
|
||||
#else
|
||||
{
|
||||
U32 mostSignificantWord = (U32)(val >> 32);
|
||||
U32 leastSignificantWord = (U32)val;
|
||||
if (mostSignificantWord == 0) {
|
||||
return 32 + ZSTD_countLeadingZeros32(leastSignificantWord);
|
||||
} else {
|
||||
return ZSTD_countLeadingZeros32(mostSignificantWord);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
MEM_STATIC unsigned ZSTD_NbCommonBytes(size_t val)
|
||||
|
@ -14,9 +14,6 @@
|
||||
#ifndef BITSTREAM_H_MODULE
|
||||
#define BITSTREAM_H_MODULE
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* This API consists of small unitary functions, which must be inlined for best performance.
|
||||
* Since link-time-optimization is not available for all compilers,
|
||||
@ -32,7 +29,6 @@ extern "C" {
|
||||
#include "error_private.h" /* error codes and messages */
|
||||
#include "bits.h" /* ZSTD_highbit32 */
|
||||
|
||||
|
||||
/*=========================================
|
||||
* Target specific
|
||||
=========================================*/
|
||||
@ -52,12 +48,13 @@ extern "C" {
|
||||
/*-******************************************
|
||||
* bitStream encoding API (write forward)
|
||||
********************************************/
|
||||
typedef size_t BitContainerType;
|
||||
/* bitStream can mix input from multiple sources.
|
||||
* A critical property of these streams is that they encode and decode in **reverse** direction.
|
||||
* So the first bit sequence you add will be the last to be read, like a LIFO stack.
|
||||
*/
|
||||
typedef struct {
|
||||
size_t bitContainer;
|
||||
BitContainerType bitContainer;
|
||||
unsigned bitPos;
|
||||
char* startPtr;
|
||||
char* ptr;
|
||||
@ -65,7 +62,7 @@ typedef struct {
|
||||
} BIT_CStream_t;
|
||||
|
||||
MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC, void* dstBuffer, size_t dstCapacity);
|
||||
MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC, size_t value, unsigned nbBits);
|
||||
MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC, BitContainerType value, unsigned nbBits);
|
||||
MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC);
|
||||
MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC);
|
||||
|
||||
@ -74,7 +71,7 @@ MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC);
|
||||
* `dstCapacity` must be >= sizeof(bitD->bitContainer), otherwise @return will be an error code.
|
||||
*
|
||||
* bits are first added to a local register.
|
||||
* Local register is size_t, hence 64-bits on 64-bits systems, or 32-bits on 32-bits systems.
|
||||
* Local register is BitContainerType, 64-bits on 64-bits systems, or 32-bits on 32-bits systems.
|
||||
* Writing data into memory is an explicit operation, performed by the flushBits function.
|
||||
* Hence keep track how many bits are potentially stored into local register to avoid register overflow.
|
||||
* After a flushBits, a maximum of 7 bits might still be stored into local register.
|
||||
@ -90,7 +87,6 @@ MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC);
|
||||
/*-********************************************
|
||||
* bitStream decoding API (read backward)
|
||||
**********************************************/
|
||||
typedef size_t BitContainerType;
|
||||
typedef struct {
|
||||
BitContainerType bitContainer;
|
||||
unsigned bitsConsumed;
|
||||
@ -106,7 +102,7 @@ typedef enum { BIT_DStream_unfinished = 0, /* fully refilled */
|
||||
} BIT_DStream_status; /* result of BIT_reloadDStream() */
|
||||
|
||||
MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize);
|
||||
MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits);
|
||||
MEM_STATIC BitContainerType BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits);
|
||||
MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD);
|
||||
MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* bitD);
|
||||
|
||||
@ -125,7 +121,7 @@ MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* bitD);
|
||||
/*-****************************************
|
||||
* unsafe API
|
||||
******************************************/
|
||||
MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC, size_t value, unsigned nbBits);
|
||||
MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC, BitContainerType value, unsigned nbBits);
|
||||
/* faster, but works only if value is "clean", meaning all high bits above nbBits are 0 */
|
||||
|
||||
MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC);
|
||||
@ -163,10 +159,15 @@ MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC,
|
||||
return 0;
|
||||
}
|
||||
|
||||
FORCE_INLINE_TEMPLATE size_t BIT_getLowerBits(size_t bitContainer, U32 const nbBits)
|
||||
FORCE_INLINE_TEMPLATE BitContainerType BIT_getLowerBits(BitContainerType bitContainer, U32 const nbBits)
|
||||
{
|
||||
#if defined(STATIC_BMI2) && STATIC_BMI2 == 1 && !defined(ZSTD_NO_INTRINSICS)
|
||||
return _bzhi_u64(bitContainer, nbBits);
|
||||
#if STATIC_BMI2 && !defined(ZSTD_NO_INTRINSICS)
|
||||
# if (defined(__x86_64__) || defined(_M_X64)) && !defined(__ILP32__)
|
||||
return _bzhi_u64(bitContainer, nbBits);
|
||||
# else
|
||||
DEBUG_STATIC_ASSERT(sizeof(bitContainer) == sizeof(U32));
|
||||
return _bzhi_u32(bitContainer, nbBits);
|
||||
# endif
|
||||
#else
|
||||
assert(nbBits < BIT_MASK_SIZE);
|
||||
return bitContainer & BIT_mask[nbBits];
|
||||
@ -177,7 +178,7 @@ FORCE_INLINE_TEMPLATE size_t BIT_getLowerBits(size_t bitContainer, U32 const nbB
|
||||
* can add up to 31 bits into `bitC`.
|
||||
* Note : does not check for register overflow ! */
|
||||
MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC,
|
||||
size_t value, unsigned nbBits)
|
||||
BitContainerType value, unsigned nbBits)
|
||||
{
|
||||
DEBUG_STATIC_ASSERT(BIT_MASK_SIZE == 32);
|
||||
assert(nbBits < BIT_MASK_SIZE);
|
||||
@ -190,7 +191,7 @@ MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC,
|
||||
* works only if `value` is _clean_,
|
||||
* meaning all high bits above nbBits are 0 */
|
||||
MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC,
|
||||
size_t value, unsigned nbBits)
|
||||
BitContainerType value, unsigned nbBits)
|
||||
{
|
||||
assert((value>>nbBits) == 0);
|
||||
assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8);
|
||||
@ -237,7 +238,7 @@ MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC)
|
||||
BIT_addBitsFast(bitC, 1, 1); /* endMark */
|
||||
BIT_flushBits(bitC);
|
||||
if (bitC->ptr >= bitC->endPtr) return 0; /* overflow detected */
|
||||
return (bitC->ptr - bitC->startPtr) + (bitC->bitPos > 0);
|
||||
return (size_t)(bitC->ptr - bitC->startPtr) + (bitC->bitPos > 0);
|
||||
}
|
||||
|
||||
|
||||
@ -298,12 +299,12 @@ MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, si
|
||||
return srcSize;
|
||||
}
|
||||
|
||||
FORCE_INLINE_TEMPLATE size_t BIT_getUpperBits(BitContainerType bitContainer, U32 const start)
|
||||
FORCE_INLINE_TEMPLATE BitContainerType BIT_getUpperBits(BitContainerType bitContainer, U32 const start)
|
||||
{
|
||||
return bitContainer >> start;
|
||||
}
|
||||
|
||||
FORCE_INLINE_TEMPLATE size_t BIT_getMiddleBits(BitContainerType bitContainer, U32 const start, U32 const nbBits)
|
||||
FORCE_INLINE_TEMPLATE BitContainerType BIT_getMiddleBits(BitContainerType bitContainer, U32 const start, U32 const nbBits)
|
||||
{
|
||||
U32 const regMask = sizeof(bitContainer)*8 - 1;
|
||||
/* if start > regMask, bitstream is corrupted, and result is undefined */
|
||||
@ -313,7 +314,7 @@ FORCE_INLINE_TEMPLATE size_t BIT_getMiddleBits(BitContainerType bitContainer, U3
|
||||
* such cpus old (pre-Haswell, 2013) and their performance is not of that
|
||||
* importance.
|
||||
*/
|
||||
#if defined(__x86_64__) || defined(_M_X86)
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
return (bitContainer >> (start & regMask)) & ((((U64)1) << nbBits) - 1);
|
||||
#else
|
||||
return (bitContainer >> (start & regMask)) & BIT_mask[nbBits];
|
||||
@ -326,7 +327,7 @@ FORCE_INLINE_TEMPLATE size_t BIT_getMiddleBits(BitContainerType bitContainer, U3
|
||||
* On 32-bits, maxNbBits==24.
|
||||
* On 64-bits, maxNbBits==56.
|
||||
* @return : value extracted */
|
||||
FORCE_INLINE_TEMPLATE size_t BIT_lookBits(const BIT_DStream_t* bitD, U32 nbBits)
|
||||
FORCE_INLINE_TEMPLATE BitContainerType BIT_lookBits(const BIT_DStream_t* bitD, U32 nbBits)
|
||||
{
|
||||
/* arbitrate between double-shift and shift+mask */
|
||||
#if 1
|
||||
@ -342,7 +343,7 @@ FORCE_INLINE_TEMPLATE size_t BIT_lookBits(const BIT_DStream_t* bitD, U32 nbBits
|
||||
|
||||
/*! BIT_lookBitsFast() :
|
||||
* unsafe version; only works if nbBits >= 1 */
|
||||
MEM_STATIC size_t BIT_lookBitsFast(const BIT_DStream_t* bitD, U32 nbBits)
|
||||
MEM_STATIC BitContainerType BIT_lookBitsFast(const BIT_DStream_t* bitD, U32 nbBits)
|
||||
{
|
||||
U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
|
||||
assert(nbBits >= 1);
|
||||
@ -358,18 +359,18 @@ FORCE_INLINE_TEMPLATE void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits)
|
||||
* Read (consume) next n bits from local register and update.
|
||||
* Pay attention to not read more than nbBits contained into local register.
|
||||
* @return : extracted value. */
|
||||
FORCE_INLINE_TEMPLATE size_t BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits)
|
||||
FORCE_INLINE_TEMPLATE BitContainerType BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits)
|
||||
{
|
||||
size_t const value = BIT_lookBits(bitD, nbBits);
|
||||
BitContainerType const value = BIT_lookBits(bitD, nbBits);
|
||||
BIT_skipBits(bitD, nbBits);
|
||||
return value;
|
||||
}
|
||||
|
||||
/*! BIT_readBitsFast() :
|
||||
* unsafe version; only works if nbBits >= 1 */
|
||||
MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits)
|
||||
MEM_STATIC BitContainerType BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits)
|
||||
{
|
||||
size_t const value = BIT_lookBitsFast(bitD, nbBits);
|
||||
BitContainerType const value = BIT_lookBitsFast(bitD, nbBits);
|
||||
assert(nbBits >= 1);
|
||||
BIT_skipBits(bitD, nbBits);
|
||||
return value;
|
||||
@ -450,8 +451,4 @@ MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* DStream)
|
||||
return ((DStream->ptr == DStream->start) && (DStream->bitsConsumed == sizeof(DStream->bitContainer)*8));
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BITSTREAM_H_MODULE */
|
||||
|
@ -27,7 +27,7 @@
|
||||
# define INLINE_KEYWORD
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) || defined(__ICCARM__)
|
||||
#if defined(__GNUC__) || defined(__IAR_SYSTEMS_ICC__)
|
||||
# define FORCE_INLINE_ATTR __attribute__((always_inline))
|
||||
#elif defined(_MSC_VER)
|
||||
# define FORCE_INLINE_ATTR __forceinline
|
||||
@ -54,7 +54,7 @@
|
||||
#endif
|
||||
|
||||
/* UNUSED_ATTR tells the compiler it is okay if the function is unused. */
|
||||
#if defined(__GNUC__)
|
||||
#if defined(__GNUC__) || defined(__IAR_SYSTEMS_ICC__)
|
||||
# define UNUSED_ATTR __attribute__((unused))
|
||||
#else
|
||||
# define UNUSED_ATTR
|
||||
@ -95,6 +95,8 @@
|
||||
#ifndef MEM_STATIC /* already defined in Linux Kernel mem.h */
|
||||
#if defined(__GNUC__)
|
||||
# define MEM_STATIC static __inline UNUSED_ATTR
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
# define MEM_STATIC static inline UNUSED_ATTR
|
||||
#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
||||
# define MEM_STATIC static inline
|
||||
#elif defined(_MSC_VER)
|
||||
@ -108,7 +110,7 @@
|
||||
#ifdef _MSC_VER
|
||||
# define FORCE_NOINLINE static __declspec(noinline)
|
||||
#else
|
||||
# if defined(__GNUC__) || defined(__ICCARM__)
|
||||
# if defined(__GNUC__) || defined(__IAR_SYSTEMS_ICC__)
|
||||
# define FORCE_NOINLINE static __attribute__((__noinline__))
|
||||
# else
|
||||
# define FORCE_NOINLINE static
|
||||
@ -117,7 +119,7 @@
|
||||
|
||||
|
||||
/* target attribute */
|
||||
#if defined(__GNUC__) || defined(__ICCARM__)
|
||||
#if defined(__GNUC__) || defined(__IAR_SYSTEMS_ICC__)
|
||||
# define TARGET_ATTRIBUTE(target) __attribute__((__target__(target)))
|
||||
#else
|
||||
# define TARGET_ATTRIBUTE(target)
|
||||
@ -205,35 +207,41 @@
|
||||
# pragma warning(disable : 4324) /* disable: C4324: padded structure */
|
||||
#endif
|
||||
|
||||
/*Like DYNAMIC_BMI2 but for compile time determination of BMI2 support*/
|
||||
#ifndef STATIC_BMI2
|
||||
# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86))
|
||||
# ifdef __AVX2__ //MSVC does not have a BMI2 specific flag, but every CPU that supports AVX2 also supports BMI2
|
||||
# define STATIC_BMI2 1
|
||||
# endif
|
||||
# elif defined(__BMI2__) && defined(__x86_64__) && defined(__GNUC__)
|
||||
# define STATIC_BMI2 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef STATIC_BMI2
|
||||
#define STATIC_BMI2 0
|
||||
#endif
|
||||
|
||||
/* compile time determination of SIMD support */
|
||||
#if !defined(ZSTD_NO_INTRINSICS)
|
||||
# if defined(__SSE2__) || defined(_M_AMD64) || (defined (_M_IX86) && defined(_M_IX86_FP) && (_M_IX86_FP >= 2))
|
||||
# if defined(__AVX2__)
|
||||
# define ZSTD_ARCH_X86_AVX2
|
||||
# endif
|
||||
# if defined(__SSE2__) || defined(_M_X64) || (defined (_M_IX86) && defined(_M_IX86_FP) && (_M_IX86_FP >= 2))
|
||||
# define ZSTD_ARCH_X86_SSE2
|
||||
# endif
|
||||
# if defined(__ARM_NEON) || defined(_M_ARM64)
|
||||
# define ZSTD_ARCH_ARM_NEON
|
||||
# endif
|
||||
# if defined(__ARM_FEATURE_SVE)
|
||||
# define ZSTD_ARCH_ARM_SVE
|
||||
# endif
|
||||
# if defined(__ARM_FEATURE_SVE2)
|
||||
# define ZSTD_ARCH_ARM_SVE2
|
||||
# endif
|
||||
# if defined(__riscv) && defined(__riscv_vector)
|
||||
# define ZSTD_ARCH_RISCV_RVV
|
||||
# endif
|
||||
#
|
||||
# if defined(ZSTD_ARCH_X86_AVX2)
|
||||
# include <immintrin.h>
|
||||
# endif
|
||||
# if defined(ZSTD_ARCH_X86_SSE2)
|
||||
# include <emmintrin.h>
|
||||
# elif defined(ZSTD_ARCH_ARM_NEON)
|
||||
# include <arm_neon.h>
|
||||
# endif
|
||||
# if defined(ZSTD_ARCH_ARM_SVE) || defined(ZSTD_ARCH_ARM_SVE2)
|
||||
# include <arm_sve.h>
|
||||
# endif
|
||||
# if defined(ZSTD_ARCH_RISCV_RVV)
|
||||
# include <riscv_vector.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* C-language Attributes are added in C23. */
|
||||
@ -273,9 +281,15 @@
|
||||
#endif
|
||||
|
||||
/*-**************************************************************
|
||||
* Alignment check
|
||||
* Alignment
|
||||
*****************************************************************/
|
||||
|
||||
/* @return 1 if @u is a 2^n value, 0 otherwise
|
||||
* useful to check a value is valid for alignment restrictions */
|
||||
MEM_STATIC int ZSTD_isPower2(size_t u) {
|
||||
return (u & (u-1)) == 0;
|
||||
}
|
||||
|
||||
/* this test was initially positioned in mem.h,
|
||||
* but this file is removed (or replaced) for linux kernel
|
||||
* so it's now hosted in compiler.h,
|
||||
@ -301,6 +315,21 @@
|
||||
# endif
|
||||
#endif /* ZSTD_ALIGNOF */
|
||||
|
||||
#ifndef ZSTD_ALIGNED
|
||||
/* C90-compatible alignment macro (GCC/Clang). Adjust for other compilers if needed. */
|
||||
# if defined(__GNUC__) || defined(__clang__)
|
||||
# define ZSTD_ALIGNED(a) __attribute__((aligned(a)))
|
||||
# elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */
|
||||
# define ZSTD_ALIGNED(a) _Alignas(a)
|
||||
#elif defined(_MSC_VER)
|
||||
# define ZSTD_ALIGNED(n) __declspec(align(n))
|
||||
# else
|
||||
/* this compiler will require its own alignment instruction */
|
||||
# define ZSTD_ALIGNED(...)
|
||||
# endif
|
||||
#endif /* ZSTD_ALIGNED */
|
||||
|
||||
|
||||
/*-**************************************************************
|
||||
* Sanitizer
|
||||
*****************************************************************/
|
||||
@ -324,7 +353,7 @@
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Helper function to perform a wrapped pointer difference without trigging
|
||||
* Helper function to perform a wrapped pointer difference without triggering
|
||||
* UBSAN.
|
||||
*
|
||||
* @returns lhs - rhs with wrapping
|
||||
@ -343,9 +372,9 @@ ptrdiff_t ZSTD_wrappedPtrDiff(unsigned char const* lhs, unsigned char const* rhs
|
||||
*/
|
||||
MEM_STATIC
|
||||
ZSTD_ALLOW_POINTER_OVERFLOW_ATTR
|
||||
unsigned char const* ZSTD_wrappedPtrAdd(unsigned char const* ptr, ptrdiff_t add)
|
||||
const void* ZSTD_wrappedPtrAdd(const void* ptr, ptrdiff_t add)
|
||||
{
|
||||
return ptr + add;
|
||||
return (const char*)ptr + add;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -356,9 +385,9 @@ unsigned char const* ZSTD_wrappedPtrAdd(unsigned char const* ptr, ptrdiff_t add)
|
||||
*/
|
||||
MEM_STATIC
|
||||
ZSTD_ALLOW_POINTER_OVERFLOW_ATTR
|
||||
unsigned char const* ZSTD_wrappedPtrSub(unsigned char const* ptr, ptrdiff_t sub)
|
||||
const void* ZSTD_wrappedPtrSub(const void* ptr, ptrdiff_t sub)
|
||||
{
|
||||
return ptr - sub;
|
||||
return (const char*)ptr - sub;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -368,9 +397,9 @@ unsigned char const* ZSTD_wrappedPtrSub(unsigned char const* ptr, ptrdiff_t sub)
|
||||
* @returns `ptr + add` except it defines `NULL + 0 == NULL`.
|
||||
*/
|
||||
MEM_STATIC
|
||||
unsigned char* ZSTD_maybeNullPtrAdd(unsigned char* ptr, ptrdiff_t add)
|
||||
void* ZSTD_maybeNullPtrAdd(void* ptr, ptrdiff_t add)
|
||||
{
|
||||
return add > 0 ? ptr + add : ptr;
|
||||
return add > 0 ? (char*)ptr + add : ptr;
|
||||
}
|
||||
|
||||
/* Issue #3240 reports an ASAN failure on an llvm-mingw build. Out of an
|
||||
|
@ -35,7 +35,7 @@ MEM_STATIC ZSTD_cpuid_t ZSTD_cpuid(void) {
|
||||
U32 f7b = 0;
|
||||
U32 f7c = 0;
|
||||
#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86))
|
||||
#if !defined(__clang__)
|
||||
#if !defined(_M_X64) || !defined(__clang__) || __clang_major__ >= 16
|
||||
int reg[4];
|
||||
__cpuid((int*)reg, 0);
|
||||
{
|
||||
|
@ -32,10 +32,6 @@
|
||||
#ifndef DEBUG_H_12987983217
|
||||
#define DEBUG_H_12987983217
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* static assert is triggered at compile time, leaving no runtime artefact.
|
||||
* static assert only works with compile-time constants.
|
||||
@ -108,9 +104,4 @@ extern int g_debuglevel; /* the variable is only declared,
|
||||
# define DEBUGLOG(l, ...) do { } while (0) /* disabled */
|
||||
#endif
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DEBUG_H_12987983217 */
|
||||
|
@ -40,6 +40,7 @@ const char* ERR_getErrorString(ERR_enum code)
|
||||
case PREFIX(tableLog_tooLarge): return "tableLog requires too much memory : unsupported";
|
||||
case PREFIX(maxSymbolValue_tooLarge): return "Unsupported max Symbol Value : too large";
|
||||
case PREFIX(maxSymbolValue_tooSmall): return "Specified maxSymbolValue is too small";
|
||||
case PREFIX(cannotProduce_uncompressedBlock): return "This mode cannot generate an uncompressed block";
|
||||
case PREFIX(stabilityCondition_notRespected): return "pledged buffer stability condition is not respected";
|
||||
case PREFIX(dictionary_corrupted): return "Dictionary is corrupted";
|
||||
case PREFIX(dictionary_wrong): return "Dictionary mismatch";
|
||||
|
@ -13,11 +13,6 @@
|
||||
#ifndef ERROR_H_MODULE
|
||||
#define ERROR_H_MODULE
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* ****************************************
|
||||
* Dependencies
|
||||
******************************************/
|
||||
@ -26,7 +21,6 @@ extern "C" {
|
||||
#include "debug.h"
|
||||
#include "zstd_deps.h" /* size_t */
|
||||
|
||||
|
||||
/* ****************************************
|
||||
* Compiler-specific
|
||||
******************************************/
|
||||
@ -161,8 +155,4 @@ void _force_has_format_string(const char *format, ...) {
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ERROR_H_MODULE */
|
||||
|
@ -11,11 +11,6 @@
|
||||
* in the COPYING file in the root directory of this source tree).
|
||||
* You may select, at your option, one of the above-listed licenses.
|
||||
****************************************************************** */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef FSE_H
|
||||
#define FSE_H
|
||||
|
||||
@ -25,7 +20,6 @@ extern "C" {
|
||||
******************************************/
|
||||
#include "zstd_deps.h" /* size_t, ptrdiff_t */
|
||||
|
||||
|
||||
/*-*****************************************
|
||||
* FSE_PUBLIC_API : control library symbols visibility
|
||||
******************************************/
|
||||
@ -232,11 +226,8 @@ If there is an error, the function will return an error code, which can be teste
|
||||
|
||||
#if defined(FSE_STATIC_LINKING_ONLY) && !defined(FSE_H_FSE_STATIC_LINKING_ONLY)
|
||||
#define FSE_H_FSE_STATIC_LINKING_ONLY
|
||||
|
||||
/* *** Dependency *** */
|
||||
#include "bitstream.h"
|
||||
|
||||
|
||||
/* *****************************************
|
||||
* Static allocation
|
||||
*******************************************/
|
||||
@ -465,13 +456,13 @@ MEM_STATIC void FSE_encodeSymbol(BIT_CStream_t* bitC, FSE_CState_t* statePtr, un
|
||||
FSE_symbolCompressionTransform const symbolTT = ((const FSE_symbolCompressionTransform*)(statePtr->symbolTT))[symbol];
|
||||
const U16* const stateTable = (const U16*)(statePtr->stateTable);
|
||||
U32 const nbBitsOut = (U32)((statePtr->value + symbolTT.deltaNbBits) >> 16);
|
||||
BIT_addBits(bitC, (size_t)statePtr->value, nbBitsOut);
|
||||
BIT_addBits(bitC, (BitContainerType)statePtr->value, nbBitsOut);
|
||||
statePtr->value = stateTable[ (statePtr->value >> nbBitsOut) + symbolTT.deltaFindState];
|
||||
}
|
||||
|
||||
MEM_STATIC void FSE_flushCState(BIT_CStream_t* bitC, const FSE_CState_t* statePtr)
|
||||
{
|
||||
BIT_addBits(bitC, (size_t)statePtr->value, statePtr->stateLog);
|
||||
BIT_addBits(bitC, (BitContainerType)statePtr->value, statePtr->stateLog);
|
||||
BIT_flushBits(bitC);
|
||||
}
|
||||
|
||||
@ -631,10 +622,4 @@ MEM_STATIC unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr)
|
||||
|
||||
#define FSE_TABLESTEP(tableSize) (((tableSize)>>1) + ((tableSize)>>3) + 3)
|
||||
|
||||
|
||||
#endif /* FSE_STATIC_LINKING_ONLY */
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -190,6 +190,8 @@ FORCE_INLINE_TEMPLATE size_t FSE_decompress_usingDTable_generic(
|
||||
FSE_initDState(&state1, &bitD, dt);
|
||||
FSE_initDState(&state2, &bitD, dt);
|
||||
|
||||
RETURN_ERROR_IF(BIT_reloadDStream(&bitD)==BIT_DStream_overflow, corruption_detected, "");
|
||||
|
||||
#define FSE_GETSYMBOL(statePtr) fast ? FSE_decodeSymbolFast(statePtr, &bitD) : FSE_decodeSymbol(statePtr, &bitD)
|
||||
|
||||
/* 4 symbols per loop */
|
||||
|
@ -12,10 +12,6 @@
|
||||
* You may select, at your option, one of the above-listed licenses.
|
||||
****************************************************************** */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef HUF_H_298734234
|
||||
#define HUF_H_298734234
|
||||
|
||||
@ -25,7 +21,6 @@ extern "C" {
|
||||
#define FSE_STATIC_LINKING_ONLY
|
||||
#include "fse.h"
|
||||
|
||||
|
||||
/* *** Tool functions *** */
|
||||
#define HUF_BLOCKSIZE_MAX (128 * 1024) /**< maximum input size for a single block compressed with HUF_compress */
|
||||
size_t HUF_compressBound(size_t size); /**< maximum compressed size (worst case) */
|
||||
@ -280,7 +275,3 @@ size_t HUF_readDTableX2_wksp(HUF_DTable* DTable, const void* src, size_t srcSize
|
||||
#endif
|
||||
|
||||
#endif /* HUF_H_298734234 */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -11,10 +11,6 @@
|
||||
#ifndef MEM_H_MODULE
|
||||
#define MEM_H_MODULE
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-****************************************
|
||||
* Dependencies
|
||||
******************************************/
|
||||
@ -30,6 +26,8 @@ extern "C" {
|
||||
#if defined(_MSC_VER) /* Visual Studio */
|
||||
# include <stdlib.h> /* _byteswap_ulong */
|
||||
# include <intrin.h> /* _byteswap_* */
|
||||
#elif defined(__ICCARM__)
|
||||
# include <intrinsics.h>
|
||||
#endif
|
||||
|
||||
/*-**************************************************************
|
||||
@ -74,7 +72,6 @@ extern "C" {
|
||||
typedef signed long long S64;
|
||||
#endif
|
||||
|
||||
|
||||
/*-**************************************************************
|
||||
* Memory I/O API
|
||||
*****************************************************************/
|
||||
@ -150,10 +147,12 @@ MEM_STATIC unsigned MEM_isLittleEndian(void)
|
||||
return 1;
|
||||
#elif defined(__clang__) && __BIG_ENDIAN__
|
||||
return 0;
|
||||
#elif defined(_MSC_VER) && (_M_AMD64 || _M_IX86)
|
||||
#elif defined(_MSC_VER) && (_M_X64 || _M_IX86)
|
||||
return 1;
|
||||
#elif defined(__DMC__) && defined(_M_IX86)
|
||||
return 1;
|
||||
#elif defined(__IAR_SYSTEMS_ICC__) && __LITTLE_ENDIAN__
|
||||
return 1;
|
||||
#else
|
||||
const union { U32 u; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */
|
||||
return one.c[0];
|
||||
@ -246,6 +245,8 @@ MEM_STATIC U32 MEM_swap32(U32 in)
|
||||
#elif (defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)) \
|
||||
|| (defined(__clang__) && __has_builtin(__builtin_bswap32))
|
||||
return __builtin_bswap32(in);
|
||||
#elif defined(__ICCARM__)
|
||||
return __REV(in);
|
||||
#else
|
||||
return MEM_swap32_fallback(in);
|
||||
#endif
|
||||
@ -418,9 +419,4 @@ MEM_STATIC void MEM_writeBEST(void* memPtr, size_t val)
|
||||
/* code only tested on 32 and 64 bits systems */
|
||||
MEM_STATIC void MEM_check(void) { DEBUG_STATIC_ASSERT((sizeof(size_t)==4) || (sizeof(size_t)==8)); }
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MEM_H_MODULE */
|
||||
|
@ -11,10 +11,6 @@
|
||||
#ifndef POOL_H
|
||||
#define POOL_H
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include "zstd_deps.h"
|
||||
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_customMem */
|
||||
@ -82,9 +78,4 @@ void POOL_add(POOL_ctx* ctx, POOL_function function, void* opaque);
|
||||
*/
|
||||
int POOL_tryAdd(POOL_ctx* ctx, POOL_function function, void* opaque);
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -74,26 +74,39 @@
|
||||
# define ZSTD_HIDE_ASM_FUNCTION(func)
|
||||
#endif
|
||||
|
||||
/* Compile time determination of BMI2 support */
|
||||
#ifndef STATIC_BMI2
|
||||
# if defined(__BMI2__)
|
||||
# define STATIC_BMI2 1
|
||||
# elif defined(_MSC_VER) && defined(__AVX2__)
|
||||
# define STATIC_BMI2 1 /* MSVC does not have a BMI2 specific flag, but every CPU that supports AVX2 also supports BMI2 */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef STATIC_BMI2
|
||||
# define STATIC_BMI2 0
|
||||
#endif
|
||||
|
||||
/* Enable runtime BMI2 dispatch based on the CPU.
|
||||
* Enabled for clang & gcc >=4.8 on x86 when BMI2 isn't enabled by default.
|
||||
*/
|
||||
#ifndef DYNAMIC_BMI2
|
||||
#if ((defined(__clang__) && __has_attribute(__target__)) \
|
||||
# if ((defined(__clang__) && __has_attribute(__target__)) \
|
||||
|| (defined(__GNUC__) \
|
||||
&& (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))) \
|
||||
&& (defined(__x86_64__) || defined(_M_X64)) \
|
||||
&& (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)) \
|
||||
&& !defined(__BMI2__)
|
||||
# define DYNAMIC_BMI2 1
|
||||
#else
|
||||
# define DYNAMIC_BMI2 0
|
||||
#endif
|
||||
# define DYNAMIC_BMI2 1
|
||||
# else
|
||||
# define DYNAMIC_BMI2 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Only enable assembly for GNUC compatible compilers,
|
||||
* Only enable assembly for GNU C compatible compilers,
|
||||
* because other platforms may not support GAS assembly syntax.
|
||||
*
|
||||
* Only enable assembly for Linux / MacOS, other platforms may
|
||||
* Only enable assembly for Linux / MacOS / Win32, other platforms may
|
||||
* work, but they haven't been tested. This could likely be
|
||||
* extended to BSD systems.
|
||||
*
|
||||
@ -101,7 +114,7 @@
|
||||
* 100% of code to be instrumented to work.
|
||||
*/
|
||||
#if defined(__GNUC__)
|
||||
# if defined(__linux__) || defined(__linux) || defined(__APPLE__)
|
||||
# if defined(__linux__) || defined(__linux) || defined(__APPLE__) || defined(_WIN32)
|
||||
# if ZSTD_MEMORY_SANITIZER
|
||||
# define ZSTD_ASM_SUPPORTED 0
|
||||
# elif ZSTD_DATAFLOW_SANITIZER
|
||||
@ -155,4 +168,23 @@
|
||||
# define ZSTD_CET_ENDBRANCH
|
||||
#endif
|
||||
|
||||
/**
|
||||
* ZSTD_IS_DETERMINISTIC_BUILD must be set to 0 if any compilation macro is
|
||||
* active that impacts the compressed output.
|
||||
*
|
||||
* NOTE: ZSTD_MULTITHREAD is allowed to be set or unset.
|
||||
*/
|
||||
#if defined(ZSTD_CLEVEL_DEFAULT) \
|
||||
|| defined(ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR) \
|
||||
|| defined(ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR) \
|
||||
|| defined(ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR) \
|
||||
|| defined(ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR) \
|
||||
|| defined(ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR) \
|
||||
|| defined(ZSTD_EXCLUDE_BTOPT_BLOCK_COMPRESSOR) \
|
||||
|| defined(ZSTD_EXCLUDE_BTULTRA_BLOCK_COMPRESSOR)
|
||||
# define ZSTD_IS_DETERMINISTIC_BUILD 0
|
||||
#else
|
||||
# define ZSTD_IS_DETERMINISTIC_BUILD 1
|
||||
#endif
|
||||
|
||||
#endif /* ZSTD_PORTABILITY_MACROS_H */
|
||||
|
@ -16,10 +16,6 @@
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(ZSTD_MULTITHREAD) && defined(_WIN32)
|
||||
|
||||
/**
|
||||
@ -72,7 +68,6 @@ int ZSTD_pthread_join(ZSTD_pthread_t thread);
|
||||
* add here more wrappers as required
|
||||
*/
|
||||
|
||||
|
||||
#elif defined(ZSTD_MULTITHREAD) /* posix assumed ; need a better detection method */
|
||||
/* === POSIX Systems === */
|
||||
# include <pthread.h>
|
||||
@ -143,8 +138,5 @@ typedef int ZSTD_pthread_cond_t;
|
||||
|
||||
#endif /* ZSTD_MULTITHREAD */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* THREADING_H_938743 */
|
||||
|
@ -227,10 +227,6 @@
|
||||
* xxHash prototypes and implementation
|
||||
*/
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ****************************
|
||||
* INLINE mode
|
||||
******************************/
|
||||
@ -537,6 +533,9 @@ extern "C" {
|
||||
/*! @brief Version number, encoded as two digits each */
|
||||
#define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE)
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
/*!
|
||||
* @brief Obtains the xxHash version.
|
||||
*
|
||||
@ -547,6 +546,9 @@ extern "C" {
|
||||
*/
|
||||
XXH_PUBLIC_API XXH_CONSTF unsigned XXH_versionNumber (void);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ****************************
|
||||
* Common basic types
|
||||
@ -593,6 +595,10 @@ typedef uint32_t XXH32_hash_t;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*
|
||||
@ -821,6 +827,9 @@ XXH_PUBLIC_API XXH_PUREF XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canoni
|
||||
#endif
|
||||
/*! @endcond */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @}
|
||||
@ -859,6 +868,9 @@ typedef uint64_t XXH64_hash_t;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
/*!
|
||||
* @}
|
||||
*
|
||||
@ -1562,6 +1574,11 @@ XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH128_hashFromCanonical(XXH_NOESCAPE con
|
||||
|
||||
|
||||
#endif /* !XXH_NO_XXH3 */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* XXH_NO_LONG_LONG */
|
||||
|
||||
/*!
|
||||
@ -1748,6 +1765,10 @@ struct XXH3_state_s {
|
||||
} while(0)
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief Calculates the 128-bit hash of @p data using XXH3.
|
||||
*
|
||||
@ -1963,8 +1984,13 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr,
|
||||
XXH64_hash_t seed64);
|
||||
#endif /* !XXH_NO_STREAM */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* !XXH_NO_XXH3 */
|
||||
#endif /* XXH_NO_LONG_LONG */
|
||||
|
||||
#if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API)
|
||||
# define XXH_IMPLEMENTATION
|
||||
#endif
|
||||
@ -2263,10 +2289,12 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr,
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/* *************************************
|
||||
* Includes & Memory related functions
|
||||
***************************************/
|
||||
#include <string.h> /* memcmp, memcpy */
|
||||
#include <limits.h> /* ULLONG_MAX */
|
||||
|
||||
#if defined(XXH_NO_STREAM)
|
||||
/* nothing */
|
||||
#elif defined(XXH_NO_STDLIB)
|
||||
@ -2280,9 +2308,17 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr,
|
||||
* without access to dynamic allocation.
|
||||
*/
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static XXH_CONSTF void* XXH_malloc(size_t s) { (void)s; return NULL; }
|
||||
static void XXH_free(void* p) { (void)p; }
|
||||
|
||||
#if defined (__cplusplus)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
@ -2291,6 +2327,9 @@ static void XXH_free(void* p) { (void)p; }
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
/*!
|
||||
* @internal
|
||||
* @brief Modify this function to use a different routine than malloc().
|
||||
@ -2303,10 +2342,15 @@ static XXH_MALLOCF void* XXH_malloc(size_t s) { return malloc(s); }
|
||||
*/
|
||||
static void XXH_free(void* p) { free(p); }
|
||||
|
||||
#if defined (__cplusplus)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* XXH_NO_STDLIB */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
/*!
|
||||
* @internal
|
||||
* @brief Modify this function to use a different routine than memcpy().
|
||||
@ -2316,8 +2360,9 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size)
|
||||
return memcpy(dest,src,size);
|
||||
}
|
||||
|
||||
#include <limits.h> /* ULLONG_MAX */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
/* *************************************
|
||||
* Compiler Specific Options
|
||||
@ -2452,6 +2497,10 @@ typedef XXH32_hash_t xxh_u32;
|
||||
# define U32 xxh_u32
|
||||
#endif
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* *** Memory access *** */
|
||||
|
||||
/*!
|
||||
@ -3608,6 +3657,10 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(XXH_NOESCAPE const XXH64_can
|
||||
return XXH_readBE64(src);
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef XXH_NO_XXH3
|
||||
|
||||
/* *********************************************************************
|
||||
@ -3839,7 +3892,7 @@ enum XXH_VECTOR_TYPE /* fake enum */ {
|
||||
# define XXH_VECTOR XXH_AVX512
|
||||
# elif defined(__AVX2__)
|
||||
# define XXH_VECTOR XXH_AVX2
|
||||
# elif defined(__SSE2__) || defined(_M_AMD64) || defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP == 2))
|
||||
# elif defined(__SSE2__) || defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP == 2))
|
||||
# define XXH_VECTOR XXH_SSE2
|
||||
# elif (defined(__PPC64__) && defined(__POWER8_VECTOR__)) \
|
||||
|| (defined(__s390x__) && defined(__VEC__)) \
|
||||
@ -3928,6 +3981,10 @@ enum XXH_VECTOR_TYPE /* fake enum */ {
|
||||
# pragma GCC optimize("-O2")
|
||||
#endif
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if XXH_VECTOR == XXH_NEON
|
||||
|
||||
/*
|
||||
@ -4050,6 +4107,10 @@ XXH_vmlal_high_u32(uint64x2_t acc, uint32x4_t lhs, uint32x4_t rhs)
|
||||
# endif
|
||||
#endif /* XXH_VECTOR == XXH_NEON */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* VSX and Z Vector helpers.
|
||||
*
|
||||
@ -4111,6 +4172,9 @@ typedef xxh_u64x2 xxh_aliasing_u64x2 XXH_ALIASING;
|
||||
# if defined(__POWER9_VECTOR__) || (defined(__clang__) && defined(__s390x__))
|
||||
# define XXH_vec_revb vec_revb
|
||||
# else
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
/*!
|
||||
* A polyfill for POWER9's vec_revb().
|
||||
*/
|
||||
@ -4120,9 +4184,15 @@ XXH_FORCE_INLINE xxh_u64x2 XXH_vec_revb(xxh_u64x2 val)
|
||||
0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08 };
|
||||
return vec_perm(val, val, vByteSwap);
|
||||
}
|
||||
#if defined (__cplusplus)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
# endif
|
||||
# endif /* XXH_VSX_BE */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
/*!
|
||||
* Performs an unaligned vector load and byte swaps it on big endian.
|
||||
*/
|
||||
@ -4167,6 +4237,11 @@ XXH_FORCE_INLINE xxh_u64x2 XXH_vec_mule(xxh_u32x4 a, xxh_u32x4 b)
|
||||
return result;
|
||||
}
|
||||
# endif /* XXH_vec_mulo, XXH_vec_mule */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* XXH_VECTOR == XXH_VSX */
|
||||
|
||||
#if XXH_VECTOR == XXH_SVE
|
||||
@ -4200,7 +4275,9 @@ do { \
|
||||
# endif
|
||||
#endif /* XXH_NO_PREFETCH */
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
/* ==========================================
|
||||
* XXH3 default settings
|
||||
* ========================================== */
|
||||
@ -6877,8 +6954,6 @@ XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (XXH_NOESCAPE const XXH3_state_
|
||||
#endif /* !XXH_NO_STREAM */
|
||||
/* 128-bit utility functions */
|
||||
|
||||
#include <string.h> /* memcmp, memcpy */
|
||||
|
||||
/* return : 1 is equal, 0 if different */
|
||||
/*! @ingroup XXH3_family */
|
||||
XXH_PUBLIC_API int XXH128_isEqual(XXH128_hash_t h1, XXH128_hash_t h2)
|
||||
@ -7005,16 +7080,15 @@ XXH3_generateSecret_fromSeed(XXH_NOESCAPE void* secretBuffer, XXH64_hash_t seed)
|
||||
# pragma GCC pop_options
|
||||
#endif
|
||||
|
||||
#endif /* XXH_NO_LONG_LONG */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* XXH_NO_LONG_LONG */
|
||||
#endif /* XXH_NO_XXH3 */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
#endif /* XXH_IMPLEMENTATION */
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -46,3 +46,12 @@ ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
|
||||
/*! ZSTD_getErrorString() :
|
||||
* provides error code string from enum */
|
||||
const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
|
||||
|
||||
int ZSTD_isDeterministicBuild(void)
|
||||
{
|
||||
#if ZSTD_IS_DETERMINISTIC_BUILD
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
@ -24,6 +24,18 @@
|
||||
#ifndef ZSTD_DEPS_COMMON
|
||||
#define ZSTD_DEPS_COMMON
|
||||
|
||||
/* Even though we use qsort_r only for the dictionary builder, the macro
|
||||
* _GNU_SOURCE has to be declared *before* the inclusion of any standard
|
||||
* header and the script 'combine.sh' combines the whole zstd source code
|
||||
* in a single file.
|
||||
*/
|
||||
#if defined(__linux) || defined(__linux__) || defined(linux) || defined(__gnu_linux__) || \
|
||||
defined(__CYGWIN__) || defined(__MSYS__)
|
||||
#if !defined(_GNU_SOURCE) && !defined(__ANDROID__) /* NDK doesn't ship qsort_r(). */
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
@ -39,10 +39,6 @@
|
||||
# define ZSTD_TRACE 0
|
||||
#endif
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ---- static assert (debug) --- */
|
||||
#define ZSTD_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c)
|
||||
#define ZSTD_isError ERR_isError /* for inlining */
|
||||
@ -95,7 +91,7 @@ typedef enum { bt_raw, bt_rle, bt_compressed, bt_reserved } blockType_e;
|
||||
#define MIN_CBLOCK_SIZE (1 /*litCSize*/ + 1 /* RLE or RAW */) /* for a non-null block */
|
||||
#define MIN_LITERALS_FOR_4_STREAMS 6
|
||||
|
||||
typedef enum { set_basic, set_rle, set_compressed, set_repeat } symbolEncodingType_e;
|
||||
typedef enum { set_basic, set_rle, set_compressed, set_repeat } SymbolEncodingType_e;
|
||||
|
||||
#define LONGNBSEQ 0x7F00
|
||||
|
||||
@ -217,7 +213,7 @@ typedef enum {
|
||||
* The src buffer must be before the dst buffer.
|
||||
*/
|
||||
MEM_STATIC FORCE_INLINE_ATTR
|
||||
void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length, ZSTD_overlap_e const ovtype)
|
||||
void ZSTD_wildcopy(void* dst, const void* src, size_t length, ZSTD_overlap_e const ovtype)
|
||||
{
|
||||
ptrdiff_t diff = (BYTE*)dst - (const BYTE*)src;
|
||||
const BYTE* ip = (const BYTE*)src;
|
||||
@ -278,62 +274,6 @@ typedef enum {
|
||||
/*-*******************************************
|
||||
* Private declarations
|
||||
*********************************************/
|
||||
typedef struct seqDef_s {
|
||||
U32 offBase; /* offBase == Offset + ZSTD_REP_NUM, or repcode 1,2,3 */
|
||||
U16 litLength;
|
||||
U16 mlBase; /* mlBase == matchLength - MINMATCH */
|
||||
} seqDef;
|
||||
|
||||
/* Controls whether seqStore has a single "long" litLength or matchLength. See seqStore_t. */
|
||||
typedef enum {
|
||||
ZSTD_llt_none = 0, /* no longLengthType */
|
||||
ZSTD_llt_literalLength = 1, /* represents a long literal */
|
||||
ZSTD_llt_matchLength = 2 /* represents a long match */
|
||||
} ZSTD_longLengthType_e;
|
||||
|
||||
typedef struct {
|
||||
seqDef* sequencesStart;
|
||||
seqDef* sequences; /* ptr to end of sequences */
|
||||
BYTE* litStart;
|
||||
BYTE* lit; /* ptr to end of literals */
|
||||
BYTE* llCode;
|
||||
BYTE* mlCode;
|
||||
BYTE* ofCode;
|
||||
size_t maxNbSeq;
|
||||
size_t maxNbLit;
|
||||
|
||||
/* longLengthPos and longLengthType to allow us to represent either a single litLength or matchLength
|
||||
* in the seqStore that has a value larger than U16 (if it exists). To do so, we increment
|
||||
* the existing value of the litLength or matchLength by 0x10000.
|
||||
*/
|
||||
ZSTD_longLengthType_e longLengthType;
|
||||
U32 longLengthPos; /* Index of the sequence to apply long length modification to */
|
||||
} seqStore_t;
|
||||
|
||||
typedef struct {
|
||||
U32 litLength;
|
||||
U32 matchLength;
|
||||
} ZSTD_sequenceLength;
|
||||
|
||||
/**
|
||||
* Returns the ZSTD_sequenceLength for the given sequences. It handles the decoding of long sequences
|
||||
* indicated by longLengthPos and longLengthType, and adds MINMATCH back to matchLength.
|
||||
*/
|
||||
MEM_STATIC ZSTD_sequenceLength ZSTD_getSequenceLength(seqStore_t const* seqStore, seqDef const* seq)
|
||||
{
|
||||
ZSTD_sequenceLength seqLen;
|
||||
seqLen.litLength = seq->litLength;
|
||||
seqLen.matchLength = seq->mlBase + MINMATCH;
|
||||
if (seqStore->longLengthPos == (U32)(seq - seqStore->sequencesStart)) {
|
||||
if (seqStore->longLengthType == ZSTD_llt_literalLength) {
|
||||
seqLen.litLength += 0x10000;
|
||||
}
|
||||
if (seqStore->longLengthType == ZSTD_llt_matchLength) {
|
||||
seqLen.matchLength += 0x10000;
|
||||
}
|
||||
}
|
||||
return seqLen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains the compressed frame size and an upper-bound for the decompressed frame size.
|
||||
@ -347,10 +287,6 @@ typedef struct {
|
||||
unsigned long long decompressedBound;
|
||||
} ZSTD_frameSizeInfo; /* decompress & legacy */
|
||||
|
||||
const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); /* compress & dictBuilder */
|
||||
int ZSTD_seqToCodes(const seqStore_t* seqStorePtr); /* compress, dictBuilder, decodeCorpus (shouldn't get its definition from here) */
|
||||
|
||||
|
||||
/* ZSTD_invalidateRepCodes() :
|
||||
* ensures next compression will not use repcodes from previous block.
|
||||
* Note : only works with regular variant;
|
||||
@ -385,8 +321,4 @@ MEM_STATIC int ZSTD_cpuSupportsBmi2(void)
|
||||
return ZSTD_cpuid_bmi1(cpuid) && ZSTD_cpuid_bmi2(cpuid);
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZSTD_CCOMMON_H_MODULE */
|
||||
|
@ -11,23 +11,20 @@
|
||||
#ifndef ZSTD_TRACE_H
|
||||
#define ZSTD_TRACE_H
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* weak symbol support
|
||||
* For now, enable conservatively:
|
||||
* - Only GNUC
|
||||
* - Only ELF
|
||||
* - Only x86-64, i386 and aarch64
|
||||
* - Only x86-64, i386, aarch64 and risc-v.
|
||||
* Also, explicitly disable on platforms known not to work so they aren't
|
||||
* forgotten in the future.
|
||||
*/
|
||||
#if !defined(ZSTD_HAVE_WEAK_SYMBOLS) && \
|
||||
defined(__GNUC__) && defined(__ELF__) && \
|
||||
(defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) || defined(__aarch64__)) && \
|
||||
(defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \
|
||||
defined(_M_IX86) || defined(__aarch64__) || defined(__riscv)) && \
|
||||
!defined(__APPLE__) && !defined(_WIN32) && !defined(__MINGW32__) && \
|
||||
!defined(__CYGWIN__) && !defined(_AIX)
|
||||
# define ZSTD_HAVE_WEAK_SYMBOLS 1
|
||||
@ -64,7 +61,7 @@ typedef struct {
|
||||
/**
|
||||
* Non-zero if streaming (de)compression is used.
|
||||
*/
|
||||
unsigned streaming;
|
||||
int streaming;
|
||||
/**
|
||||
* The dictionary ID.
|
||||
*/
|
||||
@ -73,7 +70,7 @@ typedef struct {
|
||||
* Is the dictionary cold?
|
||||
* Only set on decompression.
|
||||
*/
|
||||
unsigned dictionaryIsCold;
|
||||
int dictionaryIsCold;
|
||||
/**
|
||||
* The dictionary size or zero if no dictionary.
|
||||
*/
|
||||
@ -156,8 +153,4 @@ ZSTD_WEAK_ATTR void ZSTD_trace_decompress_end(
|
||||
|
||||
#endif /* ZSTD_TRACE */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZSTD_TRACE_H */
|
||||
|
@ -19,6 +19,12 @@
|
||||
#include "../common/error_private.h" /* ERROR */
|
||||
#include "hist.h"
|
||||
|
||||
#if defined(ZSTD_ARCH_ARM_SVE2)
|
||||
#define HIST_FAST_THRESHOLD 500
|
||||
#else
|
||||
#define HIST_FAST_THRESHOLD 1500
|
||||
#endif
|
||||
|
||||
|
||||
/* --- Error management --- */
|
||||
unsigned HIST_isError(size_t code) { return ERR_isError(code); }
|
||||
@ -26,6 +32,16 @@ unsigned HIST_isError(size_t code) { return ERR_isError(code); }
|
||||
/*-**************************************************************
|
||||
* Histogram functions
|
||||
****************************************************************/
|
||||
void HIST_add(unsigned* count, const void* src, size_t srcSize)
|
||||
{
|
||||
const BYTE* ip = (const BYTE*)src;
|
||||
const BYTE* const end = ip + srcSize;
|
||||
|
||||
while (ip<end) {
|
||||
count[*ip++]++;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned HIST_count_simple(unsigned* count, unsigned* maxSymbolValuePtr,
|
||||
const void* src, size_t srcSize)
|
||||
{
|
||||
@ -55,6 +71,244 @@ unsigned HIST_count_simple(unsigned* count, unsigned* maxSymbolValuePtr,
|
||||
|
||||
typedef enum { trustInput, checkMaxSymbolValue } HIST_checkInput_e;
|
||||
|
||||
#if defined(ZSTD_ARCH_ARM_SVE2)
|
||||
FORCE_INLINE_TEMPLATE size_t min_size(size_t a, size_t b) { return a < b ? a : b; }
|
||||
|
||||
static
|
||||
svuint16_t HIST_count_6_sve2(const BYTE* const src, size_t size, U32* const dst,
|
||||
const svuint8_t c0, const svuint8_t c1,
|
||||
const svuint8_t c2, const svuint8_t c3,
|
||||
const svuint8_t c4, const svuint8_t c5,
|
||||
const svuint16_t histmax, size_t maxCount)
|
||||
{
|
||||
const svbool_t vl128 = svptrue_pat_b8(SV_VL16);
|
||||
svuint16_t hh0 = svdup_n_u16(0);
|
||||
svuint16_t hh1 = svdup_n_u16(0);
|
||||
svuint16_t hh2 = svdup_n_u16(0);
|
||||
svuint16_t hh3 = svdup_n_u16(0);
|
||||
svuint16_t hh4 = svdup_n_u16(0);
|
||||
svuint16_t hh5 = svdup_n_u16(0);
|
||||
svuint16_t hh6 = svdup_n_u16(0);
|
||||
svuint16_t hh7 = svdup_n_u16(0);
|
||||
svuint16_t hh8 = svdup_n_u16(0);
|
||||
svuint16_t hh9 = svdup_n_u16(0);
|
||||
svuint16_t hha = svdup_n_u16(0);
|
||||
svuint16_t hhb = svdup_n_u16(0);
|
||||
|
||||
size_t i = 0;
|
||||
while (i < size) {
|
||||
/* We can only accumulate 15 (15 * 16 <= 255) iterations of histogram
|
||||
* in 8-bit accumulators! */
|
||||
const size_t size240 = min_size(i + 240, size);
|
||||
|
||||
svbool_t pred = svwhilelt_b8_u64(i, size);
|
||||
svuint8_t c = svld1rq_u8(pred, src + i);
|
||||
svuint8_t h0 = svhistseg_u8(c0, c);
|
||||
svuint8_t h1 = svhistseg_u8(c1, c);
|
||||
svuint8_t h2 = svhistseg_u8(c2, c);
|
||||
svuint8_t h3 = svhistseg_u8(c3, c);
|
||||
svuint8_t h4 = svhistseg_u8(c4, c);
|
||||
svuint8_t h5 = svhistseg_u8(c5, c);
|
||||
|
||||
for (i += 16; i < size240; i += 16) {
|
||||
pred = svwhilelt_b8_u64(i, size);
|
||||
c = svld1rq_u8(pred, src + i);
|
||||
h0 = svadd_u8_x(vl128, h0, svhistseg_u8(c0, c));
|
||||
h1 = svadd_u8_x(vl128, h1, svhistseg_u8(c1, c));
|
||||
h2 = svadd_u8_x(vl128, h2, svhistseg_u8(c2, c));
|
||||
h3 = svadd_u8_x(vl128, h3, svhistseg_u8(c3, c));
|
||||
h4 = svadd_u8_x(vl128, h4, svhistseg_u8(c4, c));
|
||||
h5 = svadd_u8_x(vl128, h5, svhistseg_u8(c5, c));
|
||||
}
|
||||
|
||||
hh0 = svaddwb_u16(hh0, h0);
|
||||
hh1 = svaddwt_u16(hh1, h0);
|
||||
hh2 = svaddwb_u16(hh2, h1);
|
||||
hh3 = svaddwt_u16(hh3, h1);
|
||||
hh4 = svaddwb_u16(hh4, h2);
|
||||
hh5 = svaddwt_u16(hh5, h2);
|
||||
hh6 = svaddwb_u16(hh6, h3);
|
||||
hh7 = svaddwt_u16(hh7, h3);
|
||||
hh8 = svaddwb_u16(hh8, h4);
|
||||
hh9 = svaddwt_u16(hh9, h4);
|
||||
hha = svaddwb_u16(hha, h5);
|
||||
hhb = svaddwt_u16(hhb, h5);
|
||||
}
|
||||
|
||||
svst1_u32(svwhilelt_b32_u64( 0, maxCount), dst + 0, svshllb_n_u32(hh0, 0));
|
||||
svst1_u32(svwhilelt_b32_u64( 4, maxCount), dst + 4, svshllt_n_u32(hh0, 0));
|
||||
svst1_u32(svwhilelt_b32_u64( 8, maxCount), dst + 8, svshllb_n_u32(hh1, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(12, maxCount), dst + 12, svshllt_n_u32(hh1, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(16, maxCount), dst + 16, svshllb_n_u32(hh2, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(20, maxCount), dst + 20, svshllt_n_u32(hh2, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(24, maxCount), dst + 24, svshllb_n_u32(hh3, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(28, maxCount), dst + 28, svshllt_n_u32(hh3, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(32, maxCount), dst + 32, svshllb_n_u32(hh4, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(36, maxCount), dst + 36, svshllt_n_u32(hh4, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(40, maxCount), dst + 40, svshllb_n_u32(hh5, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(44, maxCount), dst + 44, svshllt_n_u32(hh5, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(48, maxCount), dst + 48, svshllb_n_u32(hh6, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(52, maxCount), dst + 52, svshllt_n_u32(hh6, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(56, maxCount), dst + 56, svshllb_n_u32(hh7, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(60, maxCount), dst + 60, svshllt_n_u32(hh7, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(64, maxCount), dst + 64, svshllb_n_u32(hh8, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(68, maxCount), dst + 68, svshllt_n_u32(hh8, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(72, maxCount), dst + 72, svshllb_n_u32(hh9, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(76, maxCount), dst + 76, svshllt_n_u32(hh9, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(80, maxCount), dst + 80, svshllb_n_u32(hha, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(84, maxCount), dst + 84, svshllt_n_u32(hha, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(88, maxCount), dst + 88, svshllb_n_u32(hhb, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(92, maxCount), dst + 92, svshllt_n_u32(hhb, 0));
|
||||
|
||||
hh0 = svmax_u16_x(vl128, hh0, hh1);
|
||||
hh2 = svmax_u16_x(vl128, hh2, hh3);
|
||||
hh4 = svmax_u16_x(vl128, hh4, hh5);
|
||||
hh6 = svmax_u16_x(vl128, hh6, hh7);
|
||||
hh8 = svmax_u16_x(vl128, hh8, hh9);
|
||||
hha = svmax_u16_x(vl128, hha, hhb);
|
||||
hh0 = svmax_u16_x(vl128, hh0, hh2);
|
||||
hh4 = svmax_u16_x(vl128, hh4, hh6);
|
||||
hh8 = svmax_u16_x(vl128, hh8, hha);
|
||||
hh0 = svmax_u16_x(vl128, hh0, hh4);
|
||||
hh8 = svmax_u16_x(vl128, hh8, histmax);
|
||||
return svmax_u16_x(vl128, hh0, hh8);
|
||||
}
|
||||
|
||||
static size_t HIST_count_sve2(unsigned* count, unsigned* maxSymbolValuePtr,
|
||||
const void* source, size_t sourceSize,
|
||||
HIST_checkInput_e check)
|
||||
{
|
||||
const BYTE* ip = (const BYTE*)source;
|
||||
const size_t maxCount = *maxSymbolValuePtr + 1;
|
||||
|
||||
assert(*maxSymbolValuePtr <= 255);
|
||||
if (!sourceSize) {
|
||||
ZSTD_memset(count, 0, maxCount * sizeof(*count));
|
||||
*maxSymbolValuePtr = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
{ const svbool_t vl128 = svptrue_pat_b8(SV_VL16);
|
||||
const svuint8_t c0 = svreinterpret_u8(svindex_u32(0x0C040800, 0x01010101));
|
||||
const svuint8_t c1 = svadd_n_u8_x(vl128, c0, 16);
|
||||
const svuint8_t c2 = svadd_n_u8_x(vl128, c0, 32);
|
||||
const svuint8_t c3 = svadd_n_u8_x(vl128, c1, 32);
|
||||
|
||||
svuint8_t symbolMax = svdup_n_u8(0);
|
||||
svuint16_t hh0 = svdup_n_u16(0);
|
||||
svuint16_t hh1 = svdup_n_u16(0);
|
||||
svuint16_t hh2 = svdup_n_u16(0);
|
||||
svuint16_t hh3 = svdup_n_u16(0);
|
||||
svuint16_t hh4 = svdup_n_u16(0);
|
||||
svuint16_t hh5 = svdup_n_u16(0);
|
||||
svuint16_t hh6 = svdup_n_u16(0);
|
||||
svuint16_t hh7 = svdup_n_u16(0);
|
||||
svuint16_t max;
|
||||
size_t maxSymbolValue;
|
||||
|
||||
size_t i = 0;
|
||||
while (i < sourceSize) {
|
||||
/* We can only accumulate 15 (15 * 16 <= 255) iterations of
|
||||
* histogram in 8-bit accumulators! */
|
||||
const size_t size240 = min_size(i + 240, sourceSize);
|
||||
|
||||
svbool_t pred = svwhilelt_b8_u64(i, sourceSize);
|
||||
svuint8_t c = svld1rq_u8(pred, ip + i);
|
||||
svuint8_t h0 = svhistseg_u8(c0, c);
|
||||
svuint8_t h1 = svhistseg_u8(c1, c);
|
||||
svuint8_t h2 = svhistseg_u8(c2, c);
|
||||
svuint8_t h3 = svhistseg_u8(c3, c);
|
||||
symbolMax = svmax_u8_x(vl128, symbolMax, c);
|
||||
|
||||
for (i += 16; i < size240; i += 16) {
|
||||
pred = svwhilelt_b8_u64(i, sourceSize);
|
||||
c = svld1rq_u8(pred, ip + i);
|
||||
h0 = svadd_u8_x(vl128, h0, svhistseg_u8(c0, c));
|
||||
h1 = svadd_u8_x(vl128, h1, svhistseg_u8(c1, c));
|
||||
h2 = svadd_u8_x(vl128, h2, svhistseg_u8(c2, c));
|
||||
h3 = svadd_u8_x(vl128, h3, svhistseg_u8(c3, c));
|
||||
symbolMax = svmax_u8_x(vl128, symbolMax, c);
|
||||
}
|
||||
|
||||
hh0 = svaddwb_u16(hh0, h0);
|
||||
hh1 = svaddwt_u16(hh1, h0);
|
||||
hh2 = svaddwb_u16(hh2, h1);
|
||||
hh3 = svaddwt_u16(hh3, h1);
|
||||
hh4 = svaddwb_u16(hh4, h2);
|
||||
hh5 = svaddwt_u16(hh5, h2);
|
||||
hh6 = svaddwb_u16(hh6, h3);
|
||||
hh7 = svaddwt_u16(hh7, h3);
|
||||
}
|
||||
maxSymbolValue = svmaxv_u8(vl128, symbolMax);
|
||||
|
||||
if (check && maxSymbolValue > *maxSymbolValuePtr) return ERROR(maxSymbolValue_tooSmall);
|
||||
*maxSymbolValuePtr = maxSymbolValue;
|
||||
|
||||
/* If the buffer size is not divisible by 16, the last elements of the final
|
||||
* vector register read will be zeros, and these elements must be subtracted
|
||||
* from the histogram.
|
||||
*/
|
||||
hh0 = svsub_n_u16_m(svptrue_pat_b32(SV_VL1), hh0, -sourceSize & 15);
|
||||
|
||||
svst1_u32(svwhilelt_b32_u64( 0, maxCount), count + 0, svshllb_n_u32(hh0, 0));
|
||||
svst1_u32(svwhilelt_b32_u64( 4, maxCount), count + 4, svshllt_n_u32(hh0, 0));
|
||||
svst1_u32(svwhilelt_b32_u64( 8, maxCount), count + 8, svshllb_n_u32(hh1, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(12, maxCount), count + 12, svshllt_n_u32(hh1, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(16, maxCount), count + 16, svshllb_n_u32(hh2, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(20, maxCount), count + 20, svshllt_n_u32(hh2, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(24, maxCount), count + 24, svshllb_n_u32(hh3, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(28, maxCount), count + 28, svshllt_n_u32(hh3, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(32, maxCount), count + 32, svshllb_n_u32(hh4, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(36, maxCount), count + 36, svshllt_n_u32(hh4, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(40, maxCount), count + 40, svshllb_n_u32(hh5, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(44, maxCount), count + 44, svshllt_n_u32(hh5, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(48, maxCount), count + 48, svshllb_n_u32(hh6, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(52, maxCount), count + 52, svshllt_n_u32(hh6, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(56, maxCount), count + 56, svshllb_n_u32(hh7, 0));
|
||||
svst1_u32(svwhilelt_b32_u64(60, maxCount), count + 60, svshllt_n_u32(hh7, 0));
|
||||
|
||||
hh0 = svmax_u16_x(vl128, hh0, hh1);
|
||||
hh2 = svmax_u16_x(vl128, hh2, hh3);
|
||||
hh4 = svmax_u16_x(vl128, hh4, hh5);
|
||||
hh6 = svmax_u16_x(vl128, hh6, hh7);
|
||||
hh0 = svmax_u16_x(vl128, hh0, hh2);
|
||||
hh4 = svmax_u16_x(vl128, hh4, hh6);
|
||||
max = svmax_u16_x(vl128, hh0, hh4);
|
||||
|
||||
maxSymbolValue = min_size(maxSymbolValue, maxCount);
|
||||
if (maxSymbolValue >= 64) {
|
||||
const svuint8_t c4 = svadd_n_u8_x(vl128, c0, 64);
|
||||
const svuint8_t c5 = svadd_n_u8_x(vl128, c1, 64);
|
||||
const svuint8_t c6 = svadd_n_u8_x(vl128, c2, 64);
|
||||
const svuint8_t c7 = svadd_n_u8_x(vl128, c3, 64);
|
||||
const svuint8_t c8 = svadd_n_u8_x(vl128, c0, 128);
|
||||
const svuint8_t c9 = svadd_n_u8_x(vl128, c1, 128);
|
||||
|
||||
max = HIST_count_6_sve2(ip, sourceSize, count + 64, c4, c5, c6, c7,
|
||||
c8, c9, max, maxCount - 64);
|
||||
|
||||
if (maxSymbolValue >= 160) {
|
||||
const svuint8_t ca = svadd_n_u8_x(vl128, c2, 128);
|
||||
const svuint8_t cb = svadd_n_u8_x(vl128, c3, 128);
|
||||
const svuint8_t cc = svadd_n_u8_x(vl128, c4, 128);
|
||||
const svuint8_t cd = svadd_n_u8_x(vl128, c5, 128);
|
||||
const svuint8_t ce = svadd_n_u8_x(vl128, c6, 128);
|
||||
const svuint8_t cf = svadd_n_u8_x(vl128, c7, 128);
|
||||
|
||||
max = HIST_count_6_sve2(ip, sourceSize, count + 160, ca, cb, cc,
|
||||
cd, ce, cf, max, maxCount - 160);
|
||||
} else if (maxCount > 160) {
|
||||
ZSTD_memset(count + 160, 0, (maxCount - 160) * sizeof(*count));
|
||||
}
|
||||
} else if (maxCount > 64) {
|
||||
ZSTD_memset(count + 64, 0, (maxCount - 64) * sizeof(*count));
|
||||
}
|
||||
|
||||
return svmaxv_u16(vl128, max);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* HIST_count_parallel_wksp() :
|
||||
* store histogram into 4 intermediate tables, recombined at the end.
|
||||
* this design makes better use of OoO cpus,
|
||||
@ -63,8 +317,8 @@ typedef enum { trustInput, checkMaxSymbolValue } HIST_checkInput_e;
|
||||
* `workSpace` must be a U32 table of size >= HIST_WKSP_SIZE_U32.
|
||||
* @return : largest histogram frequency,
|
||||
* or an error code (notably when histogram's alphabet is larger than *maxSymbolValuePtr) */
|
||||
static size_t HIST_count_parallel_wksp(
|
||||
unsigned* count, unsigned* maxSymbolValuePtr,
|
||||
static UNUSED_ATTR
|
||||
size_t HIST_count_parallel_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
|
||||
const void* source, size_t sourceSize,
|
||||
HIST_checkInput_e check,
|
||||
U32* const workSpace)
|
||||
@ -141,11 +395,17 @@ size_t HIST_countFast_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
|
||||
const void* source, size_t sourceSize,
|
||||
void* workSpace, size_t workSpaceSize)
|
||||
{
|
||||
if (sourceSize < 1500) /* heuristic threshold */
|
||||
if (sourceSize < HIST_FAST_THRESHOLD) /* heuristic threshold */
|
||||
return HIST_count_simple(count, maxSymbolValuePtr, source, sourceSize);
|
||||
#if defined(ZSTD_ARCH_ARM_SVE2)
|
||||
(void)workSpace;
|
||||
(void)workSpaceSize;
|
||||
return HIST_count_sve2(count, maxSymbolValuePtr, source, sourceSize, trustInput);
|
||||
#else
|
||||
if ((size_t)workSpace & 3) return ERROR(GENERIC); /* must be aligned on 4-bytes boundaries */
|
||||
if (workSpaceSize < HIST_WKSP_SIZE) return ERROR(workSpace_tooSmall);
|
||||
return HIST_count_parallel_wksp(count, maxSymbolValuePtr, source, sourceSize, trustInput, (U32*)workSpace);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* HIST_count_wksp() :
|
||||
@ -155,10 +415,15 @@ size_t HIST_count_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
|
||||
const void* source, size_t sourceSize,
|
||||
void* workSpace, size_t workSpaceSize)
|
||||
{
|
||||
#if defined(ZSTD_ARCH_ARM_SVE2)
|
||||
if (*maxSymbolValuePtr < 255)
|
||||
return HIST_count_sve2(count, maxSymbolValuePtr, source, sourceSize, checkMaxSymbolValue);
|
||||
#else
|
||||
if ((size_t)workSpace & 3) return ERROR(GENERIC); /* must be aligned on 4-bytes boundaries */
|
||||
if (workSpaceSize < HIST_WKSP_SIZE) return ERROR(workSpace_tooSmall);
|
||||
if (*maxSymbolValuePtr < 255)
|
||||
return HIST_count_parallel_wksp(count, maxSymbolValuePtr, source, sourceSize, checkMaxSymbolValue, (U32*)workSpace);
|
||||
#endif
|
||||
*maxSymbolValuePtr = 255;
|
||||
return HIST_countFast_wksp(count, maxSymbolValuePtr, source, sourceSize, workSpace, workSpaceSize);
|
||||
}
|
||||
|
@ -35,7 +35,11 @@ unsigned HIST_isError(size_t code); /**< tells if a return value is an error co
|
||||
|
||||
/* --- advanced histogram functions --- */
|
||||
|
||||
#if defined(__ARM_FEATURE_SVE2)
|
||||
#define HIST_WKSP_SIZE_U32 0
|
||||
#else
|
||||
#define HIST_WKSP_SIZE_U32 1024
|
||||
#endif
|
||||
#define HIST_WKSP_SIZE (HIST_WKSP_SIZE_U32 * sizeof(unsigned))
|
||||
/** HIST_count_wksp() :
|
||||
* Same as HIST_count(), but using an externally provided scratch buffer.
|
||||
@ -73,3 +77,10 @@ size_t HIST_countFast_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
|
||||
*/
|
||||
unsigned HIST_count_simple(unsigned* count, unsigned* maxSymbolValuePtr,
|
||||
const void* src, size_t srcSize);
|
||||
|
||||
/*! HIST_add() :
|
||||
* Lowest level: just add nb of occurrences of characters from @src into @count.
|
||||
* @count is not reset. @count array is presumed large enough (i.e. 1 KB).
|
||||
@ This function does not need any additional stack memory.
|
||||
*/
|
||||
void HIST_add(unsigned* count, const void* src, size_t srcSize);
|
||||
|
@ -425,6 +425,7 @@ static U32 HUF_setMaxHeight(nodeElt* huffNode, U32 lastNonNull, U32 targetNbBits
|
||||
* gain back half the rank.
|
||||
*/
|
||||
U32 nBitsToDecrease = ZSTD_highbit32((U32)totalCost) + 1;
|
||||
assert(nBitsToDecrease <= HUF_TABLELOG_MAX+1);
|
||||
for ( ; nBitsToDecrease > 1; nBitsToDecrease--) {
|
||||
U32 const highPos = rankLast[nBitsToDecrease];
|
||||
U32 const lowPos = rankLast[nBitsToDecrease-1];
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -24,10 +24,7 @@
|
||||
# include "zstdmt_compress.h"
|
||||
#endif
|
||||
#include "../common/bits.h" /* ZSTD_highbit32, ZSTD_NbCommonBytes */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "zstd_preSplit.h" /* ZSTD_SLIPBLOCK_WORKSPACESIZE */
|
||||
|
||||
/*-*************************************
|
||||
* Constants
|
||||
@ -82,6 +79,70 @@ typedef struct {
|
||||
ZSTD_fseCTables_t fse;
|
||||
} ZSTD_entropyCTables_t;
|
||||
|
||||
/***********************************************
|
||||
* Sequences *
|
||||
***********************************************/
|
||||
typedef struct SeqDef_s {
|
||||
U32 offBase; /* offBase == Offset + ZSTD_REP_NUM, or repcode 1,2,3 */
|
||||
U16 litLength;
|
||||
U16 mlBase; /* mlBase == matchLength - MINMATCH */
|
||||
} SeqDef;
|
||||
|
||||
/* Controls whether seqStore has a single "long" litLength or matchLength. See SeqStore_t. */
|
||||
typedef enum {
|
||||
ZSTD_llt_none = 0, /* no longLengthType */
|
||||
ZSTD_llt_literalLength = 1, /* represents a long literal */
|
||||
ZSTD_llt_matchLength = 2 /* represents a long match */
|
||||
} ZSTD_longLengthType_e;
|
||||
|
||||
typedef struct {
|
||||
SeqDef* sequencesStart;
|
||||
SeqDef* sequences; /* ptr to end of sequences */
|
||||
BYTE* litStart;
|
||||
BYTE* lit; /* ptr to end of literals */
|
||||
BYTE* llCode;
|
||||
BYTE* mlCode;
|
||||
BYTE* ofCode;
|
||||
size_t maxNbSeq;
|
||||
size_t maxNbLit;
|
||||
|
||||
/* longLengthPos and longLengthType to allow us to represent either a single litLength or matchLength
|
||||
* in the seqStore that has a value larger than U16 (if it exists). To do so, we increment
|
||||
* the existing value of the litLength or matchLength by 0x10000.
|
||||
*/
|
||||
ZSTD_longLengthType_e longLengthType;
|
||||
U32 longLengthPos; /* Index of the sequence to apply long length modification to */
|
||||
} SeqStore_t;
|
||||
|
||||
typedef struct {
|
||||
U32 litLength;
|
||||
U32 matchLength;
|
||||
} ZSTD_SequenceLength;
|
||||
|
||||
/**
|
||||
* Returns the ZSTD_SequenceLength for the given sequences. It handles the decoding of long sequences
|
||||
* indicated by longLengthPos and longLengthType, and adds MINMATCH back to matchLength.
|
||||
*/
|
||||
MEM_STATIC ZSTD_SequenceLength ZSTD_getSequenceLength(SeqStore_t const* seqStore, SeqDef const* seq)
|
||||
{
|
||||
ZSTD_SequenceLength seqLen;
|
||||
seqLen.litLength = seq->litLength;
|
||||
seqLen.matchLength = seq->mlBase + MINMATCH;
|
||||
if (seqStore->longLengthPos == (U32)(seq - seqStore->sequencesStart)) {
|
||||
if (seqStore->longLengthType == ZSTD_llt_literalLength) {
|
||||
seqLen.litLength += 0x10000;
|
||||
}
|
||||
if (seqStore->longLengthType == ZSTD_llt_matchLength) {
|
||||
seqLen.matchLength += 0x10000;
|
||||
}
|
||||
}
|
||||
return seqLen;
|
||||
}
|
||||
|
||||
const SeqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); /* compress & dictBuilder */
|
||||
int ZSTD_seqToCodes(const SeqStore_t* seqStorePtr); /* compress, dictBuilder, decodeCorpus (shouldn't get its definition from here) */
|
||||
|
||||
|
||||
/***********************************************
|
||||
* Entropy buffer statistics structs and funcs *
|
||||
***********************************************/
|
||||
@ -91,7 +152,7 @@ typedef struct {
|
||||
* hufDesSize refers to the size of huffman tree description in bytes.
|
||||
* This metadata is populated in ZSTD_buildBlockEntropyStats_literals() */
|
||||
typedef struct {
|
||||
symbolEncodingType_e hType;
|
||||
SymbolEncodingType_e hType;
|
||||
BYTE hufDesBuffer[ZSTD_MAX_HUF_HEADER_SIZE];
|
||||
size_t hufDesSize;
|
||||
} ZSTD_hufCTablesMetadata_t;
|
||||
@ -102,9 +163,9 @@ typedef struct {
|
||||
* fseTablesSize refers to the size of fse tables in bytes.
|
||||
* This metadata is populated in ZSTD_buildBlockEntropyStats_sequences() */
|
||||
typedef struct {
|
||||
symbolEncodingType_e llType;
|
||||
symbolEncodingType_e ofType;
|
||||
symbolEncodingType_e mlType;
|
||||
SymbolEncodingType_e llType;
|
||||
SymbolEncodingType_e ofType;
|
||||
SymbolEncodingType_e mlType;
|
||||
BYTE fseTablesBuffer[ZSTD_MAX_FSE_HEADERS_SIZE];
|
||||
size_t fseTablesSize;
|
||||
size_t lastCountSize; /* This is to account for bug in 1.3.4. More detail in ZSTD_entropyCompressSeqStore_internal() */
|
||||
@ -119,7 +180,7 @@ typedef struct {
|
||||
* Builds entropy for the block.
|
||||
* @return : 0 on success or error code */
|
||||
size_t ZSTD_buildBlockEntropyStats(
|
||||
const seqStore_t* seqStorePtr,
|
||||
const SeqStore_t* seqStorePtr,
|
||||
const ZSTD_entropyCTables_t* prevEntropy,
|
||||
ZSTD_entropyCTables_t* nextEntropy,
|
||||
const ZSTD_CCtx_params* cctxParams,
|
||||
@ -148,15 +209,9 @@ typedef struct {
|
||||
stopped. posInSequence <= seq[pos].litLength + seq[pos].matchLength */
|
||||
size_t size; /* The number of sequences. <= capacity. */
|
||||
size_t capacity; /* The capacity starting from `seq` pointer */
|
||||
} rawSeqStore_t;
|
||||
} RawSeqStore_t;
|
||||
|
||||
typedef struct {
|
||||
U32 idx; /* Index in array of ZSTD_Sequence */
|
||||
U32 posInSequence; /* Position within sequence at idx */
|
||||
size_t posInSrc; /* Number of bytes given by sequences provided so far */
|
||||
} ZSTD_sequencePosition;
|
||||
|
||||
UNUSED_ATTR static const rawSeqStore_t kNullRawSeqStore = {NULL, 0, 0, 0, 0};
|
||||
UNUSED_ATTR static const RawSeqStore_t kNullRawSeqStore = {NULL, 0, 0, 0, 0};
|
||||
|
||||
typedef struct {
|
||||
int price; /* price from beginning of segment to this position */
|
||||
@ -188,7 +243,7 @@ typedef struct {
|
||||
U32 offCodeSumBasePrice; /* to compare to log2(offreq) */
|
||||
ZSTD_OptPrice_e priceType; /* prices can be determined dynamically, or follow a pre-defined cost structure */
|
||||
const ZSTD_entropyCTables_t* symbolCosts; /* pre-calculated dictionary statistics */
|
||||
ZSTD_paramSwitch_e literalCompressionMode;
|
||||
ZSTD_ParamSwitch_e literalCompressionMode;
|
||||
} optState_t;
|
||||
|
||||
typedef struct {
|
||||
@ -210,11 +265,11 @@ typedef struct {
|
||||
|
||||
#define ZSTD_WINDOW_START_INDEX 2
|
||||
|
||||
typedef struct ZSTD_matchState_t ZSTD_matchState_t;
|
||||
typedef struct ZSTD_MatchState_t ZSTD_MatchState_t;
|
||||
|
||||
#define ZSTD_ROW_HASH_CACHE_SIZE 8 /* Size of prefetching hash cache for row-based matchfinder */
|
||||
|
||||
struct ZSTD_matchState_t {
|
||||
struct ZSTD_MatchState_t {
|
||||
ZSTD_window_t window; /* State for window round buffer management */
|
||||
U32 loadedDictEnd; /* index of end of dictionary, within context's referential.
|
||||
* When loadedDictEnd != 0, a dictionary is in use, and still valid.
|
||||
@ -236,15 +291,15 @@ struct ZSTD_matchState_t {
|
||||
U32* hashTable3;
|
||||
U32* chainTable;
|
||||
|
||||
U32 forceNonContiguous; /* Non-zero if we should force non-contiguous load for the next window update. */
|
||||
int forceNonContiguous; /* Non-zero if we should force non-contiguous load for the next window update. */
|
||||
|
||||
int dedicatedDictSearch; /* Indicates whether this matchState is using the
|
||||
* dedicated dictionary search structure.
|
||||
*/
|
||||
optState_t opt; /* optimal parser state */
|
||||
const ZSTD_matchState_t* dictMatchState;
|
||||
const ZSTD_MatchState_t* dictMatchState;
|
||||
ZSTD_compressionParameters cParams;
|
||||
const rawSeqStore_t* ldmSeqStore;
|
||||
const RawSeqStore_t* ldmSeqStore;
|
||||
|
||||
/* Controls prefetching in some dictMatchState matchfinders.
|
||||
* This behavior is controlled from the cctx ms.
|
||||
@ -262,7 +317,7 @@ struct ZSTD_matchState_t {
|
||||
typedef struct {
|
||||
ZSTD_compressedBlockState_t* prevCBlock;
|
||||
ZSTD_compressedBlockState_t* nextCBlock;
|
||||
ZSTD_matchState_t matchState;
|
||||
ZSTD_MatchState_t matchState;
|
||||
} ZSTD_blockState_t;
|
||||
|
||||
typedef struct {
|
||||
@ -289,7 +344,7 @@ typedef struct {
|
||||
} ldmState_t;
|
||||
|
||||
typedef struct {
|
||||
ZSTD_paramSwitch_e enableLdm; /* ZSTD_ps_enable to enable LDM. ZSTD_ps_auto by default */
|
||||
ZSTD_ParamSwitch_e enableLdm; /* ZSTD_ps_enable to enable LDM. ZSTD_ps_auto by default */
|
||||
U32 hashLog; /* Log size of hashTable */
|
||||
U32 bucketSizeLog; /* Log bucket size for collision resolution, at most 8 */
|
||||
U32 minMatchLength; /* Minimum match length */
|
||||
@ -320,7 +375,7 @@ struct ZSTD_CCtx_params_s {
|
||||
* There is no guarantee that hint is close to actual source size */
|
||||
|
||||
ZSTD_dictAttachPref_e attachDictPref;
|
||||
ZSTD_paramSwitch_e literalCompressionMode;
|
||||
ZSTD_ParamSwitch_e literalCompressionMode;
|
||||
|
||||
/* Multithreading: used to pass parameters to mtctx */
|
||||
int nbWorkers;
|
||||
@ -339,14 +394,27 @@ struct ZSTD_CCtx_params_s {
|
||||
ZSTD_bufferMode_e outBufferMode;
|
||||
|
||||
/* Sequence compression API */
|
||||
ZSTD_sequenceFormat_e blockDelimiters;
|
||||
ZSTD_SequenceFormat_e blockDelimiters;
|
||||
int validateSequences;
|
||||
|
||||
/* Block splitting */
|
||||
ZSTD_paramSwitch_e useBlockSplitter;
|
||||
/* Block splitting
|
||||
* @postBlockSplitter executes split analysis after sequences are produced,
|
||||
* it's more accurate but consumes more resources.
|
||||
* @preBlockSplitter_level splits before knowing sequences,
|
||||
* it's more approximative but also cheaper.
|
||||
* Valid @preBlockSplitter_level values range from 0 to 6 (included).
|
||||
* 0 means auto, 1 means do not split,
|
||||
* then levels are sorted in increasing cpu budget, from 2 (fastest) to 6 (slowest).
|
||||
* Highest @preBlockSplitter_level combines well with @postBlockSplitter.
|
||||
*/
|
||||
ZSTD_ParamSwitch_e postBlockSplitter;
|
||||
int preBlockSplitter_level;
|
||||
|
||||
/* Adjust the max block size*/
|
||||
size_t maxBlockSize;
|
||||
|
||||
/* Param for deciding whether to use row-based matchfinder */
|
||||
ZSTD_paramSwitch_e useRowMatchFinder;
|
||||
ZSTD_ParamSwitch_e useRowMatchFinder;
|
||||
|
||||
/* Always load a dictionary in ext-dict mode (not prefix mode)? */
|
||||
int deterministicRefPrefix;
|
||||
@ -355,7 +423,7 @@ struct ZSTD_CCtx_params_s {
|
||||
ZSTD_customMem customMem;
|
||||
|
||||
/* Controls prefetching in some dictMatchState matchfinders */
|
||||
ZSTD_paramSwitch_e prefetchCDictTables;
|
||||
ZSTD_ParamSwitch_e prefetchCDictTables;
|
||||
|
||||
/* Controls whether zstd will fall back to an internal matchfinder
|
||||
* if the external matchfinder returns an error code. */
|
||||
@ -367,15 +435,13 @@ struct ZSTD_CCtx_params_s {
|
||||
void* extSeqProdState;
|
||||
ZSTD_sequenceProducer_F extSeqProdFunc;
|
||||
|
||||
/* Adjust the max block size*/
|
||||
size_t maxBlockSize;
|
||||
|
||||
/* Controls repcode search in external sequence parsing */
|
||||
ZSTD_paramSwitch_e searchForExternalRepcodes;
|
||||
ZSTD_ParamSwitch_e searchForExternalRepcodes;
|
||||
}; /* typedef'd to ZSTD_CCtx_params within "zstd.h" */
|
||||
|
||||
#define COMPRESS_SEQUENCES_WORKSPACE_SIZE (sizeof(unsigned) * (MaxSeq + 2))
|
||||
#define ENTROPY_WORKSPACE_SIZE (HUF_WORKSPACE_SIZE + COMPRESS_SEQUENCES_WORKSPACE_SIZE)
|
||||
#define TMP_WORKSPACE_SIZE (MAX(ENTROPY_WORKSPACE_SIZE, ZSTD_SLIPBLOCK_WORKSPACESIZE))
|
||||
|
||||
/**
|
||||
* Indicates whether this compression proceeds directly from user-provided
|
||||
@ -393,11 +459,11 @@ typedef enum {
|
||||
*/
|
||||
#define ZSTD_MAX_NB_BLOCK_SPLITS 196
|
||||
typedef struct {
|
||||
seqStore_t fullSeqStoreChunk;
|
||||
seqStore_t firstHalfSeqStore;
|
||||
seqStore_t secondHalfSeqStore;
|
||||
seqStore_t currSeqStore;
|
||||
seqStore_t nextSeqStore;
|
||||
SeqStore_t fullSeqStoreChunk;
|
||||
SeqStore_t firstHalfSeqStore;
|
||||
SeqStore_t secondHalfSeqStore;
|
||||
SeqStore_t currSeqStore;
|
||||
SeqStore_t nextSeqStore;
|
||||
|
||||
U32 partitions[ZSTD_MAX_NB_BLOCK_SPLITS];
|
||||
ZSTD_entropyCTablesMetadata_t entropyMetadata;
|
||||
@ -414,7 +480,7 @@ struct ZSTD_CCtx_s {
|
||||
size_t dictContentSize;
|
||||
|
||||
ZSTD_cwksp workspace; /* manages buffer for dynamic allocations */
|
||||
size_t blockSize;
|
||||
size_t blockSizeMax;
|
||||
unsigned long long pledgedSrcSizePlusOne; /* this way, 0 (default) == unknown */
|
||||
unsigned long long consumedSrcSize;
|
||||
unsigned long long producedCSize;
|
||||
@ -426,13 +492,14 @@ struct ZSTD_CCtx_s {
|
||||
int isFirstBlock;
|
||||
int initialized;
|
||||
|
||||
seqStore_t seqStore; /* sequences storage ptrs */
|
||||
SeqStore_t seqStore; /* sequences storage ptrs */
|
||||
ldmState_t ldmState; /* long distance matching state */
|
||||
rawSeq* ldmSequences; /* Storage for the ldm output sequences */
|
||||
size_t maxNbLdmSequences;
|
||||
rawSeqStore_t externSeqStore; /* Mutable reference to external sequences */
|
||||
RawSeqStore_t externSeqStore; /* Mutable reference to external sequences */
|
||||
ZSTD_blockState_t blockState;
|
||||
U32* entropyWorkspace; /* entropy workspace of ENTROPY_WORKSPACE_SIZE bytes */
|
||||
void* tmpWorkspace; /* used as substitute of stack space - must be aligned for S64 type */
|
||||
size_t tmpWkspSize;
|
||||
|
||||
/* Whether we are streaming or not */
|
||||
ZSTD_buffered_policy_e bufferedPolicy;
|
||||
@ -506,12 +573,12 @@ typedef enum {
|
||||
* behavior of taking both the source size and the dict size into account
|
||||
* when selecting and adjusting parameters.
|
||||
*/
|
||||
} ZSTD_cParamMode_e;
|
||||
} ZSTD_CParamMode_e;
|
||||
|
||||
typedef size_t (*ZSTD_blockCompressor) (
|
||||
ZSTD_matchState_t* bs, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
||||
typedef size_t (*ZSTD_BlockCompressor_f) (
|
||||
ZSTD_MatchState_t* bs, SeqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
|
||||
void const* src, size_t srcSize);
|
||||
ZSTD_blockCompressor ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_paramSwitch_e rowMatchfinderMode, ZSTD_dictMode_e dictMode);
|
||||
ZSTD_BlockCompressor_f ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_ParamSwitch_e rowMatchfinderMode, ZSTD_dictMode_e dictMode);
|
||||
|
||||
|
||||
MEM_STATIC U32 ZSTD_LLcode(U32 litLength)
|
||||
@ -557,6 +624,25 @@ MEM_STATIC int ZSTD_cParam_withinBounds(ZSTD_cParameter cParam, int value)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ZSTD_selectAddr:
|
||||
* @return index >= lowLimit ? candidate : backup,
|
||||
* tries to force branchless codegen. */
|
||||
MEM_STATIC const BYTE*
|
||||
ZSTD_selectAddr(U32 index, U32 lowLimit, const BYTE* candidate, const BYTE* backup)
|
||||
{
|
||||
#if defined(__GNUC__) && defined(__x86_64__)
|
||||
__asm__ (
|
||||
"cmp %1, %2\n"
|
||||
"cmova %3, %0\n"
|
||||
: "+r"(candidate)
|
||||
: "r"(index), "r"(lowLimit), "r"(backup)
|
||||
);
|
||||
return candidate;
|
||||
#else
|
||||
return index >= lowLimit ? candidate : backup;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ZSTD_noCompressBlock() :
|
||||
* Writes uncompressed block to dst buffer from given src.
|
||||
* Returns the size of the block */
|
||||
@ -621,7 +707,7 @@ ZSTD_safecopyLiterals(BYTE* op, BYTE const* ip, BYTE const* const iend, BYTE con
|
||||
{
|
||||
assert(iend > ilimit_w);
|
||||
if (ip <= ilimit_w) {
|
||||
ZSTD_wildcopy(op, ip, ilimit_w - ip, ZSTD_no_overlap);
|
||||
ZSTD_wildcopy(op, ip, (size_t)(ilimit_w - ip), ZSTD_no_overlap);
|
||||
op += ilimit_w - ip;
|
||||
ip = ilimit_w;
|
||||
}
|
||||
@ -639,14 +725,55 @@ ZSTD_safecopyLiterals(BYTE* op, BYTE const* ip, BYTE const* const iend, BYTE con
|
||||
#define OFFBASE_TO_OFFSET(o) (assert(OFFBASE_IS_OFFSET(o)), (o) - ZSTD_REP_NUM)
|
||||
#define OFFBASE_TO_REPCODE(o) (assert(OFFBASE_IS_REPCODE(o)), (o)) /* returns ID 1,2,3 */
|
||||
|
||||
/*! ZSTD_storeSeqOnly() :
|
||||
* Store a sequence (litlen, litPtr, offBase and matchLength) into SeqStore_t.
|
||||
* Literals themselves are not copied, but @litPtr is updated.
|
||||
* @offBase : Users should employ macros REPCODE_TO_OFFBASE() and OFFSET_TO_OFFBASE().
|
||||
* @matchLength : must be >= MINMATCH
|
||||
*/
|
||||
HINT_INLINE UNUSED_ATTR void
|
||||
ZSTD_storeSeqOnly(SeqStore_t* seqStorePtr,
|
||||
size_t litLength,
|
||||
U32 offBase,
|
||||
size_t matchLength)
|
||||
{
|
||||
assert((size_t)(seqStorePtr->sequences - seqStorePtr->sequencesStart) < seqStorePtr->maxNbSeq);
|
||||
|
||||
/* literal Length */
|
||||
assert(litLength <= ZSTD_BLOCKSIZE_MAX);
|
||||
if (UNLIKELY(litLength>0xFFFF)) {
|
||||
assert(seqStorePtr->longLengthType == ZSTD_llt_none); /* there can only be a single long length */
|
||||
seqStorePtr->longLengthType = ZSTD_llt_literalLength;
|
||||
seqStorePtr->longLengthPos = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
|
||||
}
|
||||
seqStorePtr->sequences[0].litLength = (U16)litLength;
|
||||
|
||||
/* match offset */
|
||||
seqStorePtr->sequences[0].offBase = offBase;
|
||||
|
||||
/* match Length */
|
||||
assert(matchLength <= ZSTD_BLOCKSIZE_MAX);
|
||||
assert(matchLength >= MINMATCH);
|
||||
{ size_t const mlBase = matchLength - MINMATCH;
|
||||
if (UNLIKELY(mlBase>0xFFFF)) {
|
||||
assert(seqStorePtr->longLengthType == ZSTD_llt_none); /* there can only be a single long length */
|
||||
seqStorePtr->longLengthType = ZSTD_llt_matchLength;
|
||||
seqStorePtr->longLengthPos = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
|
||||
}
|
||||
seqStorePtr->sequences[0].mlBase = (U16)mlBase;
|
||||
}
|
||||
|
||||
seqStorePtr->sequences++;
|
||||
}
|
||||
|
||||
/*! ZSTD_storeSeq() :
|
||||
* Store a sequence (litlen, litPtr, offBase and matchLength) into seqStore_t.
|
||||
* Store a sequence (litlen, litPtr, offBase and matchLength) into SeqStore_t.
|
||||
* @offBase : Users should employ macros REPCODE_TO_OFFBASE() and OFFSET_TO_OFFBASE().
|
||||
* @matchLength : must be >= MINMATCH
|
||||
* Allowed to over-read literals up to litLimit.
|
||||
*/
|
||||
HINT_INLINE UNUSED_ATTR void
|
||||
ZSTD_storeSeq(seqStore_t* seqStorePtr,
|
||||
ZSTD_storeSeq(SeqStore_t* seqStorePtr,
|
||||
size_t litLength, const BYTE* literals, const BYTE* litLimit,
|
||||
U32 offBase,
|
||||
size_t matchLength)
|
||||
@ -673,36 +800,14 @@ ZSTD_storeSeq(seqStore_t* seqStorePtr,
|
||||
ZSTD_STATIC_ASSERT(WILDCOPY_OVERLENGTH >= 16);
|
||||
ZSTD_copy16(seqStorePtr->lit, literals);
|
||||
if (litLength > 16) {
|
||||
ZSTD_wildcopy(seqStorePtr->lit+16, literals+16, (ptrdiff_t)litLength-16, ZSTD_no_overlap);
|
||||
ZSTD_wildcopy(seqStorePtr->lit+16, literals+16, litLength-16, ZSTD_no_overlap);
|
||||
}
|
||||
} else {
|
||||
ZSTD_safecopyLiterals(seqStorePtr->lit, literals, litEnd, litLimit_w);
|
||||
}
|
||||
seqStorePtr->lit += litLength;
|
||||
|
||||
/* literal Length */
|
||||
if (litLength>0xFFFF) {
|
||||
assert(seqStorePtr->longLengthType == ZSTD_llt_none); /* there can only be a single long length */
|
||||
seqStorePtr->longLengthType = ZSTD_llt_literalLength;
|
||||
seqStorePtr->longLengthPos = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
|
||||
}
|
||||
seqStorePtr->sequences[0].litLength = (U16)litLength;
|
||||
|
||||
/* match offset */
|
||||
seqStorePtr->sequences[0].offBase = offBase;
|
||||
|
||||
/* match Length */
|
||||
assert(matchLength >= MINMATCH);
|
||||
{ size_t const mlBase = matchLength - MINMATCH;
|
||||
if (mlBase>0xFFFF) {
|
||||
assert(seqStorePtr->longLengthType == ZSTD_llt_none); /* there can only be a single long length */
|
||||
seqStorePtr->longLengthType = ZSTD_llt_matchLength;
|
||||
seqStorePtr->longLengthPos = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
|
||||
}
|
||||
seqStorePtr->sequences[0].mlBase = (U16)mlBase;
|
||||
}
|
||||
|
||||
seqStorePtr->sequences++;
|
||||
ZSTD_storeSeqOnly(seqStorePtr, litLength, offBase, matchLength);
|
||||
}
|
||||
|
||||
/* ZSTD_updateRep() :
|
||||
@ -731,12 +836,12 @@ ZSTD_updateRep(U32 rep[ZSTD_REP_NUM], U32 const offBase, U32 const ll0)
|
||||
|
||||
typedef struct repcodes_s {
|
||||
U32 rep[3];
|
||||
} repcodes_t;
|
||||
} Repcodes_t;
|
||||
|
||||
MEM_STATIC repcodes_t
|
||||
MEM_STATIC Repcodes_t
|
||||
ZSTD_newRep(U32 const rep[ZSTD_REP_NUM], U32 const offBase, U32 const ll0)
|
||||
{
|
||||
repcodes_t newReps;
|
||||
Repcodes_t newReps;
|
||||
ZSTD_memcpy(&newReps, rep, sizeof(newReps));
|
||||
ZSTD_updateRep(newReps.rep, offBase, ll0);
|
||||
return newReps;
|
||||
@ -779,8 +884,8 @@ ZSTD_count_2segments(const BYTE* ip, const BYTE* match,
|
||||
size_t const matchLength = ZSTD_count(ip, match, vEnd);
|
||||
if (match + matchLength != mEnd) return matchLength;
|
||||
DEBUGLOG(7, "ZSTD_count_2segments: found a 2-parts match (current length==%zu)", matchLength);
|
||||
DEBUGLOG(7, "distance from match beginning to end dictionary = %zi", mEnd - match);
|
||||
DEBUGLOG(7, "distance from current pos to end buffer = %zi", iEnd - ip);
|
||||
DEBUGLOG(7, "distance from match beginning to end dictionary = %i", (int)(mEnd - match));
|
||||
DEBUGLOG(7, "distance from current pos to end buffer = %i", (int)(iEnd - ip));
|
||||
DEBUGLOG(7, "next byte : ip==%02X, istart==%02X", ip[matchLength], *iStart);
|
||||
DEBUGLOG(7, "final match length = %zu", matchLength + ZSTD_count(ip+matchLength, iStart, iEnd));
|
||||
return matchLength + ZSTD_count(ip+matchLength, iStart, iEnd);
|
||||
@ -918,11 +1023,12 @@ MEM_STATIC U64 ZSTD_rollingHash_rotate(U64 hash, BYTE toRemove, BYTE toAdd, U64
|
||||
/*-*************************************
|
||||
* Round buffer management
|
||||
***************************************/
|
||||
#if (ZSTD_WINDOWLOG_MAX_64 > 31)
|
||||
# error "ZSTD_WINDOWLOG_MAX is too large : would overflow ZSTD_CURRENT_MAX"
|
||||
#endif
|
||||
/* Max current allowed */
|
||||
#define ZSTD_CURRENT_MAX ((3U << 29) + (1U << ZSTD_WINDOWLOG_MAX))
|
||||
/* Max @current value allowed:
|
||||
* In 32-bit mode: we want to avoid crossing the 2 GB limit,
|
||||
* reducing risks of side effects in case of signed operations on indexes.
|
||||
* In 64-bit mode: we want to ensure that adding the maximum job size (512 MB)
|
||||
* doesn't overflow U32 index capacity (4 GB) */
|
||||
#define ZSTD_CURRENT_MAX (MEM_64bits() ? 3500U MB : 2000U MB)
|
||||
/* Maximum chunk size before overflow correction needs to be called again */
|
||||
#define ZSTD_CHUNKSIZE_MAX \
|
||||
( ((U32)-1) /* Maximum ending current index */ \
|
||||
@ -962,7 +1068,7 @@ MEM_STATIC U32 ZSTD_window_hasExtDict(ZSTD_window_t const window)
|
||||
* Inspects the provided matchState and figures out what dictMode should be
|
||||
* passed to the compressor.
|
||||
*/
|
||||
MEM_STATIC ZSTD_dictMode_e ZSTD_matchState_dictMode(const ZSTD_matchState_t *ms)
|
||||
MEM_STATIC ZSTD_dictMode_e ZSTD_matchState_dictMode(const ZSTD_MatchState_t *ms)
|
||||
{
|
||||
return ZSTD_window_hasExtDict(ms->window) ?
|
||||
ZSTD_extDict :
|
||||
@ -1151,7 +1257,7 @@ ZSTD_window_enforceMaxDist(ZSTD_window_t* window,
|
||||
const void* blockEnd,
|
||||
U32 maxDist,
|
||||
U32* loadedDictEndPtr,
|
||||
const ZSTD_matchState_t** dictMatchStatePtr)
|
||||
const ZSTD_MatchState_t** dictMatchStatePtr)
|
||||
{
|
||||
U32 const blockEndIdx = (U32)((BYTE const*)blockEnd - window->base);
|
||||
U32 const loadedDictEnd = (loadedDictEndPtr != NULL) ? *loadedDictEndPtr : 0;
|
||||
@ -1196,7 +1302,7 @@ ZSTD_checkDictValidity(const ZSTD_window_t* window,
|
||||
const void* blockEnd,
|
||||
U32 maxDist,
|
||||
U32* loadedDictEndPtr,
|
||||
const ZSTD_matchState_t** dictMatchStatePtr)
|
||||
const ZSTD_MatchState_t** dictMatchStatePtr)
|
||||
{
|
||||
assert(loadedDictEndPtr != NULL);
|
||||
assert(dictMatchStatePtr != NULL);
|
||||
@ -1246,8 +1352,8 @@ MEM_STATIC void ZSTD_window_init(ZSTD_window_t* window) {
|
||||
MEM_STATIC
|
||||
ZSTD_ALLOW_POINTER_OVERFLOW_ATTR
|
||||
U32 ZSTD_window_update(ZSTD_window_t* window,
|
||||
void const* src, size_t srcSize,
|
||||
int forceNonContiguous)
|
||||
const void* src, size_t srcSize,
|
||||
int forceNonContiguous)
|
||||
{
|
||||
BYTE const* const ip = (BYTE const*)src;
|
||||
U32 contiguous = 1;
|
||||
@ -1274,8 +1380,9 @@ U32 ZSTD_window_update(ZSTD_window_t* window,
|
||||
/* if input and dictionary overlap : reduce dictionary (area presumed modified by input) */
|
||||
if ( (ip+srcSize > window->dictBase + window->lowLimit)
|
||||
& (ip < window->dictBase + window->dictLimit)) {
|
||||
ptrdiff_t const highInputIdx = (ip + srcSize) - window->dictBase;
|
||||
U32 const lowLimitMax = (highInputIdx > (ptrdiff_t)window->dictLimit) ? window->dictLimit : (U32)highInputIdx;
|
||||
size_t const highInputIdx = (size_t)((ip + srcSize) - window->dictBase);
|
||||
U32 const lowLimitMax = (highInputIdx > (size_t)window->dictLimit) ? window->dictLimit : (U32)highInputIdx;
|
||||
assert(highInputIdx < UINT_MAX);
|
||||
window->lowLimit = lowLimitMax;
|
||||
DEBUGLOG(5, "Overlapping extDict and input : new lowLimit = %u", window->lowLimit);
|
||||
}
|
||||
@ -1285,7 +1392,7 @@ U32 ZSTD_window_update(ZSTD_window_t* window,
|
||||
/**
|
||||
* Returns the lowest allowed match index. It may either be in the ext-dict or the prefix.
|
||||
*/
|
||||
MEM_STATIC U32 ZSTD_getLowestMatchIndex(const ZSTD_matchState_t* ms, U32 curr, unsigned windowLog)
|
||||
MEM_STATIC U32 ZSTD_getLowestMatchIndex(const ZSTD_MatchState_t* ms, U32 curr, unsigned windowLog)
|
||||
{
|
||||
U32 const maxDistance = 1U << windowLog;
|
||||
U32 const lowestValid = ms->window.lowLimit;
|
||||
@ -1302,7 +1409,7 @@ MEM_STATIC U32 ZSTD_getLowestMatchIndex(const ZSTD_matchState_t* ms, U32 curr, u
|
||||
/**
|
||||
* Returns the lowest allowed match index in the prefix.
|
||||
*/
|
||||
MEM_STATIC U32 ZSTD_getLowestPrefixIndex(const ZSTD_matchState_t* ms, U32 curr, unsigned windowLog)
|
||||
MEM_STATIC U32 ZSTD_getLowestPrefixIndex(const ZSTD_MatchState_t* ms, U32 curr, unsigned windowLog)
|
||||
{
|
||||
U32 const maxDistance = 1U << windowLog;
|
||||
U32 const lowestValid = ms->window.dictLimit;
|
||||
@ -1315,6 +1422,13 @@ MEM_STATIC U32 ZSTD_getLowestPrefixIndex(const ZSTD_matchState_t* ms, U32 curr,
|
||||
return matchLowest;
|
||||
}
|
||||
|
||||
/* index_safety_check:
|
||||
* intentional underflow : ensure repIndex isn't overlapping dict + prefix
|
||||
* @return 1 if values are not overlapping,
|
||||
* 0 otherwise */
|
||||
MEM_STATIC int ZSTD_index_overlap_check(const U32 prefixLowestIndex, const U32 repIndex) {
|
||||
return ((U32)((prefixLowestIndex-1) - repIndex) >= 3);
|
||||
}
|
||||
|
||||
|
||||
/* debug functions */
|
||||
@ -1385,10 +1499,6 @@ MEM_STATIC int ZSTD_comparePackedTags(size_t packedTag1, size_t packedTag2) {
|
||||
return tag1 == tag2;
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ===============================================================
|
||||
* Shared internal declarations
|
||||
* These prototypes may be called from sources not in lib/compress
|
||||
@ -1404,6 +1514,25 @@ size_t ZSTD_loadCEntropy(ZSTD_compressedBlockState_t* bs, void* workspace,
|
||||
|
||||
void ZSTD_reset_compressedBlockState(ZSTD_compressedBlockState_t* bs);
|
||||
|
||||
typedef struct {
|
||||
U32 idx; /* Index in array of ZSTD_Sequence */
|
||||
U32 posInSequence; /* Position within sequence at idx */
|
||||
size_t posInSrc; /* Number of bytes given by sequences provided so far */
|
||||
} ZSTD_SequencePosition;
|
||||
|
||||
/* for benchmark */
|
||||
size_t ZSTD_convertBlockSequences(ZSTD_CCtx* cctx,
|
||||
const ZSTD_Sequence* const inSeqs, size_t nbSequences,
|
||||
int repcodeResolution);
|
||||
|
||||
typedef struct {
|
||||
size_t nbSequences;
|
||||
size_t blockSize;
|
||||
size_t litSize;
|
||||
} BlockSummary;
|
||||
|
||||
BlockSummary ZSTD_get1BlockSummary(const ZSTD_Sequence* seqs, size_t nbSeqs);
|
||||
|
||||
/* ==============================================================
|
||||
* Private declarations
|
||||
* These prototypes shall only be called from within lib/compress
|
||||
@ -1415,7 +1544,7 @@ void ZSTD_reset_compressedBlockState(ZSTD_compressedBlockState_t* bs);
|
||||
* Note: srcSizeHint == 0 means 0!
|
||||
*/
|
||||
ZSTD_compressionParameters ZSTD_getCParamsFromCCtxParams(
|
||||
const ZSTD_CCtx_params* CCtxParams, U64 srcSizeHint, size_t dictSize, ZSTD_cParamMode_e mode);
|
||||
const ZSTD_CCtx_params* CCtxParams, U64 srcSizeHint, size_t dictSize, ZSTD_CParamMode_e mode);
|
||||
|
||||
/*! ZSTD_initCStream_internal() :
|
||||
* Private use only. Init streaming operation.
|
||||
@ -1427,7 +1556,7 @@ size_t ZSTD_initCStream_internal(ZSTD_CStream* zcs,
|
||||
const ZSTD_CDict* cdict,
|
||||
const ZSTD_CCtx_params* params, unsigned long long pledgedSrcSize);
|
||||
|
||||
void ZSTD_resetSeqStore(seqStore_t* ssPtr);
|
||||
void ZSTD_resetSeqStore(SeqStore_t* ssPtr);
|
||||
|
||||
/*! ZSTD_getCParamsFromCDict() :
|
||||
* as the name implies */
|
||||
@ -1480,33 +1609,6 @@ U32 ZSTD_cycleLog(U32 hashLog, ZSTD_strategy strat);
|
||||
*/
|
||||
void ZSTD_CCtx_trace(ZSTD_CCtx* cctx, size_t extraCSize);
|
||||
|
||||
/* Returns 0 on success, and a ZSTD_error otherwise. This function scans through an array of
|
||||
* ZSTD_Sequence, storing the sequences it finds, until it reaches a block delimiter.
|
||||
* Note that the block delimiter must include the last literals of the block.
|
||||
*/
|
||||
size_t
|
||||
ZSTD_copySequencesToSeqStoreExplicitBlockDelim(ZSTD_CCtx* cctx,
|
||||
ZSTD_sequencePosition* seqPos,
|
||||
const ZSTD_Sequence* const inSeqs, size_t inSeqsSize,
|
||||
const void* src, size_t blockSize, ZSTD_paramSwitch_e externalRepSearch);
|
||||
|
||||
/* Returns the number of bytes to move the current read position back by.
|
||||
* Only non-zero if we ended up splitting a sequence.
|
||||
* Otherwise, it may return a ZSTD error if something went wrong.
|
||||
*
|
||||
* This function will attempt to scan through blockSize bytes
|
||||
* represented by the sequences in @inSeqs,
|
||||
* storing any (partial) sequences.
|
||||
*
|
||||
* Occasionally, we may want to change the actual number of bytes we consumed from inSeqs to
|
||||
* avoid splitting a match, or to avoid splitting a match such that it would produce a match
|
||||
* smaller than MINMATCH. In this case, we return the number of bytes that we didn't read from this block.
|
||||
*/
|
||||
size_t
|
||||
ZSTD_copySequencesToSeqStoreNoBlockDelim(ZSTD_CCtx* cctx, ZSTD_sequencePosition* seqPos,
|
||||
const ZSTD_Sequence* const inSeqs, size_t inSeqsSize,
|
||||
const void* src, size_t blockSize, ZSTD_paramSwitch_e externalRepSearch);
|
||||
|
||||
/* Returns 1 if an external sequence producer is registered, otherwise returns 0. */
|
||||
MEM_STATIC int ZSTD_hasExtSeqProd(const ZSTD_CCtx_params* params) {
|
||||
return params->extSeqProdFunc != NULL;
|
||||
|
@ -140,7 +140,7 @@ size_t ZSTD_compressLiterals (
|
||||
size_t const lhSize = 3 + (srcSize >= 1 KB) + (srcSize >= 16 KB);
|
||||
BYTE* const ostart = (BYTE*)dst;
|
||||
U32 singleStream = srcSize < 256;
|
||||
symbolEncodingType_e hType = set_compressed;
|
||||
SymbolEncodingType_e hType = set_compressed;
|
||||
size_t cLitSize;
|
||||
|
||||
DEBUGLOG(5,"ZSTD_compressLiterals (disableLiteralCompression=%i, srcSize=%u, dstCapacity=%zu)",
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user