Skip to content

Commit

Permalink
[flang] Dodge build problem in some Power environments
Browse files Browse the repository at this point in the history
  • Loading branch information
klausler committed Jan 9, 2020
1 parent 1c21916 commit 9e6d1a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions flang/runtime/main.cc
Expand Up @@ -22,11 +22,22 @@ extern "C" {
void __FortranProgram(); // PROGRAM statement

int main(int argc, const char *argv[], const char *envp[]) {

Fortran::runtime::argc = argc;
Fortran::runtime::argv = argv;
Fortran::runtime::envp = envp;

#ifdef feclearexcept // a macro in some environments; omit std::
feclearexcept(FE_ALL_EXCEPT);
#else
std::feclearexcept(FE_ALL_EXCEPT);
#endif
#ifdef fesetround
fesetround(FE_TONEAREST);
#else
std::fesetround(FE_TONEAREST);
#endif

std::atexit(Fortran::runtime::NotifyOtherImagesOfNormalEnd);
// TODO: Runtime configuration settings from environment
__FortranProgram();
Expand Down
7 changes: 6 additions & 1 deletion flang/runtime/stop.cc
Expand Up @@ -15,7 +15,12 @@
extern "C" {

static void DescribeIEEESignaledExceptions() {
if (auto excepts{std::fetestexcept(FE_ALL_EXCEPT)}) {
#ifdef fetestexcept // a macro in some environments; omit std::
auto excepts{fetestexcept(FE_ALL_EXCEPT)};
#else
auto excepts{std::fetestexcept(FE_ALL_EXCEPT)};
#endif
if (excepts) {
std::fputs("IEEE arithmetic exceptions signaled:", stderr);
if (excepts & FE_DIVBYZERO) {
std::fputs(" DIVBYZERO", stderr);
Expand Down

0 comments on commit 9e6d1a7

Please sign in to comment.