annotate gcc/ada/libgnat/a-calcon.ads @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- A D A . C A L E N D A R . C O N V E R S I O N S --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 2008-2019, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This package provides various routines for conversion between Ada and Unix
kono
parents:
diff changeset
33 -- time models - Time, Duration, struct tm and struct timespec.
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 with Interfaces.C;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
36 with Interfaces.C.Extensions;
111
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 package Ada.Calendar.Conversions is
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 function To_Ada_Time (Unix_Time : Interfaces.C.long) return Time;
kono
parents:
diff changeset
41 -- Convert a time value represented as number of seconds since the
kono
parents:
diff changeset
42 -- Unix Epoch to a time value relative to an Ada implementation-defined
kono
parents:
diff changeset
43 -- Epoch. The units of the result are nanoseconds on all targets. Raises
kono
parents:
diff changeset
44 -- Time_Error if the result cannot fit into a Time value.
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 function To_Ada_Time
kono
parents:
diff changeset
47 (tm_year : Interfaces.C.int;
kono
parents:
diff changeset
48 tm_mon : Interfaces.C.int;
kono
parents:
diff changeset
49 tm_day : Interfaces.C.int;
kono
parents:
diff changeset
50 tm_hour : Interfaces.C.int;
kono
parents:
diff changeset
51 tm_min : Interfaces.C.int;
kono
parents:
diff changeset
52 tm_sec : Interfaces.C.int;
kono
parents:
diff changeset
53 tm_isdst : Interfaces.C.int) return Time;
kono
parents:
diff changeset
54 -- Convert a time value expressed in Unix-like fields of struct tm into
kono
parents:
diff changeset
55 -- a Time value relative to the Ada Epoch. The ranges of the formals are
kono
parents:
diff changeset
56 -- as follows:
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 -- tm_year -- years since 1900
kono
parents:
diff changeset
59 -- tm_mon -- months since January [0 .. 11]
kono
parents:
diff changeset
60 -- tm_day -- day of the month [1 .. 31]
kono
parents:
diff changeset
61 -- tm_hour -- hours since midnight [0 .. 24]
kono
parents:
diff changeset
62 -- tm_min -- minutes after the hour [0 .. 59]
kono
parents:
diff changeset
63 -- tm_sec -- seconds after the minute [0 .. 60]
kono
parents:
diff changeset
64 -- tm_isdst -- Daylight Savings Time flag [-1 .. 1]
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 -- The returned value is in UTC and may or may not contain leap seconds
kono
parents:
diff changeset
67 -- depending on whether binder flag "-y" was used. Raises Time_Error if
kono
parents:
diff changeset
68 -- the input values are out of the defined ranges or if tm_sec equals 60
kono
parents:
diff changeset
69 -- and the instance in time is not a leap second occurrence.
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 function To_Duration
kono
parents:
diff changeset
72 (tv_sec : Interfaces.C.long;
kono
parents:
diff changeset
73 tv_nsec : Interfaces.C.long) return Duration;
kono
parents:
diff changeset
74 -- Convert an elapsed time value expressed in Unix-like fields of struct
kono
parents:
diff changeset
75 -- timespec into a Duration value. The expected ranges are:
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 -- tv_sec - seconds
kono
parents:
diff changeset
78 -- tv_nsec - nanoseconds
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 procedure To_Struct_Timespec
kono
parents:
diff changeset
81 (D : Duration;
kono
parents:
diff changeset
82 tv_sec : out Interfaces.C.long;
kono
parents:
diff changeset
83 tv_nsec : out Interfaces.C.long);
kono
parents:
diff changeset
84 -- Convert a Duration value into the constituents of struct timespec.
kono
parents:
diff changeset
85 -- Formal tv_sec denotes seconds and tv_nsecs denotes nanoseconds.
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 procedure To_Struct_Tm
kono
parents:
diff changeset
88 (T : Time;
kono
parents:
diff changeset
89 tm_year : out Interfaces.C.int;
kono
parents:
diff changeset
90 tm_mon : out Interfaces.C.int;
kono
parents:
diff changeset
91 tm_day : out Interfaces.C.int;
kono
parents:
diff changeset
92 tm_hour : out Interfaces.C.int;
kono
parents:
diff changeset
93 tm_min : out Interfaces.C.int;
kono
parents:
diff changeset
94 tm_sec : out Interfaces.C.int);
kono
parents:
diff changeset
95 -- Convert a Time value set in the Ada Epoch into the constituents of
kono
parents:
diff changeset
96 -- struct tm. The ranges of the out formals are as follows:
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 -- tm_year -- years since 1900
kono
parents:
diff changeset
99 -- tm_mon -- months since January [0 .. 11]
kono
parents:
diff changeset
100 -- tm_day -- day of the month [1 .. 31]
kono
parents:
diff changeset
101 -- tm_hour -- hours since midnight [0 .. 24]
kono
parents:
diff changeset
102 -- tm_min -- minutes after the hour [0 .. 59]
kono
parents:
diff changeset
103 -- tm_sec -- seconds after the minute [0 .. 60]
kono
parents:
diff changeset
104 -- tm_isdst -- Daylight Savings Time flag [-1 .. 1]
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 -- The input date is considered to be in UTC
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 function To_Unix_Time (Ada_Time : Time) return Interfaces.C.long;
kono
parents:
diff changeset
109 -- Convert a time value represented as number of time units since the Ada
kono
parents:
diff changeset
110 -- implementation-defined Epoch to a value relative to the Unix Epoch. The
kono
parents:
diff changeset
111 -- units of the result are seconds. Raises Time_Error if the result cannot
kono
parents:
diff changeset
112 -- fit into a Time value.
kono
parents:
diff changeset
113
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
114 function To_Unix_Nano_Time
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
115 (Ada_Time : Time) return Interfaces.C.Extensions.long_long;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
116 -- Convert a time value represented as number of time units since the Ada
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
117 -- implementation-defined Epoch to a value relative to the Unix Epoch. The
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
118 -- units of the result are nanoseconds. Raises Time_Error if the result
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
119 -- cannot fit into a Time value.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
120
111
kono
parents:
diff changeset
121 end Ada.Calendar.Conversions;