lib/lz4/lz4_compress.c
Source file repositories/reference/linux-study-clean/lib/lz4/lz4_compress.c
File Facts
- System
- Linux kernel
- Corpus path
lib/lz4/lz4_compress.c- Extension
.c- Size
- 23363 bytes
- Lines
- 940
- 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/unaligned.h
Detected Declarations
function LZ4_hash4function LZ4_hash5function LZ4_hashPositionfunction LZ4_putPositionOnHashfunction LZ4_putPositionfunction LZ4_compress_genericfunction LZ4_compress_fast_extStatefunction LZ4_compress_fastfunction LZ4_compress_defaultfunction LZ4_compress_destSize_genericfunction LZ4_compress_destSize_extStatefunction LZ4_compress_destSizefunction LZ4_resetStreamfunction LZ4_loadDictfunction LZ4_renormDictTfunction LZ4_saveDictfunction LZ4_compress_fast_continueexport LZ4_compress_fastexport LZ4_compress_defaultexport LZ4_compress_destSizeexport LZ4_loadDictexport LZ4_saveDictexport LZ4_compress_fast_continue
Annotated Snippet
if (dict == usingExtDict) {
if (match < (const BYTE *)source) {
refDelta = dictDelta;
lowLimit = dictionary;
} else {
refDelta = 0;
lowLimit = (const BYTE *)source;
} }
forwardH = LZ4_hashPosition(forwardIp,
tableType);
LZ4_putPositionOnHash(ip, h, dictPtr->hashTable,
tableType, base);
} while (((dictIssue == dictSmall)
? (match < lowRefLimit)
: 0)
|| ((tableType == byU16)
? 0
: (match + MAX_DISTANCE < ip))
|| (LZ4_read32(match + refDelta)
!= LZ4_read32(ip)));
}
/* Catch up */
while (((ip > anchor) & (match + refDelta > lowLimit))
&& (unlikely(ip[-1] == match[refDelta - 1]))) {
ip--;
match--;
}
/* Encode Literals */
{
unsigned const int litLength = (unsigned int)(ip - anchor);
token = op++;
if ((outputLimited) &&
/* Check output buffer overflow */
(unlikely(op + litLength +
(2 + 1 + LASTLITERALS) +
(litLength / 255) > olimit)))
return 0;
if (litLength >= RUN_MASK) {
int len = (int)litLength - RUN_MASK;
*token = (RUN_MASK << ML_BITS);
for (; len >= 255; len -= 255)
*op++ = 255;
*op++ = (BYTE)len;
} else
*token = (BYTE)(litLength << ML_BITS);
/* Copy Literals */
LZ4_wildCopy(op, anchor, op + litLength);
op += litLength;
}
_next_match:
/* Encode Offset */
LZ4_writeLE16(op, (U16)(ip - match));
op += 2;
/* Encode MatchLength */
{
unsigned int matchCode;
if ((dict == usingExtDict)
&& (lowLimit == dictionary)) {
const BYTE *limit;
match += refDelta;
limit = ip + (dictEnd - match);
if (limit > matchlimit)
limit = matchlimit;
matchCode = LZ4_count(ip + MINMATCH,
match + MINMATCH, limit);
ip += MINMATCH + matchCode;
if (ip == limit) {
unsigned const int more = LZ4_count(ip,
(const BYTE *)source,
matchlimit);
matchCode += more;
Annotation
- Immediate include surface: `lz4defs.h`, `linux/module.h`, `linux/kernel.h`, `linux/unaligned.h`.
- Detected declarations: `function LZ4_hash4`, `function LZ4_hash5`, `function LZ4_hashPosition`, `function LZ4_putPositionOnHash`, `function LZ4_putPosition`, `function LZ4_compress_generic`, `function LZ4_compress_fast_extState`, `function LZ4_compress_fast`, `function LZ4_compress_default`, `function LZ4_compress_destSize_generic`.
- 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.