1#ifndef FLOAT
2#define FLOAT double
3#endif
4
5void
6test_isunordered(FLOAT x, FLOAT y, int true)
7{
8  if (__builtin_isunordered(x, y))
9    {
10      if (! true)
11	abort ();
12    }
13  else
14    {
15      if (true)
16	abort ();
17    }
18}
19
20void
21test_isless(FLOAT x, FLOAT y, int true)
22{
23  if (__builtin_isless(x, y))
24    {
25      if (! true)
26	abort ();
27    }
28  else
29    {
30      if (true)
31	abort ();
32    }
33}
34
35void
36test_islessequal(FLOAT x, FLOAT y, int true)
37{
38  if (__builtin_islessequal(x, y))
39    {
40      if (! true)
41	abort ();
42    }
43  else
44    {
45      if (true)
46	abort ();
47    }
48}
49
50void
51test_isgreater(FLOAT x, FLOAT y, int true)
52{
53  if (__builtin_isgreater(x, y))
54    {
55      if (! true)
56	abort ();
57    }
58  else
59    {
60      if (true)
61	abort ();
62    }
63}
64
65void
66test_isgreaterequal(FLOAT x, FLOAT y, int true)
67{
68  if (__builtin_isgreaterequal(x, y))
69    {
70      if (! true)
71	abort ();
72    }
73  else
74    {
75      if (true)
76	abort ();
77    }
78}
79
80void
81test_islessgreater(FLOAT x, FLOAT y, int true)
82{
83  if (__builtin_islessgreater(x, y))
84    {
85      if (! true)
86	abort ();
87    }
88  else
89    {
90      if (true)
91	abort ();
92    }
93}
94
95#define NAN (0.0 / 0.0)
96
97int
98main()
99{
100  struct try
101  {
102    FLOAT x, y;
103    unsigned unord : 1;
104    unsigned lt : 1;
105    unsigned le : 1;
106    unsigned gt : 1;
107    unsigned ge : 1;
108    unsigned lg : 1;
109  };
110
111  static struct try const data[] =
112  {
113    { NAN, NAN, 1, 0, 0, 0, 0, 0 },
114    { 0.0, NAN, 1, 0, 0, 0, 0, 0 },
115    { NAN, 0.0, 1, 0, 0, 0, 0, 0 },
116    { 0.0, 0.0, 0, 0, 1, 0, 1, 0 },
117    { 1.0, 2.0, 0, 1, 1, 0, 0, 1 },
118    { 2.0, 1.0, 0, 0, 0, 1, 1, 1 },
119  };
120
121  const int n = sizeof(data) / sizeof(data[0]);
122  int i;
123
124  for (i = 0; i < n; ++i)
125    {
126      test_isunordered (data[i].x, data[i].y, data[i].unord);
127      test_isless (data[i].x, data[i].y, data[i].lt);
128      test_islessequal (data[i].x, data[i].y, data[i].le);
129      test_isgreater (data[i].x, data[i].y, data[i].gt);
130      test_isgreaterequal (data[i].x, data[i].y, data[i].ge);
131      test_islessgreater (data[i].x, data[i].y, data[i].lg);
132    }
133
134  exit (0);
135}
136