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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/x86/test_FCMOV.c

Version: ~ [ linux-5.1-rc5 ] ~ [ linux-5.0.7 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.34 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.111 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.168 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.178 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.138 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.65 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ 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 | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp