Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/ieee/mzero3.c

raw
1 /* Copyright (C) 2002 Free Software Foundation.
2 by Hans-Peter Nilsson <[email protected]>, derived from mzero2.c
3
4 In the MMIX port, negdf2 was bogusly expanding -x into 0 - x. */
5
6 void abort (void);
7 void exit (int);
8
9 double nzerod = -0.0;
10 float nzerof = -0.0;
11 double zerod = 0.0;
12 float zerof = 0.0;
13
14 void expectd (double, double);
15 void expectf (float, float);
16 double negd (double);
17 float negf (float);
18
19 int
20 main (void)
21 {
22 expectd (negd (zerod), nzerod);
23 expectf (negf (zerof), nzerof);
24 expectd (negd (nzerod), zerod);
25 expectf (negf (nzerof), zerof);
26 exit (0);
27 }
28
29 void
30 expectd (double value, double expected)
31 {
32 if (value != expected
33 || __builtin_memcmp ((void *)&value, (void *) &expected,
34 sizeof (double)) != 0)
35 abort ();
36 }
37
38 void
39 expectf (float value, float expected)
40 {
41 if (value != expected
42 || __builtin_memcmp ((void *)&value, (void *) &expected,
43 sizeof (float)) != 0)
44 abort ();
45 }
46
47 double
48 negd (double v)
49 {
50 return -v;
51 }
52
53 float
54 negf (float v)
55 {
56 return -v;
57 }