t_fe_round.c revision 1.16 1 1.1 maya /*
2 1.1 maya * Written by Maya Rashish <maya (at) NetBSD.org>
3 1.1 maya * Public domain.
4 1.1 maya *
5 1.1 maya * Testing IEEE-754 rounding modes (and lrint)
6 1.1 maya */
7 1.1 maya
8 1.1 maya #include <atf-c.h>
9 1.1 maya #include <fenv.h>
10 1.1 maya #ifdef __HAVE_FENV
11 1.1 maya #include <math.h>
12 1.12 kre #include <stdint.h>
13 1.1 maya #include <stdio.h>
14 1.1 maya #include <stdlib.h>
15 1.1 maya
16 1.1 maya /*#pragma STDC FENV_ACCESS ON gcc?? */
17 1.1 maya
18 1.1 maya #define INT 9223L
19 1.1 maya
20 1.1 maya #define EPSILON 0.001
21 1.1 maya
22 1.10 riastrad static const char *
23 1.10 riastrad rmname(int rm)
24 1.10 riastrad {
25 1.10 riastrad switch (rm) {
26 1.10 riastrad case FE_TOWARDZERO:
27 1.10 riastrad return "FE_TOWARDZERO";
28 1.10 riastrad case FE_DOWNWARD:
29 1.10 riastrad return "FE_DOWNWARD";
30 1.10 riastrad case FE_UPWARD:
31 1.10 riastrad return "FE_UPWARD";
32 1.10 riastrad case FE_TONEAREST:
33 1.10 riastrad return "FE_TONEAREST";
34 1.10 riastrad default:
35 1.10 riastrad return "unknown";
36 1.10 riastrad }
37 1.10 riastrad }
38 1.10 riastrad
39 1.1 maya static const struct {
40 1.1 maya int round_mode;
41 1.1 maya double input;
42 1.1 maya long int expected;
43 1.1 maya } values[] = {
44 1.16 riastrad { FE_DOWNWARD, 3.75, 3},
45 1.16 riastrad { FE_DOWNWARD, -3.75, -4},
46 1.16 riastrad { FE_DOWNWARD, +0., 0},
47 1.16 riastrad { FE_DOWNWARD, -INT-0.0625, -INT-1},
48 1.16 riastrad { FE_DOWNWARD, +INT-0.0625, INT-1},
49 1.16 riastrad { FE_DOWNWARD, -INT+0.0625, -INT},
50 1.16 riastrad { FE_DOWNWARD, +INT+0.0625, INT},
51 1.1 maya #if 0 /* cpu bugs? */
52 1.16 riastrad { FE_DOWNWARD, -0., -1},
53 1.1 maya
54 1.16 riastrad { FE_UPWARD, +0., 1},
55 1.1 maya #endif
56 1.16 riastrad { FE_UPWARD, -0., 0},
57 1.16 riastrad { FE_UPWARD, -123.75, -123},
58 1.16 riastrad { FE_UPWARD, 123.75, 124},
59 1.16 riastrad { FE_UPWARD, -INT-0.0625, -INT},
60 1.16 riastrad { FE_UPWARD, +INT-0.0625, INT},
61 1.16 riastrad { FE_UPWARD, -INT+0.0625, -INT+1},
62 1.16 riastrad { FE_UPWARD, +INT+0.0625, INT+1},
63 1.16 riastrad
64 1.16 riastrad { FE_TOWARDZERO, 1.9375, 1},
65 1.16 riastrad { FE_TOWARDZERO, -1.9375, -1},
66 1.16 riastrad { FE_TOWARDZERO, 0.25, 0},
67 1.16 riastrad { FE_TOWARDZERO, INT+0.0625, INT},
68 1.16 riastrad { FE_TOWARDZERO, INT-0.0625, INT - 1},
69 1.16 riastrad { FE_TOWARDZERO, -INT+0.0625, -INT + 1},
70 1.16 riastrad { FE_TOWARDZERO, +0., 0},
71 1.16 riastrad { FE_TOWARDZERO, -0., 0},
72 1.16 riastrad
73 1.16 riastrad { FE_TONEAREST, -INT-0.0625, -INT},
74 1.16 riastrad { FE_TONEAREST, +INT-0.0625, INT},
75 1.16 riastrad { FE_TONEAREST, -INT+0.0625, -INT},
76 1.16 riastrad { FE_TONEAREST, +INT+0.0625, INT},
77 1.16 riastrad { FE_TONEAREST, -INT-0.53125, -INT-1},
78 1.16 riastrad { FE_TONEAREST, +INT-0.53125, INT-1},
79 1.16 riastrad { FE_TONEAREST, -INT+0.53125, -INT+1},
80 1.16 riastrad { FE_TONEAREST, +INT+0.53125, INT+1},
81 1.16 riastrad { FE_TONEAREST, +0., 0},
82 1.16 riastrad { FE_TONEAREST, -0., 0},
83 1.1 maya };
84 1.1 maya
85 1.16 riastrad ATF_TC(fe_lrint);
86 1.16 riastrad ATF_TC_HEAD(fe_lrint, tc)
87 1.1 maya {
88 1.16 riastrad atf_tc_set_md_var(tc, "descr",
89 1.16 riastrad "Checking IEEE 754 rounding modes using lrint(3)");
90 1.1 maya }
91 1.1 maya
92 1.16 riastrad ATF_TC_BODY(fe_lrint, tc)
93 1.1 maya {
94 1.16 riastrad enum {
95 1.16 riastrad LLRINT,
96 1.16 riastrad LLRINTF,
97 1.16 riastrad LRINT,
98 1.16 riastrad LRINTF,
99 1.16 riastrad N_FN,
100 1.16 riastrad } fn;
101 1.16 riastrad static const char *const fnname[] = {
102 1.16 riastrad [LLRINT] = "llrint",
103 1.16 riastrad [LLRINTF] = "llrintf",
104 1.16 riastrad [LRINT] = "lrint",
105 1.16 riastrad [LRINTF] = "lrintf",
106 1.16 riastrad };
107 1.1 maya long int received;
108 1.16 riastrad unsigned i;
109 1.1 maya
110 1.16 riastrad for (i = 0; i < __arraycount(values); i++) {
111 1.16 riastrad for (fn = 0; fn < N_FN; fn++) {
112 1.16 riastrad /*
113 1.16 riastrad * Set the requested rounding mode.
114 1.16 riastrad */
115 1.16 riastrad fesetround(values[i].round_mode);
116 1.16 riastrad
117 1.16 riastrad /*
118 1.16 riastrad * Call the lrint(3)-family function.
119 1.16 riastrad */
120 1.16 riastrad switch (fn) {
121 1.16 riastrad case LLRINT:
122 1.16 riastrad received = llrint(values[i].input);
123 1.16 riastrad break;
124 1.16 riastrad case LLRINTF:
125 1.16 riastrad received = llrintf(values[i].input);
126 1.16 riastrad break;
127 1.16 riastrad case LRINT:
128 1.16 riastrad received = lrint(values[i].input);
129 1.16 riastrad break;
130 1.16 riastrad case LRINTF:
131 1.16 riastrad received = lrintf(values[i].input);
132 1.16 riastrad break;
133 1.16 riastrad default:
134 1.16 riastrad atf_tc_fail("impossible");
135 1.16 riastrad }
136 1.16 riastrad
137 1.16 riastrad /*
138 1.16 riastrad * Assuming the result we got has zero
139 1.16 riastrad * fractional part, casting to long int should
140 1.16 riastrad * have no rounding. Verify it matches the
141 1.16 riastrad * integer we expect.
142 1.16 riastrad */
143 1.16 riastrad ATF_CHECK_MSG((long int)received == values[i].expected,
144 1.16 riastrad "[%u] %s %s(%f): got %ld, expected %ld",
145 1.16 riastrad i, rmname(values[i].round_mode), fnname[fn],
146 1.16 riastrad values[i].input,
147 1.16 riastrad (long int)received, values[i].expected);
148 1.16 riastrad
149 1.16 riastrad /* Do we get the same rounding mode out? */
150 1.16 riastrad ATF_CHECK_MSG(fegetround() == values[i].round_mode,
151 1.16 riastrad "[%u] %s: set %d (%s), got %d (%s)",
152 1.16 riastrad i, fnname[fn],
153 1.16 riastrad values[i].round_mode, rmname(values[i].round_mode),
154 1.16 riastrad fegetround(), rmname(fegetround()));
155 1.16 riastrad }
156 1.1 maya }
157 1.1 maya }
158 1.1 maya
159 1.16 riastrad ATF_TC(fe_nearbyint_rint);
160 1.16 riastrad ATF_TC_HEAD(fe_nearbyint_rint, tc)
161 1.6 he {
162 1.10 riastrad atf_tc_set_md_var(tc, "descr",
163 1.16 riastrad "Checking IEEE 754 rounding modes using nearbyint/rint");
164 1.6 he }
165 1.6 he
166 1.16 riastrad ATF_TC_BODY(fe_nearbyint_rint, tc)
167 1.6 he {
168 1.16 riastrad enum {
169 1.16 riastrad NEARBYINT,
170 1.16 riastrad NEARBYINTF,
171 1.16 riastrad NEARBYINTL,
172 1.16 riastrad RINT,
173 1.16 riastrad RINTF,
174 1.16 riastrad RINTL,
175 1.16 riastrad N_FN,
176 1.16 riastrad } fn;
177 1.16 riastrad static const char *const fnname[] = {
178 1.16 riastrad [NEARBYINT] = "nearbyint",
179 1.16 riastrad [NEARBYINTF] = "nearbyintf",
180 1.16 riastrad [NEARBYINTL] = "nearbyintl",
181 1.16 riastrad [RINT] = "rint",
182 1.16 riastrad [RINTF] = "rintf",
183 1.16 riastrad [RINTL] = "rintl",
184 1.16 riastrad };
185 1.10 riastrad double received, ipart, fpart;
186 1.16 riastrad unsigned i;
187 1.6 he
188 1.16 riastrad for (i = 0; i < __arraycount(values); i++) {
189 1.16 riastrad for (fn = 0; fn < N_FN; fn++) {
190 1.16 riastrad bool expect_except =
191 1.16 riastrad values[i].input != (double)values[i].expected;
192 1.16 riastrad
193 1.16 riastrad /*
194 1.16 riastrad * Set the requested rounding mode.
195 1.16 riastrad */
196 1.16 riastrad fesetround(values[i].round_mode);
197 1.16 riastrad
198 1.16 riastrad /*
199 1.16 riastrad * Clear sticky floating-point exception bits
200 1.16 riastrad * so we can verify whether the FE_INEXACT
201 1.16 riastrad * exception is raised.
202 1.16 riastrad */
203 1.16 riastrad feclearexcept(FE_ALL_EXCEPT);
204 1.16 riastrad
205 1.16 riastrad /*
206 1.16 riastrad * Call the rint(3)-family function.
207 1.16 riastrad */
208 1.16 riastrad switch (fn) {
209 1.16 riastrad case NEARBYINT:
210 1.16 riastrad received = nearbyint(values[i].input);
211 1.16 riastrad expect_except = false;
212 1.16 riastrad break;
213 1.16 riastrad case NEARBYINTF:
214 1.16 riastrad received = nearbyintf(values[i].input);
215 1.16 riastrad expect_except = false;
216 1.16 riastrad break;
217 1.16 riastrad case NEARBYINTL:
218 1.16 riastrad received = nearbyintl(values[i].input);
219 1.16 riastrad expect_except = false;
220 1.16 riastrad break;
221 1.16 riastrad case RINT:
222 1.16 riastrad received = rint(values[i].input);
223 1.16 riastrad break;
224 1.16 riastrad case RINTF:
225 1.16 riastrad received = rintf(values[i].input);
226 1.16 riastrad break;
227 1.16 riastrad case RINTL:
228 1.16 riastrad received = rintl(values[i].input);
229 1.16 riastrad break;
230 1.16 riastrad default:
231 1.16 riastrad atf_tc_fail("impossible");
232 1.16 riastrad }
233 1.16 riastrad
234 1.16 riastrad /*
235 1.16 riastrad * Verify FE_INEXACT was raised or not,
236 1.16 riastrad * depending on whether there was rounding and
237 1.16 riastrad * whether the function is supposed to raise
238 1.16 riastrad * exceptions.
239 1.16 riastrad */
240 1.16 riastrad if (expect_except) {
241 1.16 riastrad ATF_CHECK_MSG(fetestexcept(FE_INEXACT) != 0,
242 1.16 riastrad "[%u] %s %s(%f)"
243 1.16 riastrad " failed to raise FE_INEXACT",
244 1.16 riastrad i, rmname(values[i].round_mode),
245 1.16 riastrad fnname[fn], values[i].input);
246 1.16 riastrad } else {
247 1.16 riastrad ATF_CHECK_MSG(fetestexcept(FE_INEXACT) == 0,
248 1.16 riastrad "[%u] %s %s(%f)"
249 1.16 riastrad " spuriously raised FE_INEXACT",
250 1.16 riastrad i, rmname(values[i].round_mode),
251 1.16 riastrad fnname[fn], values[i].input);
252 1.16 riastrad }
253 1.16 riastrad
254 1.16 riastrad /*
255 1.16 riastrad * Verify the fractional part of the result is
256 1.16 riastrad * zero -- the result of rounding to an integer
257 1.16 riastrad * is supposed to be an integer.
258 1.16 riastrad */
259 1.16 riastrad fpart = modf(received, &ipart);
260 1.16 riastrad ATF_CHECK_MSG(fpart == 0,
261 1.16 riastrad "[%u] %s %s(%f)=%f has fractional part %f"
262 1.16 riastrad " (integer part %f)",
263 1.16 riastrad i, rmname(values[i].round_mode), fnname[fn],
264 1.16 riastrad values[i].input, received, fpart, ipart);
265 1.16 riastrad
266 1.16 riastrad /*
267 1.16 riastrad * Assuming the result we got has zero
268 1.16 riastrad * fractional part, casting to long int should
269 1.16 riastrad * have no rounding. Verify it matches the
270 1.16 riastrad * integer we expect.
271 1.16 riastrad */
272 1.16 riastrad ATF_CHECK_MSG((long int)received == values[i].expected,
273 1.16 riastrad "[%u] %s %s(%f): got %f, expected %ld",
274 1.16 riastrad i, rmname(values[i].round_mode), fnname[fn],
275 1.16 riastrad values[i].input, received, values[i].expected);
276 1.16 riastrad
277 1.16 riastrad /* Do we get the same rounding mode out? */
278 1.16 riastrad ATF_CHECK_MSG(fegetround() == values[i].round_mode,
279 1.16 riastrad "[%u] %s: set %d (%s), got %d (%s)",
280 1.16 riastrad i, fnname[fn],
281 1.16 riastrad values[i].round_mode, rmname(values[i].round_mode),
282 1.16 riastrad fegetround(), rmname(fegetround()));
283 1.16 riastrad }
284 1.6 he }
285 1.6 he }
286 1.6 he
287 1.11 riastrad #ifdef __HAVE_LONG_DOUBLE
288 1.11 riastrad
289 1.11 riastrad /*
290 1.11 riastrad * Use one bit more than fits in IEEE 754 binary64.
291 1.11 riastrad */
292 1.11 riastrad static const struct {
293 1.11 riastrad int round_mode;
294 1.11 riastrad long double input;
295 1.16 riastrad int64_t expected;
296 1.11 riastrad } valuesl[] = {
297 1.13 riastrad { FE_TOWARDZERO, 0x2.00000000000008p+52L, 0x20000000000000 },
298 1.13 riastrad { FE_DOWNWARD, 0x2.00000000000008p+52L, 0x20000000000000 },
299 1.13 riastrad { FE_UPWARD, 0x2.00000000000008p+52L, 0x20000000000001 },
300 1.13 riastrad { FE_TONEAREST, 0x2.00000000000008p+52L, 0x20000000000000 },
301 1.13 riastrad { FE_TOWARDZERO, 0x2.00000000000018p+52L, 0x20000000000001 },
302 1.13 riastrad { FE_DOWNWARD, 0x2.00000000000018p+52L, 0x20000000000001 },
303 1.13 riastrad { FE_UPWARD, 0x2.00000000000018p+52L, 0x20000000000002 },
304 1.13 riastrad { FE_TONEAREST, 0x2.00000000000018p+52L, 0x20000000000002 },
305 1.11 riastrad };
306 1.11 riastrad
307 1.16 riastrad ATF_TC(fe_nearbyintl_rintl);
308 1.16 riastrad ATF_TC_HEAD(fe_nearbyintl_rintl, tc)
309 1.11 riastrad {
310 1.11 riastrad atf_tc_set_md_var(tc, "descr",
311 1.16 riastrad "Checking IEEE 754 rounding modes using nearbyintl/rintl");
312 1.11 riastrad }
313 1.11 riastrad
314 1.16 riastrad ATF_TC_BODY(fe_nearbyintl_rintl, tc)
315 1.11 riastrad {
316 1.16 riastrad enum {
317 1.16 riastrad RINTL,
318 1.16 riastrad NEARBYINTL,
319 1.16 riastrad N_FN,
320 1.16 riastrad } fn;
321 1.16 riastrad static const char *const fnname[] = {
322 1.16 riastrad [RINTL] = "rintl",
323 1.16 riastrad [NEARBYINTL] = "nearbyintl",
324 1.16 riastrad };
325 1.11 riastrad long double received, ipart, fpart;
326 1.16 riastrad unsigned i;
327 1.11 riastrad
328 1.16 riastrad for (i = 0; i < __arraycount(valuesl); i++) {
329 1.16 riastrad for (fn = 0; fn < N_FN; fn++) {
330 1.16 riastrad bool expect_except =
331 1.16 riastrad (valuesl[i].input !=
332 1.16 riastrad (long double)valuesl[i].expected);
333 1.16 riastrad
334 1.16 riastrad /*
335 1.16 riastrad * Set the requested rounding mode.
336 1.16 riastrad */
337 1.16 riastrad fesetround(valuesl[i].round_mode);
338 1.16 riastrad
339 1.16 riastrad /*
340 1.16 riastrad * Clear sticky floating-point exception bits
341 1.16 riastrad * so we can verify whether the FE_INEXACT
342 1.16 riastrad * exception is raised.
343 1.16 riastrad */
344 1.16 riastrad feclearexcept(FE_ALL_EXCEPT);
345 1.16 riastrad
346 1.16 riastrad /*
347 1.16 riastrad * Call the rint(3)-family function.
348 1.16 riastrad */
349 1.16 riastrad switch (fn) {
350 1.16 riastrad case NEARBYINTL:
351 1.16 riastrad received = nearbyintl(valuesl[i].input);
352 1.16 riastrad expect_except = false;
353 1.16 riastrad break;
354 1.16 riastrad case RINTL:
355 1.16 riastrad received = rintl(valuesl[i].input);
356 1.16 riastrad break;
357 1.16 riastrad default:
358 1.16 riastrad atf_tc_fail("impossible");
359 1.16 riastrad }
360 1.16 riastrad
361 1.16 riastrad /*
362 1.16 riastrad * Verify FE_INEXACT was raised or not,
363 1.16 riastrad * depending on whether there was rounding and
364 1.16 riastrad * whether the function is supposed to raise
365 1.16 riastrad * exceptions.
366 1.16 riastrad */
367 1.16 riastrad if (expect_except) {
368 1.16 riastrad ATF_CHECK_MSG(fetestexcept(FE_INEXACT) != 0,
369 1.16 riastrad "[%u] %s %s(%Lf)"
370 1.16 riastrad " failed to raise FE_INEXACT",
371 1.16 riastrad i, rmname(valuesl[i].round_mode),
372 1.16 riastrad fnname[fn], valuesl[i].input);
373 1.16 riastrad } else {
374 1.16 riastrad ATF_CHECK_MSG(fetestexcept(FE_INEXACT) == 0,
375 1.16 riastrad "[%u] %s %s(%Lf)"
376 1.16 riastrad " spuriously raised FE_INEXACT",
377 1.16 riastrad i, rmname(valuesl[i].round_mode),
378 1.16 riastrad fnname[fn], valuesl[i].input);
379 1.16 riastrad }
380 1.16 riastrad
381 1.16 riastrad /*
382 1.16 riastrad * Verify the fractional part of the result is
383 1.16 riastrad * zero -- the result of rounding to an integer
384 1.16 riastrad * is supposed to be an integer.
385 1.16 riastrad */
386 1.16 riastrad fpart = modfl(received, &ipart);
387 1.16 riastrad ATF_CHECK_MSG(fpart == 0,
388 1.16 riastrad "[%u] %s %s(%Lf)=%Lf has fractional part %Lf"
389 1.16 riastrad " (integer part %Lf)",
390 1.16 riastrad i, rmname(valuesl[i].round_mode), fnname[fn],
391 1.16 riastrad valuesl[i].input, received, fpart, ipart);
392 1.16 riastrad
393 1.16 riastrad /*
394 1.16 riastrad * Assuming the result we got has zero
395 1.16 riastrad * fractional part, casting to int64_t should
396 1.16 riastrad * have no rounding. Verify it matches the
397 1.16 riastrad * integer we expect.
398 1.16 riastrad */
399 1.16 riastrad ATF_CHECK_MSG(((int64_t)received ==
400 1.16 riastrad valuesl[i].expected),
401 1.16 riastrad "[%u] %s %s(%Lf): got %Lf, expected %jd",
402 1.16 riastrad i, rmname(valuesl[i].round_mode), fnname[fn],
403 1.16 riastrad valuesl[i].input, received, valuesl[i].expected);
404 1.16 riastrad
405 1.16 riastrad /* Do we get the same rounding mode out? */
406 1.16 riastrad ATF_CHECK_MSG(fegetround() == valuesl[i].round_mode,
407 1.16 riastrad "[%u] %s: set %d (%s), got %d (%s)",
408 1.16 riastrad i, fnname[fn],
409 1.16 riastrad valuesl[i].round_mode,
410 1.16 riastrad rmname(valuesl[i].round_mode),
411 1.16 riastrad fegetround(), rmname(fegetround()));
412 1.16 riastrad }
413 1.11 riastrad }
414 1.11 riastrad }
415 1.11 riastrad
416 1.11 riastrad #endif
417 1.11 riastrad
418 1.7 he static const struct {
419 1.7 he double input;
420 1.7 he double toward;
421 1.7 he double expected;
422 1.7 he } values2[] = {
423 1.7 he { 10.0, 11.0, 10.0 },
424 1.7 he { -5.0, -6.0, -5.0 },
425 1.7 he };
426 1.7 he
427 1.7 he ATF_TC(fe_nextafter);
428 1.7 he ATF_TC_HEAD(fe_nextafter, tc)
429 1.7 he {
430 1.7 he atf_tc_set_md_var(tc, "descr", "Checking IEEE 754 rounding using nextafter()");
431 1.7 he }
432 1.7 he
433 1.7 he ATF_TC_BODY(fe_nextafter, tc)
434 1.7 he {
435 1.7 he double received;
436 1.7 he int res;
437 1.7 he
438 1.7 he for (unsigned int i = 0; i < __arraycount(values2); i++) {
439 1.7 he received = nextafter(values2[i].input, values2[i].toward);
440 1.7 he if (values2[i].input < values2[i].toward) {
441 1.7 he res = (received > values2[i].input);
442 1.7 he } else {
443 1.7 he res = (received < values2[i].input);
444 1.7 he }
445 1.7 he ATF_CHECK_MSG(
446 1.7 he res && (fabs(received - values2[i].expected) < EPSILON),
447 1.7 he "nextafter() rounding wrong, difference too large\n"
448 1.7 he "input: %f (index %d): got %f, expected %f, res %d\n",
449 1.7 he values2[i].input, i, received, values2[i].expected, res);
450 1.7 he }
451 1.7 he }
452 1.7 he
453 1.7 he ATF_TC(fe_nexttoward);
454 1.7 he ATF_TC_HEAD(fe_nexttoward, tc)
455 1.7 he {
456 1.7 he atf_tc_set_md_var(tc, "descr", "Checking IEEE 754 rounding using nexttoward()");
457 1.7 he }
458 1.7 he
459 1.7 he ATF_TC_BODY(fe_nexttoward, tc)
460 1.7 he {
461 1.7 he double received;
462 1.7 he int res;
463 1.7 he
464 1.7 he for (unsigned int i = 0; i < __arraycount(values2); i++) {
465 1.7 he received = nexttoward(values2[i].input, values2[i].toward);
466 1.7 he if (values2[i].input < values2[i].toward) {
467 1.7 he res = (received > values2[i].input);
468 1.7 he } else {
469 1.7 he res = (received < values2[i].input);
470 1.7 he }
471 1.7 he ATF_CHECK_MSG(
472 1.7 he res && (fabs(received - values2[i].expected) < EPSILON),
473 1.7 he "nexttoward() rounding wrong, difference too large\n"
474 1.7 he "input: %f (index %d): got %f, expected %f, res %d\n",
475 1.7 he values2[i].input, i, received, values2[i].expected, res);
476 1.7 he }
477 1.7 he }
478 1.7 he
479 1.1 maya ATF_TP_ADD_TCS(tp)
480 1.1 maya {
481 1.1 maya
482 1.16 riastrad ATF_TP_ADD_TC(tp, fe_lrint);
483 1.16 riastrad ATF_TP_ADD_TC(tp, fe_nearbyint_rint);
484 1.11 riastrad #ifdef __HAVE_LONG_DOUBLE
485 1.16 riastrad ATF_TP_ADD_TC(tp, fe_nearbyintl_rintl);
486 1.11 riastrad #endif
487 1.7 he ATF_TP_ADD_TC(tp, fe_nextafter);
488 1.7 he ATF_TP_ADD_TC(tp, fe_nexttoward);
489 1.1 maya
490 1.1 maya return atf_no_error();
491 1.1 maya }
492 1.1 maya #else
493 1.1 maya ATF_TC(t_nofe_round);
494 1.1 maya
495 1.1 maya ATF_TC_HEAD(t_nofe_round, tc)
496 1.1 maya {
497 1.1 maya atf_tc_set_md_var(tc, "descr",
498 1.1 maya "dummy test case - no fenv.h support");
499 1.1 maya }
500 1.1 maya
501 1.4 he ATF_TC_BODY(t_nofe_round, tc)
502 1.4 he {
503 1.4 he atf_tc_skip("no fenv.h support on this architecture");
504 1.4 he }
505 1.1 maya
506 1.6 he ATF_TC(t_nofe_nearbyint);
507 1.6 he
508 1.6 he ATF_TC_HEAD(t_nofe_nearbyint, tc)
509 1.6 he {
510 1.6 he atf_tc_set_md_var(tc, "descr",
511 1.6 he "dummy test case - no fenv.h support");
512 1.6 he }
513 1.6 he
514 1.6 he ATF_TC_BODY(t_nofe_nearbyint, tc)
515 1.6 he {
516 1.6 he atf_tc_skip("no fenv.h support on this architecture");
517 1.6 he }
518 1.6 he
519 1.7 he ATF_TC(t_nofe_nextafter);
520 1.7 he
521 1.7 he ATF_TC_HEAD(t_nofe_nextafter, tc)
522 1.7 he {
523 1.7 he atf_tc_set_md_var(tc, "descr",
524 1.7 he "dummy test case - no fenv.h support");
525 1.7 he }
526 1.7 he
527 1.7 he ATF_TC_BODY(t_nofe_nextafter, tc)
528 1.7 he {
529 1.7 he atf_tc_skip("no fenv.h support on this architecture");
530 1.7 he }
531 1.7 he
532 1.7 he ATF_TC(t_nofe_nexttoward);
533 1.7 he
534 1.7 he ATF_TC_HEAD(t_nofe_nexttoward, tc)
535 1.7 he {
536 1.7 he atf_tc_set_md_var(tc, "descr",
537 1.7 he "dummy test case - no fenv.h support");
538 1.7 he }
539 1.7 he
540 1.7 he ATF_TC_BODY(t_nofe_nexttoward, tc)
541 1.7 he {
542 1.7 he atf_tc_skip("no fenv.h support on this architecture");
543 1.7 he }
544 1.6 he
545 1.1 maya ATF_TP_ADD_TCS(tp)
546 1.1 maya {
547 1.1 maya ATF_TP_ADD_TC(tp, t_nofe_round);
548 1.6 he ATF_TP_ADD_TC(tp, t_nofe_nearbyint);
549 1.7 he ATF_TP_ADD_TC(tp, t_nofe_nextafter);
550 1.7 he ATF_TP_ADD_TC(tp, t_nofe_nexttoward);
551 1.1 maya return atf_no_error();
552 1.1 maya }
553 1.1 maya
554 1.1 maya #endif
555