1 //===-- runtime/main.cpp ----------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "main.h" 10 #include "environment.h" 11 #include "terminator.h" 12 #include "unit.h" 13 #include <cfenv> 14 #include <cstdio> 15 #include <cstdlib> 16 17 static void ConfigureFloatingPoint() { 18 #ifdef feclearexcept // a macro in some environments; omit std:: 19 feclearexcept(FE_ALL_EXCEPT); 20 #else 21 std::feclearexcept(FE_ALL_EXCEPT); 22 #endif 23 #ifdef fesetround 24 fesetround(FE_TONEAREST); 25 #else 26 std::fesetround(FE_TONEAREST); 27 #endif 28 } 29 30 extern "C" { 31 32 void RTNAME(ProgramStart)(int argc, const char *argv[], const char *envp[]) { 33 std::atexit(Fortran::runtime::NotifyOtherImagesOfNormalEnd); 34 Fortran::runtime::executionEnvironment.Configure(argc, argv, envp); 35 ConfigureFloatingPoint(); 36 Fortran::runtime::Terminator terminator{"ProgramStart()"}; 37 Fortran::runtime::io::ExternalFile::InitializePredefinedUnits(terminator); 38 } 39 } 40