tools/testing/selftests/bpf/prog_tests/reg_bounds.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/reg_bounds.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/reg_bounds.c- Extension
.c- Size
- 69473 bytes
- Lines
- 2313
- 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
limits.htest_progs.hlinux/filter.hlinux/bpf.h
Detected Declarations
struct strbufstruct rangestruct reg_statestruct case_specstruct ctxstruct subtest_caseenum num_tenum opfunction snappendffunction min_tfunction max_tfunction cast_tfunction t_is_32function t_signedfunction t_unsignedfunction num_is_smallfunction snprintf_numfunction snprintf_rangefunction print_rangefunction unkn_subregfunction rangefunction sign64function sign32function upper32function swap_low32function range_eqfunction range_cast_to_s32function range_cast_u64function range_cast_s64function range_cast_u32function range_cast_s32function range_castfunction is_valid_numfunction is_valid_rangefunction range_intersectionfunction range_unionfunction range_castfunction next_u32_blockfunction prev_u32_blockfunction u64_range_containsfunction u32_range_containsfunction range64_range32_intersectfunction range_refinefunction complement_opfunction OPfunction OPfunction OPfunction range_branch_taken_op
Annotated Snippet
struct strbuf {
size_t buf_sz;
int pos;
char buf[0];
};
#define DEFINE_STRBUF(name, N) \
struct { struct strbuf buf; char data[(N)]; } ___##name; \
struct strbuf *name = (___##name.buf.buf_sz = (N), ___##name.buf.pos = 0, &___##name.buf)
__printf(2, 3)
static inline void snappendf(struct strbuf *s, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
s->pos += vsnprintf(s->buf + s->pos,
s->pos < s->buf_sz ? s->buf_sz - s->pos : 0,
fmt, args);
va_end(args);
}
/* ==================================
* GENERIC NUMBER TYPE AND OPERATIONS
* ==================================
*/
enum num_t { U64, first_t = U64, U32, S64, S32, last_t = S32 };
static __always_inline u64 min_t(enum num_t t, u64 x, u64 y)
{
switch (t) {
case U64: return (u64)x < (u64)y ? (u64)x : (u64)y;
case U32: return (u32)x < (u32)y ? (u32)x : (u32)y;
case S64: return (s64)x < (s64)y ? (s64)x : (s64)y;
case S32: return (s32)x < (s32)y ? (s32)x : (s32)y;
default: printf("min_t!\n"); exit(1);
}
}
static __always_inline u64 max_t(enum num_t t, u64 x, u64 y)
{
switch (t) {
case U64: return (u64)x > (u64)y ? (u64)x : (u64)y;
case U32: return (u32)x > (u32)y ? (u32)x : (u32)y;
case S64: return (s64)x > (s64)y ? (s64)x : (s64)y;
case S32: return (s32)x > (s32)y ? (u32)(s32)x : (u32)(s32)y;
default: printf("max_t!\n"); exit(1);
}
}
static __always_inline u64 cast_t(enum num_t t, u64 x)
{
switch (t) {
case U64: return (u64)x;
case U32: return (u32)x;
case S64: return (s64)x;
case S32: return (u32)(s32)x;
default: printf("cast_t!\n"); exit(1);
}
}
static const char *t_str(enum num_t t)
{
switch (t) {
case U64: return "u64";
case U32: return "u32";
case S64: return "s64";
case S32: return "s32";
default: printf("t_str!\n"); exit(1);
}
}
static enum num_t t_is_32(enum num_t t)
{
switch (t) {
case U64: return false;
case U32: return true;
case S64: return false;
case S32: return true;
default: printf("t_is_32!\n"); exit(1);
}
}
static enum num_t t_signed(enum num_t t)
{
switch (t) {
case U64: return S64;
case U32: return S32;
case S64: return S64;
case S32: return S32;
Annotation
- Immediate include surface: `limits.h`, `test_progs.h`, `linux/filter.h`, `linux/bpf.h`.
- Detected declarations: `struct strbuf`, `struct range`, `struct reg_state`, `struct case_spec`, `struct ctx`, `struct subtest_case`, `enum num_t`, `enum op`, `function snappendf`, `function min_t`.
- 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.