FLANG
extensions.h
1//===-- include/flang/Runtime/extensions.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// These C-coded entry points with Fortran-mangled names implement legacy
10// extensions that will eventually be implemented in Fortran.
11
12#ifndef FORTRAN_RUNTIME_EXTENSIONS_H_
13#define FORTRAN_RUNTIME_EXTENSIONS_H_
14
15#include "flang/Runtime/entry-names.h"
16#include <cstddef>
17#include <cstdint>
18
19#define FORTRAN_PROCEDURE_NAME(name) name##_
20
21#ifdef _WIN32
22// UID and GID don't exist on Windows, these exist to avoid errors.
23typedef std::uint32_t uid_t;
24typedef std::uint32_t gid_t;
25#else
26#include "sys/types.h" //pid_t
27#endif
28
29extern "C" {
30
31// PGI extension function DSECNDS(refTime)
32double FORTRAN_PROCEDURE_NAME(dsecnds)(double *refTime);
33double RTNAME(Dsecnds)(double *refTime, const char *sourceFile, int line);
34
35// CALL FLUSH(n) antedates the Fortran 2003 FLUSH statement.
36void FORTRAN_PROCEDURE_NAME(flush)(const int &unit);
37
38// GNU extension subroutine FDATE
39void FORTRAN_PROCEDURE_NAME(fdate)(char *string, std::int64_t length);
40
41void RTNAME(Free)(std::intptr_t ptr);
42
43// Common extensions FSEEK & FTELL, variously named
44std::int32_t RTNAME(Fseek)(int unit, std::int64_t zeroBasedPos, int whence,
45 const char *sourceFileName, int lineNumber);
46std::int64_t RTNAME(Ftell)(int unit);
47
48// GNU Fortran 77 compatibility function IARGC.
49std::int32_t FORTRAN_PROCEDURE_NAME(iargc)();
50
51// GNU Fortran 77 compatibility subroutine GETARG(N, ARG).
52void FORTRAN_PROCEDURE_NAME(getarg)(
53 std::int32_t &n, char *arg, std::int64_t length);
54
55// Calls getgid()
56gid_t RTNAME(GetGID)();
57
58// Calls getuid()
59uid_t RTNAME(GetUID)();
60
61// GNU extension subroutine GETLOG(C).
62void FORTRAN_PROCEDURE_NAME(getlog)(char *name, std::int64_t length);
63
64// GNU extension subroutine HOSTNM(C)
65int FORTRAN_PROCEDURE_NAME(hostnm)(char *hn, int length);
66
67std::intptr_t RTNAME(Malloc)(std::size_t size);
68
69// GNU extension function STATUS = SIGNAL(number, handler)
70std::int64_t RTNAME(Signal)(std::int64_t number, void (*handler)(int));
71
72// GNU extension subroutine SLEEP(SECONDS)
73void RTNAME(Sleep)(std::int64_t seconds);
74
75// GNU extension function TIME()
76std::int64_t RTNAME(time)();
77
78// GNU extension function ACCESS(NAME, MODE)
79// TODO: not supported on Windows
80#ifndef _WIN32
81std::int64_t FORTRAN_PROCEDURE_NAME(access)(const char *name,
82 std::int64_t nameLength, const char *mode, std::int64_t modeLength);
83#endif
84
85// GNU extension subroutine CHDIR(NAME, [STATUS])
86int RTNAME(Chdir)(const char *name);
87
88// GNU extension function IERRNO()
89int FORTRAN_PROCEDURE_NAME(ierrno)();
90
91// GNU extension subroutine PERROR(STRING)
92void RTNAME(Perror)(const char *str);
93
94// MCLOCK -- returns accumulated time in ticks
95int FORTRAN_PROCEDURE_NAME(mclock)();
96
97// GNU extension subroutine SECNDS(refTime)
98float FORTRAN_PROCEDURE_NAME(secnds)(float *refTime);
99float RTNAME(Secnds)(float *refTime, const char *sourceFile, int line);
100
101} // extern "C"
102#endif // FORTRAN_RUNTIME_EXTENSIONS_H_