tools/testing/selftests/powerpc/nx-gzip/include/nx_dbg.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/nx-gzip/include/nx_dbg.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/nx-gzip/include/nx_dbg.h- Extension
.h- Size
- 2765 bytes
- Lines
- 96
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
sys/file.hstdint.hstdio.htime.hpthread.h
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#ifndef _NXU_DBG_H_
#define _NXU_DBG_H_
#include <sys/file.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include <pthread.h>
extern FILE * nx_gzip_log;
extern int nx_gzip_trace;
extern unsigned int nx_gzip_inflate_impl;
extern unsigned int nx_gzip_deflate_impl;
extern unsigned int nx_gzip_inflate_flags;
extern unsigned int nx_gzip_deflate_flags;
extern int nx_dbg;
pthread_mutex_t mutex_log;
#define nx_gzip_trace_enabled() (nx_gzip_trace & 0x1)
#define nx_gzip_hw_trace_enabled() (nx_gzip_trace & 0x2)
#define nx_gzip_sw_trace_enabled() (nx_gzip_trace & 0x4)
#define nx_gzip_gather_statistics() (nx_gzip_trace & 0x8)
#define nx_gzip_per_stream_stat() (nx_gzip_trace & 0x10)
#define prt(fmt, ...) do { \
pthread_mutex_lock(&mutex_log); \
flock(nx_gzip_log->_fileno, LOCK_EX); \
time_t t; struct tm *m; time(&t); m = localtime(&t); \
fprintf(nx_gzip_log, "[%04d/%02d/%02d %02d:%02d:%02d] " \
"pid %d: " fmt, \
(int)m->tm_year + 1900, (int)m->tm_mon+1, (int)m->tm_mday, \
(int)m->tm_hour, (int)m->tm_min, (int)m->tm_sec, \
(int)getpid(), ## __VA_ARGS__); \
fflush(nx_gzip_log); \
flock(nx_gzip_log->_fileno, LOCK_UN); \
pthread_mutex_unlock(&mutex_log); \
} while (0)
/* Use in case of an error */
#define prt_err(fmt, ...) do { if (nx_dbg >= 0) { \
prt("%s:%u: Error: "fmt, \
__FILE__, __LINE__, ## __VA_ARGS__); \
}} while (0)
/* Use in case of an warning */
#define prt_warn(fmt, ...) do { if (nx_dbg >= 1) { \
prt("%s:%u: Warning: "fmt, \
__FILE__, __LINE__, ## __VA_ARGS__); \
}} while (0)
/* Informational printouts */
#define prt_info(fmt, ...) do { if (nx_dbg >= 2) { \
prt("Info: "fmt, ## __VA_ARGS__); \
}} while (0)
/* Trace zlib wrapper code */
#define prt_trace(fmt, ...) do { if (nx_gzip_trace_enabled()) { \
prt("### "fmt, ## __VA_ARGS__); \
}} while (0)
/* Trace statistics */
#define prt_stat(fmt, ...) do { if (nx_gzip_gather_statistics()) { \
prt("### "fmt, ## __VA_ARGS__); \
}} while (0)
/* Trace zlib hardware implementation */
#define hw_trace(fmt, ...) do { \
if (nx_gzip_hw_trace_enabled()) \
fprintf(nx_gzip_log, "hhh " fmt, ## __VA_ARGS__); \
} while (0)
/* Trace zlib software implementation */
#define sw_trace(fmt, ...) do { \
if (nx_gzip_sw_trace_enabled()) \
fprintf(nx_gzip_log, "sss " fmt, ## __VA_ARGS__); \
} while (0)
/**
* str_to_num - Convert string into number and copy with endings like
* KiB for kilobyte
* MiB for megabyte
* GiB for gigabyte
*/
uint64_t str_to_num(char *str);
void nx_lib_debug(int onoff);
#endif /* _NXU_DBG_H_ */
Annotation
- Immediate include surface: `sys/file.h`, `stdint.h`, `stdio.h`, `time.h`, `pthread.h`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.