Skip to content

Commit 5cb7305

Browse files
authored
[libc] Remove FE_ALL_EXCEPT check in hdr/fenv_macros.h. (#114446)
FE_ALL_EXCEPT macro might not be a valid preprocessor constant expression in some environment. Moreover, FE_ALL_EXCEPT might not be defined as int.
1 parent 2606a58 commit 5cb7305

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

libc/hdr/fenv_macros.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
// In some environment, FE_ALL_EXCEPT is set to 0 and the remaining exceptions
2121
// FE_* are missing.
22-
#if (FE_ALL_EXCEPT == 0)
2322
#ifndef FE_DIVBYZERO
2423
#define FE_DIVBYZERO 0
2524
#endif // FE_DIVBYZERO
@@ -39,12 +38,6 @@
3938
#ifndef FE_UNDERFLOW
4039
#define FE_UNDERFLOW 0
4140
#endif // FE_UNDERFLOW
42-
#else
43-
// If this is not provided by the system, define it for use internally.
44-
#ifndef __FE_DENORM
45-
#define __FE_DENORM (1 << 6)
46-
#endif
47-
#endif
4841

4942
// Rounding mode macros might be missing.
5043
#ifndef FE_DOWNWARD

libc/test/UnitTest/FPMatcher.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,31 +297,35 @@ struct ModifyMXCSR {
297297
#define EXPECT_FP_EXCEPTION(expected) \
298298
do { \
299299
if (math_errhandling & MATH_ERREXCEPT) { \
300-
EXPECT_EQ(LIBC_NAMESPACE::fputil::test_except(FE_ALL_EXCEPT) & \
301-
((expected) ? (expected) : FE_ALL_EXCEPT), \
302-
(expected)); \
300+
EXPECT_EQ( \
301+
LIBC_NAMESPACE::fputil::test_except( \
302+
static_cast<int>(FE_ALL_EXCEPT)) & \
303+
((expected) ? (expected) : static_cast<int>(FE_ALL_EXCEPT)), \
304+
(expected)); \
303305
} \
304306
} while (0)
305307

306308
#define ASSERT_FP_EXCEPTION(expected) \
307309
do { \
308310
if (math_errhandling & MATH_ERREXCEPT) { \
309-
ASSERT_EQ(LIBC_NAMESPACE::fputil::test_except(FE_ALL_EXCEPT) & \
310-
((expected) ? (expected) : FE_ALL_EXCEPT), \
311-
(expected)); \
311+
ASSERT_EQ( \
312+
LIBC_NAMESPACE::fputil::test_except( \
313+
static_cast<int>(FE_ALL_EXCEPT)) & \
314+
((expected) ? (expected) : static_cast<int>(FE_ALL_EXCEPT)), \
315+
(expected)); \
312316
} \
313317
} while (0)
314318

315319
#define EXPECT_FP_EQ_WITH_EXCEPTION(expected_val, actual_val, expected_except) \
316320
do { \
317-
LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); \
321+
LIBC_NAMESPACE::fputil::clear_except(static_cast<int>(FE_ALL_EXCEPT)); \
318322
EXPECT_FP_EQ(expected_val, actual_val); \
319323
EXPECT_FP_EXCEPTION(expected_except); \
320324
} while (0)
321325

322326
#define EXPECT_FP_IS_NAN_WITH_EXCEPTION(actual_val, expected_except) \
323327
do { \
324-
LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); \
328+
LIBC_NAMESPACE::fputil::clear_except(static_cast<int>(FE_ALL_EXCEPT)); \
325329
EXPECT_FP_IS_NAN(actual_val); \
326330
EXPECT_FP_EXCEPTION(expected_except); \
327331
} while (0)
@@ -374,7 +378,7 @@ struct ModifyMXCSR {
374378
using namespace LIBC_NAMESPACE::fputil::testing; \
375379
ForceRoundingMode __r((rounding_mode)); \
376380
if (__r.success) { \
377-
LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); \
381+
LIBC_NAMESPACE::fputil::clear_except(static_cast<int>(FE_ALL_EXCEPT)); \
378382
EXPECT_FP_EQ((expected), (actual)); \
379383
EXPECT_FP_EXCEPTION(expected_except); \
380384
} \

0 commit comments

Comments
 (0)