lib/lz4/lz4hc_compress.c
Source file repositories/reference/linux-study-clean/lib/lz4/lz4hc_compress.c
File Facts
- System
- Linux kernel
- Corpus path
lib/lz4/lz4hc_compress.c- Extension
.c- Size
- 19128 bytes
- Lines
- 769
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
Dependency Surface
lz4defs.hlinux/module.hlinux/kernel.hlinux/string.h
Detected Declarations
function LZ4HC_hashPtrfunction LZ4HC_initfunction LZ4HC_Insertfunction LZ4HC_InsertAndFindBestMatchfunction LZ4HC_InsertAndGetWiderMatchfunction LZ4HC_encodeSequencefunction LZ4HC_compress_genericfunction LZ4_compress_HC_extStateHCfunction LZ4_compress_HCfunction LZ4_resetStreamHCfunction LZ4_loadDictHCfunction LZ4HC_setExternalDictfunction LZ4_compressHC_continue_genericfunction LZ4_compress_HC_continuefunction LZ4_saveDictHCexport LZ4_compress_HCexport LZ4_resetStreamHCexport LZ4_loadDictHCexport LZ4_compress_HC_continueexport LZ4_saveDictHC
Annotated Snippet
if (matchIndex >= dictLimit) {
const BYTE * const match = base + matchIndex;
if (*(match + ml) == *(ip + ml)
&& (LZ4_read32(match) == LZ4_read32(ip))) {
size_t const mlt = LZ4_count(ip + MINMATCH,
match + MINMATCH, iLimit) + MINMATCH;
if (mlt > ml) {
ml = mlt;
*matchpos = match;
}
}
} else {
const BYTE * const match = dictBase + matchIndex;
if (LZ4_read32(match) == LZ4_read32(ip)) {
size_t mlt;
const BYTE *vLimit = ip
+ (dictLimit - matchIndex);
if (vLimit > iLimit)
vLimit = iLimit;
mlt = LZ4_count(ip + MINMATCH,
match + MINMATCH, vLimit) + MINMATCH;
if ((ip + mlt == vLimit)
&& (vLimit < iLimit))
mlt += LZ4_count(ip + mlt,
base + dictLimit,
iLimit);
if (mlt > ml) {
/* virtual matchpos */
ml = mlt;
*matchpos = base + matchIndex;
}
}
}
matchIndex -= DELTANEXTU16(matchIndex);
}
return (int)ml;
}
static FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch(
LZ4HC_CCtx_internal *hc4,
const BYTE * const ip,
const BYTE * const iLowLimit,
const BYTE * const iHighLimit,
int longest,
const BYTE **matchpos,
const BYTE **startpos,
const int maxNbAttempts)
{
U16 * const chainTable = hc4->chainTable;
U32 * const HashTable = hc4->hashTable;
const BYTE * const base = hc4->base;
const U32 dictLimit = hc4->dictLimit;
const BYTE * const lowPrefixPtr = base + dictLimit;
const U32 lowLimit = (hc4->lowLimit + 64 * KB > (U32)(ip - base))
? hc4->lowLimit
: (U32)(ip - base) - (64 * KB - 1);
const BYTE * const dictBase = hc4->dictBase;
U32 matchIndex;
int nbAttempts = maxNbAttempts;
int delta = (int)(ip - iLowLimit);
/* First Match */
LZ4HC_Insert(hc4, ip);
matchIndex = HashTable[LZ4HC_hashPtr(ip)];
while ((matchIndex >= lowLimit)
&& (nbAttempts)) {
nbAttempts--;
if (matchIndex >= dictLimit) {
const BYTE *matchPtr = base + matchIndex;
if (*(iLowLimit + longest)
== *(matchPtr - delta + longest)) {
if (LZ4_read32(matchPtr) == LZ4_read32(ip)) {
int mlt = MINMATCH + LZ4_count(
ip + MINMATCH,
matchPtr + MINMATCH,
iHighLimit);
int back = 0;
while ((ip + back > iLowLimit)
&& (matchPtr + back > lowPrefixPtr)
&& (ip[back - 1] == matchPtr[back - 1]))
back--;
Annotation
- Immediate include surface: `lz4defs.h`, `linux/module.h`, `linux/kernel.h`, `linux/string.h`.
- Detected declarations: `function LZ4HC_hashPtr`, `function LZ4HC_init`, `function LZ4HC_Insert`, `function LZ4HC_InsertAndFindBestMatch`, `function LZ4HC_InsertAndGetWiderMatch`, `function LZ4HC_encodeSequence`, `function LZ4HC_compress_generic`, `function LZ4_compress_HC_extStateHC`, `function LZ4_compress_HC`, `function LZ4_resetStreamHC`.
- Atlas domain: Kernel Services / lib.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.