1 /* Test nearbyint functions do not clear exceptions (bug 15491).
2 Copyright (C) 2015-2016 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
23 #include <math-tests.h>
29 #define TEST_FUNC(NAME, FLOAT, SUFFIX) \
34 volatile FLOAT a, b __attribute__ ((unused)); \
36 /* nearbyint must not clear already-raised exceptions. */ \
37 feraiseexcept (FE_ALL_EXCEPT); \
38 b = nearbyint ## SUFFIX (a); \
39 if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \
40 puts ("PASS: " #FLOAT); \
43 puts ("FAIL: " #FLOAT); \
46 /* But it mustn't lose exceptions from sNaN arguments. */ \
47 if (SNAN_TESTS (FLOAT) && EXCEPTION_TESTS (FLOAT)) \
49 static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \
50 volatile FLOAT c __attribute__ ((unused)); \
51 feclearexcept (FE_ALL_EXCEPT); \
52 c = nearbyint ## SUFFIX (snan); \
53 if (fetestexcept (FE_INVALID) == FE_INVALID) \
54 puts ("PASS: " #FLOAT " sNaN"); \
57 puts ("FAIL: " #FLOAT " sNaN"); \
64 TEST_FUNC (float_test
, float, f
)
65 TEST_FUNC (double_test
, double, )
66 #ifndef NO_LONG_DOUBLE
67 TEST_FUNC (ldouble_test
, long double, l
)
73 int result
= float_test ();
74 result
|= double_test ();
75 #ifndef NO_LONG_DOUBLE
76 result
|= ldouble_test ();
81 #define TEST_FUNCTION do_test ()
82 #include "../test-skeleton.c"