1 /* Test nearbyint functions do not disable exception traps (bug 19228).
2 Copyright (C) 2015-2024 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 <https://www.gnu.org/licenses/>. */
27 #define TEST_FUNC(NAME, FLOAT, SUFFIX) \
32 volatile FLOAT a, b __attribute__ ((unused)); \
34 /* nearbyint must work when traps on "inexact" are enabled. */ \
35 b = nearbyint ## SUFFIX (a); \
36 /* And it must have left those traps enabled. */ \
37 if (fegetexcept () == FE_INEXACT) \
38 puts ("PASS: " #FLOAT); \
41 puts ("FAIL: " #FLOAT); \
47 TEST_FUNC (float_test
, float, f
)
48 TEST_FUNC (double_test
, double, )
49 TEST_FUNC (ldouble_test
, long double, l
)
54 if (feenableexcept (FE_INEXACT
) == -1)
56 puts ("enabling FE_INEXACT traps failed, cannot test");
59 int result
= float_test ();
60 feenableexcept (FE_INEXACT
);
61 result
|= double_test ();
62 feenableexcept (FE_INEXACT
);
63 result
|= ldouble_test ();
67 #define TEST_FUNCTION do_test ()
68 #include "../test-skeleton.c"