diff options
Diffstat (limited to 'flang/runtime/exceptions.cpp')
| -rw-r--r-- | flang/runtime/exceptions.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/flang/runtime/exceptions.cpp b/flang/runtime/exceptions.cpp index 993c996c9ce7..2fa2baa2ec84 100644 --- a/flang/runtime/exceptions.cpp +++ b/flang/runtime/exceptions.cpp @@ -81,6 +81,27 @@ uint32_t RTNAME(MapException)(uint32_t excepts) { // on some systems, e.g. Solaris, so omit object size comparison for now. // TODO: consider femode_t object size comparison once its more mature. +// Check if the processor has the ability to control whether to halt or +// continue execution when a given exception is raised. +bool RTNAME(SupportHalting)([[maybe_unused]] uint32_t except) { +#ifdef __USE_GNU + except = RTNAME(MapException)(except); + int currentSet = fegetexcept(), flipSet, ok; + if (currentSet & except) { + ok = fedisableexcept(except); + flipSet = fegetexcept(); + ok |= feenableexcept(except); + } else { + ok = feenableexcept(except); + flipSet = fegetexcept(); + ok |= fedisableexcept(except); + } + return ok != -1 && currentSet != flipSet; +#else + return false; +#endif +} + bool RTNAME(GetUnderflowMode)(void) { #if __x86_64__ // The MXCSR Flush to Zero flag is the negation of the ieee_get_underflow_mode |
