tools/testing/selftests/powerpc/stringloops/memcmp.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/stringloops/memcmp.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/stringloops/memcmp.c- Extension
.c- Size
- 3818 bytes
- Lines
- 170
- 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.
Dependency Surface
malloc.hstdlib.hstring.hsys/mman.htime.hutils.h
Detected Declarations
function enter_vmx_opsfunction exit_vmx_opsfunction test_onefunction testcasefunction testcasesfunction main
Annotated Snippet
if (vmx_count != 0) {
printf("vmx enter/exit not paired.(offset:%ld size:%ld s1:%p s2:%p vc:%d\n",
offset, size, s1, s2, vmx_count);
printf("\n");
abort();
}
}
}
}
static int testcase(bool islarge)
{
unsigned long i, comp_size, alloc_size;
char *p, *s1, *s2;
int iterations;
comp_size = (islarge ? LARGE_SIZE : SIZE);
alloc_size = comp_size + MAX_OFFSET_DIFF_S1_S2;
iterations = islarge ? LARGE_ITERATIONS : ITERATIONS;
p = mmap(NULL, 4 * MAP_SIZE, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
FAIL_IF(p == MAP_FAILED);
/* Put s1/s2 at the end of a page */
s1 = p + MAP_SIZE - alloc_size;
s2 = p + 3 * MAP_SIZE - alloc_size;
/* And unmap the subsequent page to force a fault if we overread */
munmap(p + MAP_SIZE, MAP_SIZE);
munmap(p + 3 * MAP_SIZE, MAP_SIZE);
srandom(time(0));
for (i = 0; i < iterations; i++) {
unsigned long j;
unsigned long change;
char *rand_s1 = s1;
char *rand_s2 = s2;
for (j = 0; j < alloc_size; j++)
s1[j] = random();
rand_s1 += random() % MAX_OFFSET_DIFF_S1_S2;
rand_s2 += random() % MAX_OFFSET_DIFF_S1_S2;
memcpy(rand_s2, rand_s1, comp_size);
/* change one byte */
change = random() % comp_size;
rand_s2[change] = random() & 0xff;
if (islarge)
test_one(rand_s1, rand_s2, LARGE_MAX_OFFSET,
LARGE_SIZE_START, comp_size);
else
test_one(rand_s1, rand_s2, SIZE, 0, comp_size);
}
srandom(time(0));
for (i = 0; i < iterations; i++) {
unsigned long j;
unsigned long change;
char *rand_s1 = s1;
char *rand_s2 = s2;
for (j = 0; j < alloc_size; j++)
s1[j] = random();
rand_s1 += random() % MAX_OFFSET_DIFF_S1_S2;
rand_s2 += random() % MAX_OFFSET_DIFF_S1_S2;
memcpy(rand_s2, rand_s1, comp_size);
/* change multiple bytes, 1/8 of total */
for (j = 0; j < comp_size / 8; j++) {
change = random() % comp_size;
s2[change] = random() & 0xff;
}
if (islarge)
test_one(rand_s1, rand_s2, LARGE_MAX_OFFSET,
LARGE_SIZE_START, comp_size);
else
test_one(rand_s1, rand_s2, SIZE, 0, comp_size);
}
return 0;
}
static int testcases(void)
Annotation
- Immediate include surface: `malloc.h`, `stdlib.h`, `string.h`, `sys/mman.h`, `time.h`, `utils.h`.
- Detected declarations: `function enter_vmx_ops`, `function exit_vmx_ops`, `function test_one`, `function testcase`, `function testcases`, `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.