OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [ada/] [a-calend-vms.ads] - Blame information for rev 839

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 706 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT RUN-TIME COMPONENTS                         --
4
--                                                                          --
5
--                         A D A . C A L E N D A R                          --
6
--                                                                          --
7
--                                 S p e c                                  --
8
--                                                                          --
9
--          Copyright (C) 1992-2009, 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
------------------------------------------------------------------------------
35
 
36
--  This is the Alpha/VMS version
37
 
38
with System.OS_Primitives;
39
 
40
package Ada.Calendar is
41
 
42
   package OSP renames System.OS_Primitives;
43
 
44
   type Time is private;
45
 
46
   --  Declarations representing limits of allowed local time values. Note
47
   --  that these do NOT constrain the possible stored values of time which
48
   --  may well permit a larger range of times (this is explicitly allowed
49
   --  in Ada 95).
50
 
51
   subtype Year_Number  is Integer range 1901 .. 2399;
52
   subtype Month_Number is Integer range 1 .. 12;
53
   subtype Day_Number   is Integer range 1 .. 31;
54
 
55
   subtype Day_Duration is Duration range 0.0 .. 86_400.0;
56
 
57
   function Clock return Time;
58
 
59
   function Year    (Date : Time) return Year_Number;
60
   function Month   (Date : Time) return Month_Number;
61
   function Day     (Date : Time) return Day_Number;
62
   function Seconds (Date : Time) return Day_Duration;
63
 
64
   procedure Split
65
     (Date    : Time;
66
      Year    : out Year_Number;
67
      Month   : out Month_Number;
68
      Day     : out Day_Number;
69
      Seconds : out Day_Duration);
70
 
71
   function Time_Of
72
     (Year    : Year_Number;
73
      Month   : Month_Number;
74
      Day     : Day_Number;
75
      Seconds : Day_Duration := 0.0) return Time;
76
 
77
   function "+" (Left : Time;     Right : Duration) return Time;
78
   function "+" (Left : Duration; Right : Time)     return Time;
79
   function "-" (Left : Time;     Right : Duration) return Time;
80
   function "-" (Left : Time;     Right : Time)     return Duration;
81
 
82
   function "<"  (Left, Right : Time) return Boolean;
83
   function "<=" (Left, Right : Time) return Boolean;
84
   function ">"  (Left, Right : Time) return Boolean;
85
   function ">=" (Left, Right : Time) return Boolean;
86
 
87
   Time_Error : exception;
88
 
89
private
90
   pragma Inline (Clock);
91
 
92
   pragma Inline (Year);
93
   pragma Inline (Month);
94
   pragma Inline (Day);
95
 
96
   pragma Inline ("+");
97
   pragma Inline ("-");
98
 
99
   pragma Inline ("<");
100
   pragma Inline ("<=");
101
   pragma Inline (">");
102
   pragma Inline (">=");
103
 
104
   --  Although the units are 100 nanoseconds, for the purpose of better
105
   --  readability, this unit will be called "mili".
106
 
107
   Mili         : constant := 10_000_000;
108
   Mili_F       : constant := 10_000_000.0;
109
   Milis_In_Day : constant := 864_000_000_000;
110
   Secs_In_Day  : constant := 86_400;
111
 
112
   --  Time is represented as the number of 100-nanosecond (ns) units from the
113
   --  system base date and time 1858-11-17 0.0 (the Smithsonian base date and
114
   --  time for the astronomic calendar).
115
 
116
   --  The time value stored is typically a UTC value, as provided in standard
117
   --  Unix environments. If this is the case then Split and Time_Of perform
118
   --  required conversions to and from local times.
119
 
120
   --  Notwithstanding this definition, Time is not quite the same as OS_Time.
121
   --  Relative Time is positive, whereas relative OS_Time is negative,
122
   --  but this declaration makes for easier conversion.
123
 
124
   type Time is new OSP.OS_Time;
125
 
126
   Days_In_Month : constant array (Month_Number) of Day_Number :=
