xref: /llvm-project/flang/include/flang/Runtime/time-intrinsic.h (revision dc8d70acf7afd6d8c9eef7d240fb8c917eddab50)
1 //===-- include/flang/Runtime/time-intrinsic.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 // Defines the API between compiled code and the implementations of time-related
10 // intrinsic subroutines in the runtime library.
11 
12 #ifndef FORTRAN_RUNTIME_TIME_INTRINSIC_H_
13 #define FORTRAN_RUNTIME_TIME_INTRINSIC_H_
14 
15 #include "flang/Runtime/entry-names.h"
16 #include <cinttypes>
17 #include <cstddef>
18 
19 namespace Fortran::runtime {
20 
21 class Descriptor;
22 
23 extern "C" {
24 
25 // Lowering may need to cast this result to match the precision of the default
26 // real kind.
27 double RTNAME(CpuTime)();
28 
29 // Interface for the SYSTEM_CLOCK intrinsic. We break it up into 3 distinct
30 // function calls, one for each of SYSTEM_CLOCK's optional output arguments.
31 // Lowering converts the results to the types of the actual arguments,
32 // including the case of a real argument for COUNT_RATE=..
33 // The kind argument to SystemClockCount and SystemClockCountMax is the
34 // kind of the integer actual arguments, which are required to be the same
35 // when both appear.
36 std::int64_t RTNAME(SystemClockCount)(int kind = 8);
37 std::int64_t RTNAME(SystemClockCountRate)(int kind = 8);
38 std::int64_t RTNAME(SystemClockCountMax)(int kind = 8);
39 
40 // Interface for DATE_AND_TIME intrinsic.
41 void RTNAME(DateAndTime)(char *date, std::size_t dateChars, char *time,
42     std::size_t timeChars, char *zone, std::size_t zoneChars,
43     const char *source = nullptr, int line = 0,
44     const Descriptor *values = nullptr);
45 
46 void RTNAME(Etime)(const Descriptor *values, const Descriptor *time,
47     const char *sourceFile, int line);
48 
49 } // extern "C"
50 } // namespace Fortran::runtime
51 #endif // FORTRAN_RUNTIME_TIME_INTRINSIC_H_
52