]>
Commit | Line | Data |
---|---|---|
d23b8f57 RK |
1 | ------------------------------------------------------------------------------ |
2 | -- -- | |
3 | -- GNAT RUN-TIME COMPONENTS -- | |
4 | -- -- | |
5 | -- A D A . R E A L _ T I M E -- | |
6 | -- -- | |
7 | -- S p e c -- | |
8 | -- -- | |
748086b7 | 9 | -- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- |
d23b8f57 RK |
10 | -- -- |
11 | -- This specification is derived from the Ada Reference Manual for use with -- | |
12 | -- GNAT. The copyright notice above, and the license provisions that follow -- | |
13 | -- apply solely to the contents of the part following the private keyword. -- | |
14 | -- -- | |
15 | -- GNAT is free software; you can redistribute it and/or modify it under -- | |
16 | -- terms of the GNU General Public License as published by the Free Soft- -- | |
748086b7 | 17 | -- ware Foundation; either version 3, or (at your option) any later ver- -- |
d23b8f57 RK |
18 | -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
19 | -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- | |
748086b7 JJ |
20 | -- or FITNESS FOR A PARTICULAR PURPOSE. -- |
21 | -- -- | |
22 | -- As a special exception under Section 7 of GPL version 3, you are granted -- | |
23 | -- additional permissions described in the GCC Runtime Library Exception, -- | |
24 | -- version 3.1, as published by the Free Software Foundation. -- | |
25 | -- -- | |
26 | -- You should have received a copy of the GNU General Public License and -- | |
27 | -- a copy of the GCC Runtime Library Exception along with this program; -- | |
28 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- | |
29 | -- <http://www.gnu.org/licenses/>. -- | |
d23b8f57 RK |
30 | -- -- |
31 | -- GNAT was originally developed by the GNAT team at New York University. -- | |
71ff80dc | 32 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
d23b8f57 RK |
33 | -- -- |
34 | ------------------------------------------------------------------------------ | |
35 | ||
36 | with System.Task_Primitives.Operations; | |
37 | pragma Elaborate_All (System.Task_Primitives.Operations); | |
38 | ||
39 | package Ada.Real_Time is | |
40 | ||
41 | type Time is private; | |
42 | Time_First : constant Time; | |
43 | Time_Last : constant Time; | |
44 | Time_Unit : constant := 10#1.0#E-9; | |
45 | ||
46 | type Time_Span is private; | |
47 | Time_Span_First : constant Time_Span; | |
fbf5a39b AC |
48 | Time_Span_Last : constant Time_Span; |
49 | Time_Span_Zero : constant Time_Span; | |
50 | Time_Span_Unit : constant Time_Span; | |
d23b8f57 RK |
51 | |
52 | Tick : constant Time_Span; | |
53 | function Clock return Time; | |
54 | ||
55 | function "+" (Left : Time; Right : Time_Span) return Time; | |
56 | function "+" (Left : Time_Span; Right : Time) return Time; | |
57 | function "-" (Left : Time; Right : Time_Span) return Time; | |
58 | function "-" (Left : Time; Right : Time) return Time_Span; | |
59 | ||
60 | function "<" (Left, Right : Time) return Boolean; | |
61 | function "<=" (Left, Right : Time) return Boolean; | |
62 | function ">" (Left, Right : Time) return Boolean; | |
63 | function ">=" (Left, Right : Time) return Boolean; | |
64 | ||
65 | function "+" (Left, Right : Time_Span) return Time_Span; | |
66 | function "-" (Left, Right : Time_Span) return Time_Span; | |
67 | function "-" (Right : Time_Span) return Time_Span; | |
68 | function "*" (Left : Time_Span; Right : Integer) return Time_Span; | |
69 | function "*" (Left : Integer; Right : Time_Span) return Time_Span; | |
70 | function "/" (Left, Right : Time_Span) return Integer; | |
71 | function "/" (Left : Time_Span; Right : Integer) return Time_Span; | |
72 | ||
73 | function "abs" (Right : Time_Span) return Time_Span; | |
74 | ||
75 | function "<" (Left, Right : Time_Span) return Boolean; | |
76 | function "<=" (Left, Right : Time_Span) return Boolean; | |
77 | function ">" (Left, Right : Time_Span) return Boolean; | |
78 | function ">=" (Left, Right : Time_Span) return Boolean; | |
79 | ||
80 | function To_Duration (TS : Time_Span) return Duration; | |
81 | function To_Time_Span (D : Duration) return Time_Span; | |
82 | ||
83 | function Nanoseconds (NS : Integer) return Time_Span; | |
84 | function Microseconds (US : Integer) return Time_Span; | |
85 | function Milliseconds (MS : Integer) return Time_Span; | |
86 | ||
f122ea71 RD |
87 | function Seconds (S : Integer) return Time_Span; |
88 | pragma Ada_05 (Seconds); | |
89 | ||
90 | function Minutes (M : Integer) return Time_Span; | |
91 | pragma Ada_05 (Minutes); | |
92 | ||
ffc5527f RD |
93 | -- Seconds_Count needs 64 bits, since Time has the full range of |
94 | -- Duration. The delta of Duration is 10 ** (-9), so the maximum | |
95 | -- number of seconds is 2**63/10**9 = 8*10**9 which does not quite | |
96 | -- fit in 32 bits. | |
84bfdde0 | 97 | |
ffc5527f | 98 | type Seconds_Count is range -2 ** 63 .. 2 ** 63 - 1; |
d23b8f57 RK |
99 | |
100 | procedure Split (T : Time; SC : out Seconds_Count; TS : out Time_Span); | |
101 | function Time_Of (SC : Seconds_Count; TS : Time_Span) return Time; | |
102 | ||
103 | private | |
104 | type Time is new Duration; | |
105 | ||
106 | Time_First : constant Time := Time'First; | |
107 | ||
108 | Time_Last : constant Time := Time'Last; | |
109 | ||
110 | type Time_Span is new Duration; | |
111 | ||
112 | Time_Span_First : constant Time_Span := Time_Span'First; | |
113 | ||
114 | Time_Span_Last : constant Time_Span := Time_Span'Last; | |
115 | ||
116 | Time_Span_Zero : constant Time_Span := 0.0; | |
117 | ||
118 | Time_Span_Unit : constant Time_Span := 10#1.0#E-9; | |
119 | ||
120 | Tick : constant Time_Span := | |
121 | Time_Span (System.Task_Primitives.Operations.RT_Resolution); | |
122 | ||
123 | -- Time and Time_Span are represented in 64-bit Duration value in | |
124 | -- in nanoseconds. For example, 1 second and 1 nanosecond is | |
125 | -- represented as the stored integer 1_000_000_001. | |
126 | ||
127 | pragma Import (Intrinsic, "<"); | |
128 | pragma Import (Intrinsic, "<="); | |
129 | pragma Import (Intrinsic, ">"); | |
130 | pragma Import (Intrinsic, ">="); | |
131 | pragma Import (Intrinsic, "abs"); | |
132 | ||
f122ea71 RD |
133 | pragma Inline (Microseconds); |
134 | pragma Inline (Milliseconds); | |
135 | pragma Inline (Nanoseconds); | |
136 | pragma Inline (Seconds); | |
137 | pragma Inline (Minutes); | |
138 | ||
d23b8f57 | 139 | end Ada.Real_Time; |