#include "flang/Runtime/main.h"
#include "environment.h"
#include "terminator.h"
#include <cfenv>
#include <cstdio>
#include <cstdlib>
static void ConfigureFloatingPoint() {
#ifdef feclearexcept
feclearexcept(FE_ALL_EXCEPT);
#else
std::feclearexcept(FE_ALL_EXCEPT);
#endif
#ifdef fesetround
fesetround(FE_TONEAREST);
#else
std::fesetround(FE_TONEAREST);
#endif
}
extern "C" {
void RTNAME(ProgramStart)(int argc, const char *argv[], const char *envp[],
const EnvironmentDefaultList *envDefaults) {
std::atexit(Fortran::runtime::NotifyOtherImagesOfNormalEnd);
Fortran::runtime::executionEnvironment.Configure(
argc, argv, envp, envDefaults);
ConfigureFloatingPoint();
}
void RTNAME(ByteswapOption)() {
if (Fortran::runtime::executionEnvironment.conversion ==
Fortran::runtime::Convert::Unknown) {
Fortran::runtime::executionEnvironment.conversion =
Fortran::runtime::Convert::Swap;
}
}
}