]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/gm2-libs-iso/wraptime.def
6422365e1e188564976ce9782e5240469621c1dc
[thirdparty/gcc.git] / gcc / m2 / gm2-libs-iso / wraptime.def
1 (* wraptime.def provides access to time primitives.
2
3 Copyright (C) 2009-2024 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
5
6 This file is part of GNU Modula-2.
7
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
21
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. *)
26
27 DEFINITION MODULE wraptime ;
28
29 (*
30 Title : wraptime
31 Author : Gaius Mulley
32 System : GNU Modula-2
33 Date : Sun Mar 1 21:41:29 2009
34 Revision : $Version$
35 Description: provides an interface to various time related
36 entities on the underlying host operating system.
37 It provides access to the glibc/libc functions:
38 gettimeofday, settimeofday and localtime_r.
39 *)
40
41 FROM SYSTEM IMPORT ADDRESS ;
42
43 TYPE
44 timeval = ADDRESS ;
45 timezone = ADDRESS ;
46 tm = ADDRESS ;
47
48
49 (*
50 InitTimeval - returns a newly created opaque type.
51 *)
52
53 PROCEDURE InitTimeval () : timeval ;
54
55
56 (*
57 KillTimeval - deallocates the memory associated with an
58 opaque type.
59 *)
60
61 PROCEDURE KillTimeval (tv: timeval) : timeval ;
62
63
64 (*
65 InitTimezone - returns a newly created opaque type.
66 *)
67
68 PROCEDURE InitTimezone () : timezone ;
69
70
71 (*
72 KillTimezone - deallocates the memory associated with an
73 opaque type.
74 *)
75
76 PROCEDURE KillTimezone (tv: timezone) : timezone ;
77
78
79 (*
80 InitTM - returns a newly created opaque type.
81 *)
82
83 PROCEDURE InitTM () : tm ;
84
85
86 (*
87 KillTM - deallocates the memory associated with an
88 opaque type.
89 *)
90
91 PROCEDURE KillTM (tv: tm) : tm ;
92
93
94 (*
95 gettimeofday - calls gettimeofday(2) with the same parameters, tv,
96 and, tz. It returns 0 on success.
97 *)
98
99 PROCEDURE gettimeofday (tv: timeval; tz: timezone) : INTEGER ;
100
101
102 (*
103 settimeofday - calls settimeofday(2) with the same parameters, tv,
104 and, tz. It returns 0 on success.
105 *)
106
107 PROCEDURE settimeofday (tv: timeval; tz: timezone) : INTEGER ;
108
109
110 (*
111 GetFractions - returns the tv_usec field inside the timeval structure
112 as a CARDINAL.
113 *)
114
115 PROCEDURE GetFractions (tv: timeval) : CARDINAL ;
116
117
118 (*
119 localtime_r - returns the tm parameter, m, after it has been assigned with
120 appropriate contents determined by, tv. Notice that
121 this procedure function expects, timeval, as its first
122 parameter and not a time_t (as expected by the posix
123 equivalent). This avoids having to expose a time_t
124 system dependant definition.
125 *)
126
127 PROCEDURE localtime_r (tv: timeval; m: tm) : tm ;
128
129
130 (*
131 GetYear - returns the year from the structure, m.
132 *)
133
134 PROCEDURE GetYear (m: tm) : CARDINAL ;
135
136
137 (*
138 GetMonth - returns the month from the structure, m.
139 *)
140
141 PROCEDURE GetMonth (m: tm) : CARDINAL ;
142
143
144 (*
145 GetDay - returns the day of the month from the structure, m.
146 *)
147
148 PROCEDURE GetDay (m: tm) : CARDINAL ;
149
150
151 (*
152 GetHour - returns the hour of the day from the structure, m.
153 *)
154
155 PROCEDURE GetHour (m: tm) : CARDINAL ;
156
157
158 (*
159 GetMinute - returns the minute within the hour from the structure, m.
160 *)
161
162 PROCEDURE GetMinute (m: tm) : CARDINAL ;
163
164
165 (*
166 GetSecond - returns the seconds in the minute from the structure, m.
167 The return value will always be in the range 0..59.
168 A leap minute of value 60 will be truncated to 59.
169 *)
170
171 PROCEDURE GetSecond (m: tm) : CARDINAL ;
172
173
174 (*
175 GetSummerTime - returns a boolean indicating whether summer time is
176 set.
177 *)
178
179 PROCEDURE GetSummerTime (tz: timezone) : BOOLEAN ;
180
181
182 (*
183 GetDST - returns the number of minutes west of GMT.
184 *)
185
186 PROCEDURE GetDST (tz: timezone) : INTEGER ;
187
188
189 (*
190 SetTimeval - sets the fields in timeval, tv, with:
191 second, minute, hour, day, month, year, fractions.
192 *)
193
194 PROCEDURE SetTimeval (tv: timeval;
195 second, minute, hour, day,
196 month, year, yday, wday, isdst: CARDINAL) ;
197
198
199 (*
200 SetTimezone - set the timezone field inside timeval, tv.
201 *)
202
203 PROCEDURE SetTimezone (tv: timeval;
204 zone: CARDINAL; minuteswest: INTEGER) ;
205
206
207 END wraptime.