File tree 3 files changed +44
-1
lines changed
3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -507,18 +507,29 @@ static RT_API_ATTRS void RaiseFPExceptions(
507
507
#define RAISE std::feraiseexcept
508
508
#endif
509
509
#endif // !defined(RT_DEVICE_COMPILATION)
510
+
511
+ // Some environment (e.g. emscripten, musl) don't define FE_OVERFLOW as allowed
512
+ // by c99 (but not c++11) :-/
513
+ #if defined(FE_OVERFLOW) || defined(RT_DEVICE_COMPILATION)
510
514
if (flags & decimal::ConversionResultFlags::Overflow) {
511
515
RAISE (FE_OVERFLOW);
512
516
}
517
+ #endif
518
+ #if defined(FE_UNDERFLOW) || defined(RT_DEVICE_COMPILATION)
513
519
if (flags & decimal::ConversionResultFlags::Underflow) {
514
520
RAISE (FE_UNDERFLOW);
515
521
}
522
+ #endif
523
+ #if defined(FE_INEXACT) || defined(RT_DEVICE_COMPILATION)
516
524
if (flags & decimal::ConversionResultFlags::Inexact) {
517
525
RAISE (FE_INEXACT);
518
526
}
527
+ #endif
528
+ #if defined(FE_INVALID) || defined(RT_DEVICE_COMPILATION)
519
529
if (flags & decimal::ConversionResultFlags::Invalid) {
520
530
RAISE (FE_INVALID);
521
531
}
532
+ #endif
522
533
#undef RAISE
523
534
}
524
535
Original file line number Diff line number Diff line change 12
12
#include " terminator.h"
13
13
#include < cfenv>
14
14
15
+ // When not supported, these macro are undefined in cfenv.h,
16
+ // set them to zero in that case.
17
+ #ifndef FE_INVALID
18
+ #define FE_INVALID 0
19
+ #endif
15
20
#ifndef __FE_DENORM
16
21
#define __FE_DENORM 0 // denorm is nonstandard
17
22
#endif
23
+ #ifndef FE_DIVBYZERO
24
+ #define FE_DIVBYZERO 0
25
+ #endif
26
+ #ifndef FE_OVERFLOW
27
+ #define FE_OVERFLOW 0
28
+ #endif
29
+ #ifndef FE_UNDERFLOW
30
+ #define FE_UNDERFLOW 0
31
+ #endif
32
+ #ifndef FE_INEXACT
33
+ #define FE_INEXACT 0
34
+ #endif
18
35
19
36
namespace Fortran ::runtime {
20
37
@@ -45,7 +62,12 @@ uint32_t RTNAME(MapException)(uint32_t excepts) {
45
62
if (excepts == 0 || excepts >= mapSize) {
46
63
terminator.Crash (" Invalid excepts value: %d" , excepts);
47
64
}
48
- return map[excepts];
65
+ uint32_t except_value = map[excepts];
66
+ if (except_value == 0 ) {
67
+ terminator.Crash (
68
+ " Excepts value %d not supported by flang runtime" , excepts);
69
+ }
70
+ return except_value;
49
71
}
50
72
51
73
// Verify that the size of ieee_modes_type and ieee_status_type objects from
Original file line number Diff line number Diff line change @@ -26,21 +26,31 @@ static void DescribeIEEESignaledExceptions() {
26
26
#endif
27
27
if (excepts) {
28
28
std::fputs (" IEEE arithmetic exceptions signaled:" , stderr);
29
+ #ifdef FE_DIVBYZERO
29
30
if (excepts & FE_DIVBYZERO) {
30
31
std::fputs (" DIVBYZERO" , stderr);
31
32
}
33
+ #endif
34
+ #ifdef FE_INEXACT
32
35
if (excepts & FE_INEXACT) {
33
36
std::fputs (" INEXACT" , stderr);
34
37
}
38
+ #endif
39
+ #ifdef FE_INVALID
35
40
if (excepts & FE_INVALID) {
36
41
std::fputs (" INVALID" , stderr);
37
42
}
43
+ #endif
44
+ #ifdef FE_OVERFLOW
38
45
if (excepts & FE_OVERFLOW) {
39
46
std::fputs (" OVERFLOW" , stderr);
40
47
}
48
+ #endif
49
+ #ifdef FE_UNDERFLOW
41
50
if (excepts & FE_UNDERFLOW) {
42
51
std::fputs (" UNDERFLOW" , stderr);
43
52
}
53
+ #endif
44
54
std::fputc (' \n ' , stderr);
45
55
}
46
56
}
You can’t perform that action at this time.
0 commit comments