| 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/Common/optional.h" |
| 13 |
#include "flang/Decimal/decimal.h" |
| 14 |
|
| 15 |
struct EnvironmentDefaultList; |
| 16 |
|
| 17 |
namespace Fortran::runtime { |
| 18 |
|
| 19 |
class Terminator; |
| 20 |
|
| 21 |
RT_OFFLOAD_VAR_GROUP_BEGIN |
| 22 |
#if FLANG_BIG_ENDIAN |
| 23 |
constexpr bool isHostLittleEndian{false}; |
| 24 |
#elif FLANG_LITTLE_ENDIAN |
| 25 |
constexpr bool isHostLittleEndian{true}; |
| 26 |
#else |
| 27 |
#error host endianness is not known |
| 28 |
#endif |
| 29 |
RT_OFFLOAD_VAR_GROUP_END |
| 30 |
|
| 31 |
// External unformatted I/O data conversions |
| 32 |
enum class Convert { Unknown, Native, LittleEndian, BigEndian, Swap }; |
| 33 |
|
| 34 |
RT_API_ATTRS Fortran::common::optional<Convert> GetConvertFromString( |
| 35 |
const char *, std::size_t); |
| 36 |
|
| 37 |
struct ExecutionEnvironment { |
| 38 |
#if !defined(_OPENMP) |
| 39 |
// FIXME: https://github.com/llvm/llvm-project/issues/84942 |
| 40 |
constexpr |
| 41 |
#endif |
| 42 |
ExecutionEnvironment(){}; |
| 43 |
void Configure(int argc, const char *argv[], const char *envp[], |
| 44 |
const EnvironmentDefaultList *envDefaults); |
| 45 |
const char *GetEnv( |
| 46 |
const char *name, std::size_t name_length, const Terminator &terminator); |
| 47 |
|
| 48 |
int argc{0}; |
| 49 |
const char **argv{nullptr}; |
| 50 |
char **envp{nullptr}; |
| 51 |
|
| 52 |
int listDirectedOutputLineLengthLimit{79}; // FORT_FMT_RECL |
| 53 |
enum decimal::FortranRounding defaultOutputRoundingMode{ |
| 54 |
decimal::FortranRounding::RoundNearest}; // RP(==PN) |
| 55 |
Convert conversion{Convert::Unknown}; // FORT_CONVERT |
| 56 |
bool noStopMessage{false}; // NO_STOP_MESSAGE=1 inhibits "Fortran STOP" |
| 57 |
bool defaultUTF8{false}; // DEFAULT_UTF8 |
| 58 |
bool checkPointerDeallocation{true}; // FORT_CHECK_POINTER_DEALLOCATION |
| 59 |
}; |
| 60 |
|
| 61 |
RT_OFFLOAD_VAR_GROUP_BEGIN |
| 62 |
extern RT_VAR_ATTRS ExecutionEnvironment executionEnvironment; |
| 63 |
RT_OFFLOAD_VAR_GROUP_END |
| 64 |
|
| 65 |
} // namespace Fortran::runtime |
| 66 |
|
| 67 |
#endif // FORTRAN_RUNTIME_ENVIRONMENT_H_ |