tools/testing/selftests/powerpc/stringloops/strlen.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/stringloops/strlen.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/stringloops/strlen.c- Extension
.c- Size
- 1930 bytes
- Lines
- 128
- 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
malloc.hstdlib.hstring.htime.hutils.h
Detected Declarations
function test_onefunction bench_testfunction testcasefunction main
Annotated Snippet
if (x != y) {
printf("strlen() returned %d, should have returned %d (%p offset %ld)\n", x, y, s, offset);
for (i = offset; i < SIZE; i++)
printf("%02x ", s[i]);
printf("\n");
}
}
}
static void bench_test(char *s)
{
struct timespec ts_start, ts_end;
int i;
clock_gettime(CLOCK_MONOTONIC, &ts_start);
for (i = 0; i < ITERATIONS_BENCH; i++)
test_strlen(s);
clock_gettime(CLOCK_MONOTONIC, &ts_end);
printf("len %3.3d : time = %.6f\n", test_strlen(s), ts_end.tv_sec - ts_start.tv_sec + (ts_end.tv_nsec - ts_start.tv_nsec) / 1e9);
}
static int testcase(void)
{
char *s;
unsigned long i;
s = memalign(128, SIZE);
if (!s) {
perror("memalign");
exit(1);
}
srandom(1);
memset(s, 0, SIZE);
for (i = 0; i < SIZE; i++) {
char c;
do {
c = random() & 0x7f;
} while (!c);
s[i] = c;
test_one(s);
}
for (i = 0; i < ITERATIONS; i++) {
unsigned long j;
for (j = 0; j < SIZE; j++) {
char c;
do {
c = random() & 0x7f;
} while (!c);
s[j] = c;
}
for (j = 0; j < sizeof(long); j++) {
s[SIZE - 1 - j] = 0;
test_one(s);
}
}
for (i = 0; i < SIZE; i++) {
char c;
do {
c = random() & 0x7f;
} while (!c);
s[i] = c;
}
bench_test(s);
s[16] = 0;
bench_test(s);
s[8] = 0;
bench_test(s);
s[4] = 0;
bench_test(s);
s[3] = 0;
bench_test(s);
s[2] = 0;
Annotation
- Immediate include surface: `malloc.h`, `stdlib.h`, `string.h`, `time.h`, `utils.h`.
- Detected declarations: `function test_one`, `function bench_test`, `function testcase`, `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.