x86/mm: Remove preempt_disable/enable() from __native_flush_tlb()
[linux/fpc-iii.git] / tools / testing / selftests / powerpc / math / fpu_syscall.c
blob949e6721256d9fa1f106dce7cbd7f96f78e14e18
1 /*
2 * Copyright 2015, Cyril Bur, IBM Corp.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * This test attempts to see if the FPU registers change across a syscall (fork).
12 #include <stdio.h>
13 #include <unistd.h>
14 #include <sys/syscall.h>
15 #include <sys/time.h>
16 #include <sys/types.h>
17 #include <sys/wait.h>
18 #include <stdlib.h>
20 #include "utils.h"
22 extern int test_fpu(double *darray, pid_t *pid);
24 double darray[] = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0,
25 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0,
26 2.1};
28 int syscall_fpu(void)
30 pid_t fork_pid;
31 int i;
32 int ret;
33 int child_ret;
34 for (i = 0; i < 1000; i++) {
35 /* test_fpu will fork() */
36 ret = test_fpu(darray, &fork_pid);
37 if (fork_pid == -1)
38 return -1;
39 if (fork_pid == 0)
40 exit(ret);
41 waitpid(fork_pid, &child_ret, 0);
42 if (ret || child_ret)
43 return 1;
46 return 0;
49 int test_syscall_fpu(void)
52 * Setup an environment with much context switching
54 pid_t pid2;
55 pid_t pid = fork();
56 int ret;
57 int child_ret;
58 FAIL_IF(pid == -1);
60 pid2 = fork();
61 /* Can't FAIL_IF(pid2 == -1); because already forked once */
62 if (pid2 == -1) {
64 * Couldn't fork, ensure test is a fail
66 child_ret = ret = 1;
67 } else {
68 ret = syscall_fpu();
69 if (pid2)
70 waitpid(pid2, &child_ret, 0);
71 else
72 exit(ret);
75 ret |= child_ret;
77 if (pid)
78 waitpid(pid, &child_ret, 0);
79 else
80 exit(ret);
82 FAIL_IF(ret || child_ret);
83 return 0;
86 int main(int argc, char *argv[])
88 return test_harness(test_syscall_fpu, "syscall_fpu");