tools/testing/selftests/powerpc/math/fpu_signal.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/math/fpu_signal.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/math/fpu_signal.c- Extension
.c- Size
- 2825 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
stdio.hunistd.hsys/syscall.hsys/time.hsys/types.hsys/wait.hstdlib.hpthread.hutils.hfpu.h
Detected Declarations
function signal_fpu_sigfunction test_signal_fpufunction main
Annotated Snippet
if (mc->fp_regs[i] != darray[i]) {
bad_context = true;
break;
}
}
}
void *signal_fpu_c(void *p)
{
long rc;
struct sigaction act;
act.sa_sigaction = signal_fpu_sig;
act.sa_flags = SA_SIGINFO;
rc = sigaction(SIGUSR1, &act, NULL);
if (rc)
return p;
srand(pthread_self());
randomise_darray(darray, ARRAY_SIZE(darray));
rc = preempt_fpu(darray, &threads_starting, &running);
return (void *) rc;
}
int test_signal_fpu(void)
{
int i, j, rc, threads;
void *rc_p;
pthread_t *tids;
threads = sysconf(_SC_NPROCESSORS_ONLN) * THREAD_FACTOR;
tids = malloc(threads * sizeof(pthread_t));
FAIL_IF(!tids);
running = true;
threads_starting = threads;
for (i = 0; i < threads; i++) {
rc = pthread_create(&tids[i], NULL, signal_fpu_c, NULL);
FAIL_IF(rc);
}
setbuf(stdout, NULL);
printf("\tWaiting for all workers to start...");
while (threads_starting)
asm volatile("": : :"memory");
printf("done\n");
printf("\tSending signals to all threads %d times...", ITERATIONS);
for (i = 0; i < ITERATIONS; i++) {
for (j = 0; j < threads; j++) {
pthread_kill(tids[j], SIGUSR1);
}
sleep(1);
}
printf("done\n");
printf("\tStopping workers...");
running = 0;
for (i = 0; i < threads; i++) {
pthread_join(tids[i], &rc_p);
/*
* Harness will say the fail was here, look at why signal_fpu
* returned
*/
if ((long) rc_p || bad_context)
printf("oops\n");
if (bad_context)
fprintf(stderr, "\t!! bad_context is true\n");
FAIL_IF((long) rc_p || bad_context);
}
printf("done\n");
free(tids);
return 0;
}
int main(int argc, char *argv[])
{
return test_harness(test_signal_fpu, "fpu_signal");
}
Annotation
- Immediate include surface: `stdio.h`, `unistd.h`, `sys/syscall.h`, `sys/time.h`, `sys/types.h`, `sys/wait.h`, `stdlib.h`, `pthread.h`.
- Detected declarations: `function signal_fpu_sig`, `function test_signal_fpu`, `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.