Skip to content

Commit 6df288d

Browse files
committed
Macro-Exclude Block Compressors from Declaration/Definition
1 parent 92e8581 commit 6df288d

8 files changed

+185
-3
lines changed

lib/compress/zstd_compress.c

+11
Original file line numberDiff line numberDiff line change
@@ -4926,12 +4926,17 @@ static size_t ZSTD_loadDictionaryContent(ZSTD_matchState_t* ms,
49264926
ZSTD_fillHashTable(ms, iend, dtlm, tfp);
49274927
break;
49284928
case ZSTD_dfast:
4929+
#ifndef ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR
49294930
ZSTD_fillDoubleHashTable(ms, iend, dtlm, tfp);
4931+
#endif
49304932
break;
49314933

49324934
case ZSTD_greedy:
49334935
case ZSTD_lazy:
49344936
case ZSTD_lazy2:
4937+
#if !defined(ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR) \
4938+
|| !defined(ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR) \
4939+
|| !defined(ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR)
49354940
assert(srcSize >= HASH_READ_SIZE);
49364941
if (ms->dedicatedDictSearch) {
49374942
assert(ms->chainTable != NULL);
@@ -4948,14 +4953,20 @@ static size_t ZSTD_loadDictionaryContent(ZSTD_matchState_t* ms,
49484953
DEBUGLOG(4, "Using chain-based hash table for lazy dict");
49494954
}
49504955
}
4956+
#endif
49514957
break;
49524958

49534959
case ZSTD_btlazy2: /* we want the dictionary table fully sorted */
49544960
case ZSTD_btopt:
49554961
case ZSTD_btultra:
49564962
case ZSTD_btultra2:
4963+
#if !defined(ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR) \
4964+
|| !defined(ZSTD_EXCLUDE_BTOPT_BLOCK_COMPRESSOR) \
4965+
|| !defined(ZSTD_EXCLUDE_BTULTRA_BLOCK_COMPRESSOR) \
4966+
|| !defined(ZSTD_EXCLUDE_BTULTRA2_BLOCK_COMPRESSOR)
49574967
assert(srcSize >= HASH_READ_SIZE);
49584968
ZSTD_updateTree(ms, iend-HASH_READ_SIZE, iend);
4969+
#endif
49594970
break;
49604971

49614972
default:

lib/compress/zstd_double_fast.c

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "zstd_compress_internal.h"
1212
#include "zstd_double_fast.h"
1313

14+
#ifndef ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR
15+
1416
static void ZSTD_fillDoubleHashTableForCDict(ZSTD_matchState_t* ms,
1517
void const* end, ZSTD_dictTableLoadMethod_e dtlm)
1618
{
@@ -756,3 +758,5 @@ size_t ZSTD_compressBlock_doubleFast_extDict(
756758
return ZSTD_compressBlock_doubleFast_extDict_7(ms, seqStore, rep, src, srcSize);
757759
}
758760
}
761+
762+
#endif /* ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR */

lib/compress/zstd_double_fast.h

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ extern "C" {
1818
#include "../common/mem.h" /* U32 */
1919
#include "zstd_compress_internal.h" /* ZSTD_CCtx, size_t */
2020

21+
#ifndef ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR
22+
2123
void ZSTD_fillDoubleHashTable(ZSTD_matchState_t* ms,
2224
void const* end, ZSTD_dictTableLoadMethod_e dtlm,
2325
ZSTD_tableFillPurpose_e tfp);
@@ -31,6 +33,7 @@ size_t ZSTD_compressBlock_doubleFast_extDict(
3133
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
3234
void const* src, size_t srcSize);
3335

36+
#endif /* ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR */
3437

3538
#if defined (__cplusplus)
3639
}

lib/compress/zstd_lazy.c

+65-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
#include "zstd_lazy.h"
1313
#include "../common/bits.h" /* ZSTD_countTrailingZeros64 */
1414

15+
#if !defined(ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR) \
16+
|| !defined(ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR) \
17+
|| !defined(ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR) \
18+
|| !defined(ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR)
19+
1520
#define kLazySkippingStep 8
1621

1722

@@ -1754,151 +1759,194 @@ ZSTD_compressBlock_lazy_generic(
17541759
/* Return the last literals size */
17551760
return (size_t)(iend - anchor);
17561761
}
1762+
#endif /* build exclusions */
17571763

17581764

1765+
#ifndef ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR
17591766
size_t ZSTD_compressBlock_btlazy2(
17601767
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
17611768
void const* src, size_t srcSize)
17621769
{
17631770
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_binaryTree, 2, ZSTD_noDict);
17641771
}
1772+
#endif
17651773