127
                     (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
128
 
129
   Invalid_Time_Zone_Offset : Long_Integer;
130
   pragma Import (C, Invalid_Time_Zone_Offset, "__gnat_invalid_tzoff");
131
 
132
   function Is_Leap (Year : Year_Number) return Boolean;
133
   --  Determine whether a given year is leap
134
 
135
   --  The following packages provide a target independent interface to the
136
   --  children of Calendar - Arithmetic, Formatting and Time_Zones.
137
 
138
   --  NOTE: Delays does not need a target independent interface because
139
   --  VMS already has a target specific file for that package.
140
 
141
   ---------------------------
142
   -- Arithmetic_Operations --
143
   ---------------------------
144
 
145
   package Arithmetic_Operations is
146
 
147
      function Add (Date : Time; Days : Long_Integer) return Time;
148
      --  Add a certain number of days to a time value
149
 
150
      procedure Difference
151
        (Left         : Time;
152
         Right        : Time;
153
         Days         : out Long_Integer;
154
         Seconds      : out Duration;
155
         Leap_Seconds : out Integer);
156
      --  Calculate the difference between two time values in terms of days,
157
      --  seconds and leap seconds elapsed. The leap seconds are not included
158
      --  in the seconds returned. If Left is greater than Right, the returned
159
      --  values are positive, negative otherwise.
160
 
161
      function Subtract (Date : Time; Days : Long_Integer) return Time;
162
      --  Subtract a certain number of days from a time value
163
 
164
   end Arithmetic_Operations;
165
 
166
   ---------------------------
167
   -- Conversion_Operations --
168
   ---------------------------
169
 
170
   package Conversion_Operations is
171
      function To_Ada_Time (Unix_Time : Long_Integer) return Time;
172
      --  Unix to Ada Epoch conversion
173
 
174
      function To_Ada_Time
175
        (tm_year  : Integer;
176
         tm_mon   : Integer;
177
         tm_day   : Integer;
178
         tm_hour  : Integer;
179
         tm_min   : Integer;
180
         tm_sec   : Integer;
181
         tm_isdst : Integer) return Time;
182
      --  Struct tm to Ada Epoch conversion
183
 
184
      function To_Duration
185
        (tv_sec  : Long_Integer;
186
         tv_nsec : Long_Integer) return Duration;
187
      --  Struct timespec to Duration conversion
188
 
189
      procedure To_Struct_Timespec
190
        (D       : Duration;
191
         tv_sec  : out Long_Integer;
192
         tv_nsec : out Long_Integer);
193
      --  Duration to struct timespec conversion
194
 
195
      procedure To_Struct_Tm
196
        (T       : Time;
197
         tm_year : out Integer;
198
         tm_mon  : out Integer;
199
         tm_day  : out Integer;
200
         tm_hour : out Integer;
201
         tm_min  : out Integer;
202
         tm_sec  : out Integer);
203
      --  Time to struct tm conversion
204
 
205
      function To_Unix_Time (Ada_Time : Time) return Long_Integer;
206
      --  Ada to Unix Epoch conversion
207
 
208
   end Conversion_Operations;
209
 
210
   ---------------------------
211
   -- Formatting_Operations --
212
   ---------------------------
213
 
214
   package Formatting_Operations is
215
 
216
      function Day_Of_Week (Date : Time) return Integer;
217
      --  Determine which day of week Date falls on. The returned values are
218
      --  within the range of 0 .. 6 (Monday .. Sunday).
219
 
220
      procedure Split
221
        (Date      : Time;
222
         Year      : out Year_Number;
223
         Month     : out Month_Number;
224
         Day       : out Day_Number;
225
         Day_Secs  : out Day_Duration;
226
         Hour      : out Integer;
227
         Minute    : out Integer;
228
         Second    : out Integer;
229
         Sub_Sec   : out Duration;
230
         Leap_Sec  : out Boolean;
231
         Is_Ada_05 : Boolean;
232
         Time_Zone : Long_Integer);
233
      --  Split a time value into its components. Set Is_Ada_05 to use the
234
      --  local time zone (the value in Time_Zone is ignored) when splitting
235
      --  a time value.
236
 
237
      function Time_Of
238
        (Year         : Year_Number;
239
         Month        : Month_Number;
240
         Day          : Day_Number;
241
         Day_Secs     : Day_Duration;
242
         Hour         : Integer;
243
         Minute       : Integer;
244
         Second       : Integer;
245
         Sub_Sec      : Duration;
246
         Leap_Sec     : Boolean := False;
247
         Use_Day_Secs : Boolean := False;
248
         Is_Ada_05    : Boolean := False;
249
         Time_Zone    : Long_Integer := 0) return Time;
250
      --  Given all the components of a date, return the corresponding time
251
      --  value. Set Use_Day_Secs to use the value in Day_Secs, otherwise the
252
      --  day duration will be calculated from Hour, Minute, Second and Sub_
253
      --  Sec. Set Is_Ada_05 to use the local time zone (the value in formal
254
      --  Time_Zone is ignored) when building a time value and to verify the
255
      --  validity of a requested leap second.
256
 
257
   end Formatting_Operations;
258
 
259
   ---------------------------
260
   -- Time_Zones_Operations --
261
   ---------------------------
262
 
263
   package Time_Zones_Operations is
264
 
265
      function UTC_Time_Offset (Date : Time) return Long_Integer;
266
      --  Return the offset in seconds from UTC
267
 
268
   end Time_Zones_Operations;
269
 
270
end Ada.Calendar;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.