drd/tests/swapcontext: Improve the portability of this test further
[valgrind.git] / none / tests / x86 / fxtract.c
blobf8c9bc41a32bbc5ff60822dbb255e34d461891db
1 #include "tests/asm.h"
2 #include <stdio.h>
3 #include <math.h>
5 double arg, res1, res2;
7 extern void do_fxtract ( void );
8 asm("\n"
9 ".text\n"
10 VG_SYM(do_fxtract) ":\n"
11 "\tfinit\n"
12 "\tfldl " VG_SYM(arg) "\n"
13 "\tfxtract\n"
14 "\tfstpl " VG_SYM(res1) "\n"
15 "\tfstpl " VG_SYM(res2) "\n"
16 "\tret\n"
17 ".previous\n"
20 void try ( double x )
22 arg = x * 1.414213562373049;
23 res1 = res2 = 0.0;
24 do_fxtract();
25 printf("%17.10e -> %14.10f %14.10f\n", arg, res1, res2);
28 int main ( void )
30 int i;
32 /* positives */
34 for (i = 0; i < 40; i++)
35 try( 1.27 + (double)(i*10 - 200) );
37 try(+0.0);
38 try(1.0 / 0.0);
39 try(sqrt(-1.0));
41 try(5.1e-308);
42 try(4.1e-308);
43 try(3.1e-308);
44 try(2.1e-308);
45 try(1.1e-308);
46 try(0.9e-308);
47 try(0.7e-308);
48 try(0.6e-308);
49 try(0.5e-308);
50 try(0.4e-308);
51 try(0.3e-308);
52 try(0.1e-308);
54 try(1.3e-320);
55 try(1.3e-321);
56 try(1.3e-322);
57 try(1.3e-323);
58 try(0.9e-323);
59 try(0.7e-323);
60 try(0.5e-323);
61 try(0.3e-323);
62 try(0.2e-323);
63 try(1.3e-324);
65 /* negatives */
67 printf("\n");
68 for (i = 0; i < 40; i++)
69 try( - (1.27 + (double)(i*10 - 200)) );
71 try(-0.0);
72 try(-(1.0 / 0.0));
73 try(-sqrt(-1.0));
75 try(-5.1e-308);
76 try(-4.1e-308);
77 try(-3.1e-308);
78 try(-2.1e-308);
79 try(-1.1e-308);
80 try(-0.9e-308);
81 try(-0.7e-308);
82 try(-0.6e-308);
83 try(-0.5e-308);
84 try(-0.4e-308);
85 try(-0.3e-308);
86 try(-0.1e-308);
88 try(-1.3e-320);
89 try(-1.3e-321);
90 try(-1.3e-322);
91 try(-1.3e-323);
92 try(-0.9e-323);
93 try(-0.7e-323);
94 try(-0.5e-323);
95 try(-0.3e-323);
96 try(-0.2e-323);
97 try(-1.3e-324);
99 return 0;