Skip to content

Commit e37bd6c

Browse files
authored
[libc][fenv] Add missing FE_* definitions for some environment. (#91519)
1 parent fcf945f commit e37bd6c

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

libc/hdr/fenv_macros.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,51 @@
1717

1818
#include <fenv.h>
1919

20+
// In some environment, FE_ALL_EXCEPT is set to 0 and the remaining exceptions
21+
// FE_* are missing.
22+
#if (FE_ALL_EXCEPT == 0)
23+
#ifndef FE_DIVBYZERO
24+
#define FE_DIVBYZERO 0
25+
#endif // FE_DIVBYZERO
26+
27+
#ifndef FE_INEXACT
28+
#define FE_INEXACT 0
29+
#endif // FE_INEXACT
30+
31+
#ifndef FE_INVALID
32+
#define FE_INVALID 0
33+
#endif // FE_INVALID
34+
35+
#ifndef FE_OVERFLOW
36+
#define FE_OVERFLOW 0
37+
#endif // FE_OVERFLOW
38+
39+
#ifndef FE_UNDERFLOW
40+
#define FE_UNDERFLOW 0
41+
#endif // FE_UNDERFLOW
42+
#else
2043
// If this is not provided by the system, define it for use internally.
2144
#ifndef __FE_DENORM
2245
#define __FE_DENORM (1 << 6)
2346
#endif
47+
#endif
48+
49+
// Rounding mode macros might be missing.
50+
#ifndef FE_DOWNWARD
51+
#define FE_DOWNWARD 0x400
52+
#endif // FE_DOWNWARD
53+
54+
#ifndef FE_TONEAREST
55+
#define FE_TONEAREST 0
56+
#endif // FE_TONEAREST
57+
58+
#ifndef FE_TOWARDZERO
59+
#define FE_TOWARDZERO 0xC00
60+
#endif // FE_TOWARDZERO
61+
62+
#ifndef FE_UPWARD
63+
#define FE_UPWARD 0x800
64+
#endif // FE_UPWARD
2465

2566
#endif // LLVM_LIBC_FULL_BUILD
2667

0 commit comments

Comments
 (0)