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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/x86/test_FCMOV.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
  2 #undef _GNU_SOURCE
  3 #define _GNU_SOURCE 1
  4 #undef __USE_GNU
  5 #define __USE_GNU 1
  6 #include <unistd.h>
  7 #include <stdlib.h>
  8 #include <string.h>
  9 #include <stdio.h>
 10 #include <signal.h>
 11 #include <sys/types.h>
 12 #include <sys/select.h>
 13 #include <sys/time.h>
 14 #include <sys/wait.h>
 15 
 16 #define TEST(insn) \
 17 long double __attribute__((noinline)) insn(long flags) \
 18 {                                               \
 19         long double out;                        \
 20         asm ("\n"                               \
 21         "       push    %1""\n"                 \
 22         "       popf""\n"                       \
 23         "       fldpi""\n"                      \
 24         "       fld1""\n"                       \
 25         "       " #insn " %%st(1), %%st" "\n"   \
 26         "       ffree   %%st(1)" "\n"           \
 27         : "=t" (out)                            \
 28         : "r" (flags)                           \
 29         );                                      \
 30         return out;                             \
 31 }
 32 
 33 TEST(fcmovb)
 34 TEST(fcmove)
 35 TEST(fcmovbe)
 36 TEST(fcmovu)
 37 TEST(fcmovnb)
 38 TEST(fcmovne)
 39 TEST(fcmovnbe)
 40 TEST(fcmovnu)
 41 
 42 enum {
 43         CF = 1 << 0,
 44         PF = 1 << 2,
 45         ZF = 1 << 6,
 46 };
 47 
 48 void sighandler(int sig)
 49 {
 50         printf("[FAIL]\tGot signal %d, exiting\n", sig);
 51         exit(1);
 52 }
 53 
 54 int main(int argc, char **argv, char **envp)
 55 {
 56         int err = 0;
 57 
 58         /* SIGILL triggers on 32-bit kernels w/o fcomi emulation
 59          * when run with "no387 nofxsr". Other signals are caught
 60          * just in case.
 61          */
 62         signal(SIGILL, sighandler);
 63         signal(SIGFPE, sighandler);
 64         signal(SIGSEGV, sighandler);
 65 
 66         printf("[RUN]\tTesting fcmovCC instructions\n");
 67         /* If fcmovCC() returns 1.0, the move wasn't done */
 68         err |= !(fcmovb(0)   == 1.0); err |= !(fcmovnb(0)  != 1.0);
 69         err |= !(fcmove(0)   == 1.0); err |= !(fcmovne(0)  != 1.0);
 70         err |= !(fcmovbe(0)  == 1.0); err |= !(fcmovnbe(0) != 1.0);
 71         err |= !(fcmovu(0)   == 1.0); err |= !(fcmovnu(0)  != 1.0);
 72 
 73         err |= !(fcmovb(CF)  != 1.0); err |= !(fcmovnb(CF)  == 1.0);
 74         err |= !(fcmove(CF)  == 1.0); err |= !(fcmovne(CF)  != 1.0);
 75         err |= !(fcmovbe(CF) != 1.0); err |= !(fcmovnbe(CF) == 1.0);
 76         err |= !(fcmovu(CF)  == 1.0); err |= !(fcmovnu(CF)  != 1.0);
 77 
 78         err |= !(fcmovb(ZF)  == 1.0); err |= !(fcmovnb(ZF)  != 1.0);
 79         err |= !(fcmove(ZF)  != 1.0); err |= !(fcmovne(ZF)  == 1.0);
 80         err |= !(fcmovbe(ZF) != 1.0); err |= !(fcmovnbe(ZF) == 1.0);
 81         err |= !(fcmovu(ZF)  == 1.0); err |= !(fcmovnu(ZF)  != 1.0);
 82 
 83         err |= !(fcmovb(PF)  == 1.0); err |= !(fcmovnb(PF)  != 1.0);
 84         err |= !(fcmove(PF)  == 1.0); err |= !(fcmovne(PF)  != 1.0);
 85         err |= !(fcmovbe(PF) == 1.0); err |= !(fcmovnbe(PF) != 1.0);
 86         err |= !(fcmovu(PF)  != 1.0); err |= !(fcmovnu(PF)  == 1.0);
 87 
 88         if (!err)
 89                 printf("[OK]\tfcmovCC\n");
 90         else
 91                 printf("[FAIL]\tfcmovCC errors: %d\n", err);
 92 
 93         return err;
 94 }
 95 

~ [ 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