Daily bump.
[official-gcc.git] / gcc / ada / a-reatim.ads
blob7abbeb843d2e1d77e765abbb8a884e1a1ac5a940
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 -- --
9 -- Copyright (C) 1992-2015, Free Software Foundation, Inc. --
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- --
17 -- ware Foundation; either version 3, or (at your option) any later ver- --
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 --
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/>. --
30 -- --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- Extensive contributions were provided by Ada Core Technologies Inc. --
33 -- --
34 ------------------------------------------------------------------------------
36 with System.Task_Primitives.Operations;
37 pragma Elaborate_All (System.Task_Primitives.Operations);
39 package Ada.Real_Time is
41 pragma Compile_Time_Error
42 (Duration'Size /= 64,
43 "this version of Ada.Real_Time requires 64-bit Duration");
45 type Time is private;
46 Time_First : constant Time;
47 Time_Last : constant Time;
48 Time_Unit : constant := 10#1.0#E-9;
50 type Time_Span is private;
51 Time_Span_First : constant Time_Span;
52 Time_Span_Last : constant Time_Span;
53 Time_Span_Zero : constant Time_Span;
54 Time_Span_Unit : constant Time_Span;
56 Tick : constant Time_Span;
57 function Clock return Time;
59 function "+" (Left : Time; Right : Time_Span) return Time;
60 function "+" (Left : Time_Span; Right : Time) return Time;
61 function "-" (Left : Time; Right : Time_Span) return Time;
62 function "-" (Left : Time; Right : Time) return Time_Span;
64 function "<" (Left, Right : Time) return Boolean;
65 function "<=" (Left, Right : Time) return Boolean;
66 function ">" (Left, Right : Time) return Boolean;
67 function ">=" (Left, Right : Time) return Boolean;
69 function "+" (Left, Right : Time_Span) return Time_Span;
70 function "-" (Left, Right : Time_Span) return Time_Span;
71 function "-" (Right : Time_Span) return Time_Span;
72 function "*" (Left : Time_Span; Right : Integer) return Time_Span;
73 function "*" (Left : Integer; Right : Time_Span) return Time_Span;
74 function "/" (Left, Right : Time_Span) return Integer;
75 function "/" (Left : Time_Span; Right : Integer) return Time_Span;
77 function "abs" (Right : Time_Span) return Time_Span;
79 function "<" (Left, Right : Time_Span) return Boolean;
80 function "<=" (Left, Right : Time_Span) return Boolean;
81 function ">" (Left, Right : Time_Span) return Boolean;
82 function ">=" (Left, Right : Time_Span) return Boolean;
84 function To_Duration (TS : Time_Span) return Duration;
85 function To_Time_Span (D : Duration) return Time_Span;
87 function Nanoseconds (NS : Integer) return Time_Span;
88 function Microseconds (US : Integer) return Time_Span;
89 function Milliseconds (MS : Integer) return Time_Span;
91 function Seconds (S : Integer) return Time_Span;
92 pragma Ada_05 (Seconds);
94 function Minutes (M : Integer) return Time_Span;
95 pragma Ada_05 (Minutes);
97 type Seconds_Count is new Long_Long_Integer;
98 -- Seconds_Count needs 64 bits, since the type Time has the full range of
99 -- Duration. The delta of Duration is 10 ** (-9), so the maximum number of
100 -- seconds is 2**63/10**9 = 8*10**9 which does not quite fit in 32 bits.
101 -- However, rather than make this explicitly 64-bits we derive from
102 -- Long_Long_Integer. In normal usage this will have the same effect. But
103 -- in the case of CodePeer with a target configuration file with a maximum
104 -- integer size of 32, it allows analysis of this unit.
106 procedure Split (T : Time; SC : out Seconds_Count; TS : out Time_Span);
107 function Time_Of (SC : Seconds_Count; TS : Time_Span) return Time;
109 private
110 -- Time and Time_Span are represented in 64-bit Duration value in
111 -- nanoseconds. For example, 1 second and 1 nanosecond is represented
112 -- as the stored integer 1_000_000_001. This is for the 64-bit Duration
113 -- case, not clear if this also is used for 32-bit Duration values.
115 type Time is new Duration;
117 Time_First : constant Time := Time'First;
119 Time_Last : constant Time := Time'Last;
121 type Time_Span is new Duration;
123 Time_Span_First : constant Time_Span := Time_Span'First;
125 Time_Span_Last : constant Time_Span := Time_Span'Last;
127 Time_Span_Zero : constant Time_Span := 0.0;
129 Time_Span_Unit : constant Time_Span := 10#1.0#E-9;
131 Tick : constant Time_Span :=
132 Time_Span (System.Task_Primitives.Operations.RT_Resolution);
134 pragma Import (Intrinsic, "<");
135 pragma Import (Intrinsic, "<=");
136 pragma Import (Intrinsic, ">");
137 pragma Import (Intrinsic, ">=");
138 pragma Import (Intrinsic, "abs");
140 pragma Inline (Microseconds);
141 pragma Inline (Milliseconds);
142 pragma Inline (Nanoseconds);
143 pragma Inline (Seconds);
144 pragma Inline (Minutes);
146 end Ada.Real_Time;