1 //===-- runtime/environment.h -----------------------------------*- 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 #ifndef FORTRAN_RUNTIME_ENVIRONMENT_H_ 10 #define FORTRAN_RUNTIME_ENVIRONMENT_H_ 11 12 #include "flang/Decimal/decimal.h" 13 #include <optional> 14 15 namespace Fortran::runtime { 16 17 class Terminator; 18 19 #if FLANG_BIG_ENDIAN 20 constexpr bool isHostLittleEndian{false}; 21 #elif FLANG_LITTLE_ENDIAN 22 constexpr bool isHostLittleEndian{true}; 23 #else 24 #error host endianness is not known 25 #endif 26 27 // External unformatted I/O data conversions 28 enum class Convert { Unknown, Native, LittleEndian, BigEndian, Swap }; 29 30 std::optional<Convert> GetConvertFromString(const char *, std::size_t); 31 32 struct ExecutionEnvironment { ExecutionEnvironmentExecutionEnvironment33 constexpr ExecutionEnvironment(){}; 34 void Configure(int argc, const char *argv[], const char *envp[]); 35 const char *GetEnv( 36 const char *name, std::size_t name_length, const Terminator &terminator); 37 38 int argc{0}; 39 const char **argv{nullptr}; 40 const char **envp{nullptr}; 41 42 int listDirectedOutputLineLengthLimit{79}; // FORT_FMT_RECL 43 enum decimal::FortranRounding defaultOutputRoundingMode{ 44 decimal::FortranRounding::RoundNearest}; // RP(==PN) 45 Convert conversion{Convert::Unknown}; // FORT_CONVERT 46 bool noStopMessage{false}; // NO_STOP_MESSAGE=1 inhibits "Fortran STOP" 47 bool defaultUTF8{false}; // DEFAULT_UTF8 48 }; 49 50 extern ExecutionEnvironment executionEnvironment; 51 } // namespace Fortran::runtime 52 53 #endif // FORTRAN_RUNTIME_ENVIRONMENT_H_ 54