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 17 #define FORTRAN_PROCEDURE_NAME(name) name##_ 18 19 #include "flang/Runtime/entry-names.h" 20 #include <cstddef> 21 #include <cstdint> 22 23 #ifdef _WIN32 24 // UID and GID don't exist on Windows, these exist to avoid errors. 25 typedef std::uint32_t uid_t; 26 typedef std::uint32_t gid_t; 27 #else 28 #include "sys/types.h" //pid_t 29 #endif 30 31 extern "C" { 32 33 // CALL FLUSH(n) antedates the Fortran 2003 FLUSH statement. 34 void FORTRAN_PROCEDURE_NAME(flush)(const int &unit); 35 36 // GNU extension subroutine FDATE 37 void FORTRAN_PROCEDURE_NAME(fdate)(char *string, std::int64_t length); 38 39 void RTNAME(Free)(std::intptr_t ptr); 40 41 // GNU Fortran 77 compatibility function IARGC. 42 std::int32_t FORTRAN_PROCEDURE_NAME(iargc)(); 43 44 // GNU Fortran 77 compatibility subroutine GETARG(N, ARG). 45 void FORTRAN_PROCEDURE_NAME(getarg)( 46 std::int32_t &n, char *arg, std::int64_t length); 47 48 // Calls getgid() 49 gid_t RTNAME(GetGID)(); 50 51 // Calls getuid() 52 uid_t RTNAME(GetUID)(); 53 54 // GNU extension subroutine GETLOG(C). 55 void FORTRAN_PROCEDURE_NAME(getlog)(char *name, std::int64_t length); 56 57 std::intptr_t RTNAME(Malloc)(std::size_t size); 58 59 // GNU extension function STATUS = SIGNAL(number, handler) 60 std::int64_t RTNAME(Signal)(std::int64_t number, void (*handler)(int)); 61 62 // GNU extension subroutine SLEEP(SECONDS) 63 void RTNAME(Sleep)(std::int64_t seconds); 64 65 // GNU extension function ACCESS(NAME, MODE) 66 // TODO: not supported on Windows 67 #ifndef _WIN32 68 std::int64_t FORTRAN_PROCEDURE_NAME(access)(const char *name, 69 std::int64_t nameLength, const char *mode, std::int64_t modeLength); 70 #endif 71 72 // GNU extension subroutine CHDIR(NAME, [STATUS]) 73 int RTNAME(Chdir)(const char *name); 74 75 // GNU extension function IERRNO() 76 int FORTRAN_PROCEDURE_NAME(ierrno)(); 77 78 } // extern "C" 79 #endif // FORTRAN_RUNTIME_EXTENSIONS_H_ 80