tools/testing/selftests/bpf/progs/iters_num.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/iters_num.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/iters_num.c- Extension
.c- Size
- 4285 bytes
- Lines
- 243
- 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.hlinux/errno.hvmlinux.hbpf/bpf_helpers.hbpf_misc.h
Detected Declarations
function num_empty_zerofunction num_empty_int_minfunction num_empty_int_maxfunction num_empty_minus_onefunction num_simple_sumfunction num_neg_sumfunction num_very_neg_sumfunction num_very_big_sumfunction num_neg_pos_sumfunction num_invalid_rangefunction num_max_rangefunction num_e2big_rangefunction num_succ_elem_cntfunction num_overfetched_elem_cntfunction num_fail_elem_cnt
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2023 Meta Platforms, Inc. and affiliates. */
#include <limits.h>
#include <linux/errno.h>
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include "bpf_misc.h"
const volatile __s64 exp_empty_zero = 0 + 1;
__s64 res_empty_zero;
SEC("raw_tp/sys_enter")
int num_empty_zero(const void *ctx)
{
__s64 sum = 0, i;
bpf_for(i, 0, 0) sum += i;
res_empty_zero = 1 + sum;
return 0;
}
const volatile __s64 exp_empty_int_min = 0 + 2;
__s64 res_empty_int_min;
SEC("raw_tp/sys_enter")
int num_empty_int_min(const void *ctx)
{
__s64 sum = 0, i;
bpf_for(i, INT_MIN, INT_MIN) sum += i;
res_empty_int_min = 2 + sum;
return 0;
}
const volatile __s64 exp_empty_int_max = 0 + 3;
__s64 res_empty_int_max;
SEC("raw_tp/sys_enter")
int num_empty_int_max(const void *ctx)
{
__s64 sum = 0, i;
bpf_for(i, INT_MAX, INT_MAX) sum += i;
res_empty_int_max = 3 + sum;
return 0;
}
const volatile __s64 exp_empty_minus_one = 0 + 4;
__s64 res_empty_minus_one;
SEC("raw_tp/sys_enter")
int num_empty_minus_one(const void *ctx)
{
__s64 sum = 0, i;
bpf_for(i, -1, -1) sum += i;
res_empty_minus_one = 4 + sum;
return 0;
}
const volatile __s64 exp_simple_sum = 9 * 10 / 2;
__s64 res_simple_sum;
SEC("raw_tp/sys_enter")
int num_simple_sum(const void *ctx)
{
__s64 sum = 0, i;
bpf_for(i, 0, 10) sum += i;
res_simple_sum = sum;
return 0;
}
const volatile __s64 exp_neg_sum = -11 * 10 / 2;
__s64 res_neg_sum;
SEC("raw_tp/sys_enter")
int num_neg_sum(const void *ctx)
{
__s64 sum = 0, i;
bpf_for(i, -10, 0) sum += i;
res_neg_sum = sum;
Annotation
- Immediate include surface: `limits.h`, `linux/errno.h`, `vmlinux.h`, `bpf/bpf_helpers.h`, `bpf_misc.h`.
- Detected declarations: `function num_empty_zero`, `function num_empty_int_min`, `function num_empty_int_max`, `function num_empty_minus_one`, `function num_simple_sum`, `function num_neg_sum`, `function num_very_neg_sum`, `function num_very_big_sum`, `function num_neg_pos_sum`, `function num_invalid_range`.
- 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.