2020-01-28 10:18:45 +08:00
|
|
|
//===-- runtime/main.cpp ----------------------------------------*- C++ -*-===//
|
2020-01-09 05:27:32 +08:00
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
//
|
2020-01-11 04:12:03 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2020-01-09 05:27:32 +08:00
|
|
|
|
|
|
|
#include "main.h"
|
2020-01-24 08:59:27 +08:00
|
|
|
#include "environment.h"
|
2020-01-09 05:27:32 +08:00
|
|
|
#include "terminator.h"
|
|
|
|
#include <cfenv>
|
2020-01-17 05:51:25 +08:00
|
|
|
#include <cstdio>
|
2020-01-09 05:27:32 +08:00
|
|
|
#include <cstdlib>
|
2020-01-10 06:01:40 +08:00
|
|
|
|
2020-01-17 05:51:25 +08:00
|
|
|
static void ConfigureFloatingPoint() {
|
2020-03-29 12:00:16 +08:00
|
|
|
#ifdef feclearexcept // a macro in some environments; omit std::
|
2020-01-10 06:01:40 +08:00
|
|
|
feclearexcept(FE_ALL_EXCEPT);
|
|
|
|
#else
|
2020-01-09 05:27:32 +08:00
|
|
|
std::feclearexcept(FE_ALL_EXCEPT);
|
2020-01-10 06:01:40 +08:00
|
|
|
#endif
|
|
|
|
#ifdef fesetround
|
|
|
|
fesetround(FE_TONEAREST);
|
|
|
|
#else
|
2020-01-09 05:27:32 +08:00
|
|
|
std::fesetround(FE_TONEAREST);
|
2020-01-10 06:01:40 +08:00
|
|
|
#endif
|
2020-01-17 05:51:25 +08:00
|
|
|
}
|
2020-01-10 06:01:40 +08:00
|
|
|
|
2020-01-17 05:51:25 +08:00
|
|
|
extern "C" {
|
|
|
|
void RTNAME(ProgramStart)(int argc, const char *argv[], const char *envp[]) {
|
2020-01-09 05:27:32 +08:00
|
|
|
std::atexit(Fortran::runtime::NotifyOtherImagesOfNormalEnd);
|
2020-01-17 05:51:25 +08:00
|
|
|
Fortran::runtime::executionEnvironment.Configure(argc, argv, envp);
|
|
|
|
ConfigureFloatingPoint();
|
2020-02-14 06:41:56 +08:00
|
|
|
// I/O is initialized on demand so that it works for non-Fortran main().
|
2020-01-09 05:27:32 +08:00
|
|
|
}
|
2020-07-22 08:37:35 +08:00
|
|
|
|
|
|
|
void RTNAME(ByteswapOption)() {
|
|
|
|
if (Fortran::runtime::executionEnvironment.conversion ==
|
|
|
|
Fortran::runtime::Convert::Unknown) {
|
|
|
|
// The environment variable overrides the command-line option;
|
|
|
|
// either of them take precedence over explicit OPEN(CONVERT=) specifiers.
|
|
|
|
Fortran::runtime::executionEnvironment.conversion =
|
|
|
|
Fortran::runtime::Convert::Swap;
|
|
|
|
}
|
|
|
|
}
|
2020-01-09 05:27:32 +08:00
|
|
|
}
|