tools/testing/selftests/powerpc/nx-gzip/gzfht_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/nx-gzip/gzfht_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/nx-gzip/gzfht_test.c- Extension
.c- Size
- 10968 bytes
- Lines
- 399
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hstdlib.hstring.hunistd.hstdint.hsys/types.hsys/stat.hsys/time.hsys/fcntl.hsys/mman.hendian.hbits/endian.hsys/ioctl.hassert.herrno.hsignal.hutils.hnxu.hnx.h
Detected Declarations
function compress_fht_samplefunction gzip_header_blankfunction append_sync_flushfunction set_bfinalfunction compress_filefunction main
Annotated Snippet
if (cc == ERR_NX_AT_FAULT) {
NXPRT(fprintf(stderr, "page fault: cc= %d, ", cc));
NXPRT(fprintf(stderr, "try= %d, fsa= %08llx\n",
fault_tries,
(unsigned long long) cmdp->crb.csb.fsaddr));
fault_tries--;
if (fault_tries > 0) {
continue;
} else {
fprintf(stderr, "error: cannot progress; ");
fprintf(stderr, "too many faults\n");
exit(-1);
}
}
fault_tries = NX_MAX_FAULTS; /* Reset for the next chunk */
inlen = inlen - srclen;
srcbuf = srcbuf + srclen;
srctotlen = srctotlen + srclen;
/* Two possible locations for spbc depending on the function
* code.
*/
spbc = (!lzcounts) ? get32(cmdp->cpb, out_spbc_comp) :
get32(cmdp->cpb, out_spbc_comp_with_count);
assert(spbc == srclen);
/* Target byte count */
tpbc = get32(cmdp->crb.csb, tpbc);
/* Target ending bit count */
tebc = getnn(cmdp->cpb, out_tebc);
NXPRT(fprintf(stderr, "compressed chunk %d ", spbc));
NXPRT(fprintf(stderr, "to %d bytes, tebc= %d\n", tpbc, tebc));
if (inlen > 0) { /* More chunks to go */
set_bfinal(dstbuf, 0);
dstbuf = dstbuf + tpbc;
dsttotlen = dsttotlen + tpbc;
outlen = outlen - tpbc;
/* Round up to the next byte with a flush
* block; do not set the BFINAqL bit.
*/
flushlen = append_sync_flush(dstbuf, tebc, 0);
dsttotlen = dsttotlen + flushlen;
outlen = outlen - flushlen;
dstbuf = dstbuf + flushlen;
NXPRT(fprintf(stderr, "added sync_flush %d bytes\n",
flushlen));
} else { /* Done */
/* Set the BFINAL bit of the last block per Deflate
* specification.
*/
set_bfinal(dstbuf, 1);
dstbuf = dstbuf + tpbc;
dsttotlen = dsttotlen + tpbc;
outlen = outlen - tpbc;
}
/* Resuming crc32 for the next chunk */
crc = get32(cmdp->cpb, out_crc);
put32(cmdp->cpb, in_crc, crc);
crc = be32toh(crc);
}
/* Append crc32 and ISIZE to the end */
memcpy(dstbuf, &crc, 4);
memcpy(dstbuf+4, &srctotlen, 4);
dsttotlen = dsttotlen + 8;
outlen = outlen - 8;
assert(FNAME_MAX > (strlen(argv[1]) + strlen(FEXT)));
strcpy(outname, argv[1]);
strcat(outname, FEXT);
if (write_file(outname, outbuf, dsttotlen)) {
fprintf(stderr, "write error: %s\n", outname);
exit(-1);
}
fprintf(stderr, "compressed %ld to %ld bytes total, ", srctotlen,
dsttotlen);
fprintf(stderr, "crc32 checksum = %08x\n", crc);
if (inbuf != NULL)
free(inbuf);
if (outbuf != NULL)
free(outbuf);
return 0;
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `string.h`, `unistd.h`, `stdint.h`, `sys/types.h`, `sys/stat.h`, `sys/time.h`.
- Detected declarations: `function compress_fht_sample`, `function gzip_header_blank`, `function append_sync_flush`, `function set_bfinal`, `function compress_file`, `function main`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source 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.