1774+
#ifndef ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR
17661775
size_t ZSTD_compressBlock_lazy2(
17671776
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
17681777
void const* src, size_t srcSize)
17691778
{
17701779
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_hashChain, 2, ZSTD_noDict);
17711780
}
1781+
#endif
17721782

1783+
#ifndef ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR
17731784
size_t ZSTD_compressBlock_lazy(
17741785
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
17751786
void const* src, size_t srcSize)
17761787
{
17771788
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_hashChain, 1, ZSTD_noDict);
17781789
}
1790+
#endif
17791791

1792+
#ifndef ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR
17801793
size_t ZSTD_compressBlock_greedy(
17811794
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
17821795
void const* src, size_t srcSize)
17831796
{
17841797
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_hashChain, 0, ZSTD_noDict);
17851798
}
1799+
#endif
17861800

1801+
#ifndef ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR
17871802
size_t ZSTD_compressBlock_btlazy2_dictMatchState(
17881803
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
17891804
void const* src, size_t srcSize)
17901805
{
17911806
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_binaryTree, 2, ZSTD_dictMatchState);
17921807
}
1808+
#endif
17931809

1810+
#ifndef ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR
17941811
size_t ZSTD_compressBlock_lazy2_dictMatchState(
17951812
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
17961813
void const* src, size_t srcSize)
17971814
{
17981815
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_hashChain, 2, ZSTD_dictMatchState);
17991816
}
1817+
#endif
18001818

1819+
#ifndef ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR
18011820
size_t ZSTD_compressBlock_lazy_dictMatchState(
18021821
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
18031822
void const* src, size_t srcSize)
18041823
{
18051824
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_hashChain, 1, ZSTD_dictMatchState);
18061825
}
1826+
#endif
18071827

1828+
#ifndef ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR
18081829
size_t ZSTD_compressBlock_greedy_dictMatchState(
18091830
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
18101831
void const* src, size_t srcSize)
18111832
{
18121833
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_hashChain, 0, ZSTD_dictMatchState);
18131834
}
1835+
#endif
18141836

1815-
1837+
#ifndef ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR
18161838
size_t ZSTD_compressBlock_lazy2_dedicatedDictSearch(
18171839
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
18181840
void const* src, size_t srcSize)
18191841
{
18201842
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_hashChain, 2, ZSTD_dedicatedDictSearch);
18211843
}
1844+
#endif
18221845

1846+
#ifndef ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR
18231847
size_t ZSTD_compressBlock_lazy_dedicatedDictSearch(
18241848
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
18251849
void const* src, size_t srcSize)
18261850
{
18271851
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_hashChain, 1, ZSTD_dedicatedDictSearch);
18281852
}
1853+
#endif
18291854

1855+
#ifndef ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR
18301856
size_t ZSTD_compressBlock_greedy_dedicatedDictSearch(
18311857
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
18321858
void const* src, size_t srcSize)
18331859
{
18341860
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_hashChain, 0, ZSTD_dedicatedDictSearch);
18351861
}
1862+
#endif
18361863

18371864
/* Row-based matchfinder */
1865+
#ifndef ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR
18381866
size_t ZSTD_compressBlock_lazy2_row(
18391867
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
18401868
void const* src, size_t srcSize)
18411869
{
18421870
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_rowHash, 2, ZSTD_noDict);
18431871
}
1872+
#endif
18441873

1874+
#ifndef ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR
18451875
size_t ZSTD_compressBlock_lazy_row(
18461876
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
18471877
void const* src, size_t srcSize)
18481878
{
18491879
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_rowHash, 1, ZSTD_noDict);
18501880
}
1881+
#endif
18511882

1883+
#ifndef ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR
18521884
size_t ZSTD_compressBlock_greedy_row(
18531885
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
18541886
void const* src, size_t srcSize)
18551887
{
18561888
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_rowHash, 0, ZSTD_noDict);
18571889
}
1890+
#endif
18581891

1892+
#ifndef ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR
18591893
size_t ZSTD_compressBlock_lazy2_dictMatchState_row(
18601894
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
18611895
void const* src, size_t srcSize)
18621896
{
18631897
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_rowHash, 2, ZSTD_dictMatchState);
18641898
}
1899+
#endif
18651900

