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 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
18 constexpr bool isHostLittleEndian{false};
19 #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
20 constexpr bool isHostLittleEndian{true};
21 #else
22 #error host endianness is not known
23 #endif
24 
25 // External unformatted I/O data conversions
26 enum class Convert { Unknown, Native, LittleEndian, BigEndian, Swap };
27 
28 std::optional<Convert> GetConvertFromString(const char *, std::size_t);
29 
30 struct ExecutionEnvironment {
31   void Configure(int argc, const char *argv[], const char *envp[]);
32 
33   int argc;
34   const char **argv;
35   const char **envp;
36   int listDirectedOutputLineLengthLimit;
37   enum decimal::FortranRounding defaultOutputRoundingMode;
38   Convert conversion;
39 };
40 extern ExecutionEnvironment executionEnvironment;
41 } // namespace Fortran::runtime
42 
43 #endif // FORTRAN_RUNTIME_ENVIRONMENT_H_
44