~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/powerpc/math/fpu_syscall.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*
  3  * Copyright 2015, Cyril Bur, IBM Corp.
  4  *
  5  * This test attempts to see if the FPU registers change across a syscall (fork).
  6  */
  7 
  8 #include <stdio.h>
  9 #include <unistd.h>
 10 #include <sys/syscall.h>
 11 #include <sys/time.h>
 12 #include <sys/types.h>
 13 #include <sys/wait.h>
 14 #include <stdlib.h>
 15 
 16 #include "utils.h"
 17 #include "fpu.h"
 18 
 19 extern int test_fpu(double *darray, pid_t *pid);
 20 
 21 double darray[32];
 22 
 23 int syscall_fpu(void)
 24 {
 25         pid_t fork_pid;
 26         int i;
 27         int ret;
 28         int child_ret;
 29 
 30         randomise_darray(darray, ARRAY_SIZE(darray));
 31 
 32         for (i = 0; i < 1000; i++) {
 33                 /* test_fpu will fork() */
 34                 ret = test_fpu(darray, &fork_pid);
 35                 if (fork_pid == -1)
 36                         return -1;
 37                 if (fork_pid == 0)
 38                         exit(ret);
 39                 waitpid(fork_pid, &child_ret, 0);
 40                 if (ret || child_ret)
 41                         return 1;
 42         }
 43 
 44         return 0;
 45 }
 46 
 47 int test_syscall_fpu(void)
 48 {
 49         /*
 50          * Setup an environment with much context switching
 51          */
 52         pid_t pid2;
 53         pid_t pid = fork();
 54         int ret;
 55         int child_ret;
 56         FAIL_IF(pid == -1);
 57 
 58         pid2 = fork();
 59         /* Can't FAIL_IF(pid2 == -1); because already forked once */
 60         if (pid2 == -1) {
 61                 /*
 62                  * Couldn't fork, ensure test is a fail
 63                  */
 64                 child_ret = ret = 1;
 65         } else {
 66                 ret = syscall_fpu();
 67                 if (pid2)
 68                         waitpid(pid2, &child_ret, 0);
 69                 else
 70                         exit(ret);
 71         }
 72 
 73         ret |= child_ret;
 74 
 75         if (pid)
 76                 waitpid(pid, &child_ret, 0);
 77         else
 78                 exit(ret);
 79 
 80         FAIL_IF(ret || child_ret);
 81         return 0;
 82 }
 83 
 84 int main(int argc, char *argv[])
 85 {
 86         return test_harness(test_syscall_fpu, "syscall_fpu");
 87 
 88 }
 89 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php