1901+
#ifndef ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR
18661902
size_t ZSTD_compressBlock_lazy_dictMatchState_row(
18671903
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
18681904
void const* src, size_t srcSize)
18691905
{
18701906
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_rowHash, 1, ZSTD_dictMatchState);
18711907
}
1908+
#endif
18721909

1910+
#ifndef ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR
18731911
size_t ZSTD_compressBlock_greedy_dictMatchState_row(
18741912
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
18751913
void const* src, size_t srcSize)
18761914
{
18771915
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_rowHash, 0, ZSTD_dictMatchState);
18781916
}
1917+
#endif
18791918

1880-
1919+
#ifndef ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR
18811920
size_t ZSTD_compressBlock_lazy2_dedicatedDictSearch_row(
18821921
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
18831922
void const* src, size_t srcSize)
18841923
{
18851924
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_rowHash, 2, ZSTD_dedicatedDictSearch);
18861925
}
1926+
#endif
18871927

1928+
#ifndef ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR
18881929
size_t ZSTD_compressBlock_lazy_dedicatedDictSearch_row(
18891930
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
18901931
void const* src, size_t srcSize)
18911932
{
18921933
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_rowHash, 1, ZSTD_dedicatedDictSearch);
18931934
}
1935+
#endif
18941936

1937+
#ifndef ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR
18951938
size_t ZSTD_compressBlock_greedy_dedicatedDictSearch_row(
18961939
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
18971940
void const* src, size_t srcSize)
18981941
{
18991942
return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, search_rowHash, 0, ZSTD_dedicatedDictSearch);
19001943
}
1944+
#endif
19011945

1946+
#if !defined(ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR) \
1947+
|| !defined(ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR) \
1948+
|| !defined(ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR) \
1949+
|| !defined(ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR)
19021950
FORCE_INLINE_TEMPLATE
19031951
size_t ZSTD_compressBlock_lazy_extDict_generic(
19041952
ZSTD_matchState_t* ms, seqStore_t* seqStore,
@@ -2101,57 +2149,71 @@ size_t ZSTD_compressBlock_lazy_extDict_generic(
21012149
/* Return the last literals size */
21022150
return (size_t)(iend - anchor);
21032151
}
2152+
#endif /* build exclusions */
21042153

2105-
2154+
#ifndef ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR
21062155
size_t ZSTD_compressBlock_greedy_extDict(
21072156
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
21082157
void const* src, size_t srcSize)
21092158
{
21102159
return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, search_hashChain, 0);
21112160
}
2161+
#endif
21122162

2163+
#ifndef ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR
21132164
size_t ZSTD_compressBlock_lazy_extDict(
21142165
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
21152166
void const* src, size_t srcSize)
21162167

21172168
{
21182169
return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, search_hashChain, 1);
21192170
}
2171+
#endif
21202172

2173+
#ifndef ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR
21212174
size_t ZSTD_compressBlock_lazy2_extDict(
21222175
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
21232176
void const* src, size_t srcSize)
21242177

21252178
{
21262179
return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, search_hashChain, 2);
21272180
}
2181+
#endif
21282182

2183+
#ifndef ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR
21292184
size_t ZSTD_compressBlock_btlazy2_extDict(
21302185
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
21312186
void const* src, size_t srcSize)
21322187

21332188
{
21342189
return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, search_binaryTree, 2);
21352190
}
2191+
#endif
21362192

2193+
#ifndef ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR
21372194
size_t ZSTD_compressBlock_greedy_extDict_row(
21382195
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
21392196
void const* src, size_t srcSize)
21402197
{
21412198
return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, search_rowHash, 0);
21422199
}
2200+
#endif
21432201

2202+
#ifndef ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR
21442203
size_t ZSTD_compressBlock_lazy_extDict_row(
21452204
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
21462205
void const* src, size_t srcSize)
21472206

21482207
{
21492208
return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, search_rowHash, 1);
21502209
}
2210+
#endif
21512211

2212+
#ifndef ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR
21522213
size_t ZSTD_compressBlock_lazy2_extDict_row(
21532214
ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
21542215
void const* src, size_t srcSize)
21552216
{
21562217
return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, search_rowHash, 2);
21572218
}
2219+
#endif

0 commit comments

Comments
 (0)