1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
#ifndef CYGONCE_LIBC_TIME_TIME_H
#define CYGONCE_LIBC_TIME_TIME_H
/*===========================================================================
//
// time.h
//
// Date and time routines from ISO C section 7.12 and POSIX 1003.1
//
//===========================================================================
// ####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later
// version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License
// along with eCos; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// As a special exception, if other files instantiate templates or use
// macros or inline functions from this file, or you compile this file
// and link it with other works to produce a work based on this file,
// this file does not by itself cause the resulting work to be covered by
// the GNU General Public License. However the source code for this file
// must still be made available in accordance with section (3) of the GNU
// General Public License v2.
//
// This exception does not invalidate any other reasons why a work based
// on this file might be covered by the GNU General Public License.
// -------------------------------------------
// ####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-14
// Purpose: Provide definitions required by ISO C section 7.12 and
// POSIX 1003.1 8.3.4-8.3.7
// Description:
// Usage: Do not include this file directly - use #include <time.h>
//
//####DESCRIPTIONEND####
//
//=========================================================================*/
// CONFIGURATION
#include <pkgconf/libc_time.h> // C library configuration
// INCLUDES
#include <cyg/infra/cyg_type.h> // Common type definitions and support
// TYPE DEFINITIONS
// Define struct tm as per ISO C para 7.12.1
struct tm {
int tm_sec; // seconds after the minute - [0..61]
// (note 61 allows for two leap seconds)
int tm_min; // minutes after the hour - [0..59]
int tm_hour; // hours since midnight - [0..23]
int tm_mday; // days of the month - [1..31]
int tm_mon; // months since January - [0..11]
int tm_year; // years since 1900
int tm_wday; // days since Sunday - [0..6]
int tm_yday; // days since January 1 - [0..365]
int tm_isdst; // Daylight Saving Time flag - positive if DST is in
// effect, 0 if not in effect, and negative if the info
// is not available
};
// The following struct is used by the implementation-defined functions
// to manipulate the Daylight Savings Time state
typedef enum {
CYG_LIBC_TIME_DSTNA = -1,
CYG_LIBC_TIME_DSTOFF = 0,
CYG_LIBC_TIME_DSTON = 1
} Cyg_libc_time_dst;
// FUNCTION PROTOTYPES
#ifdef __cplusplus
extern "C" {
#endif
//===========================================================================
//
// POSIX 1003.1 functions
#ifdef CYGFUN_LIBC_TIME_POSIX
/////////////////////////////////
// asctime_r() - POSIX.1 8.3.4 //
/////////////////////////////////
//
// This returns a textual representation of a struct tm, and writes
// the string to return into __buf
//
extern char *
asctime_r( const struct tm *__timeptr, char *__buf );
///////////////////////////////
// ctime_r() - POSIX.1 8.3.5 //
///////////////////////////////
//
// This returns the equivalent of ctime() but writes to __buf
// to store the returned string
//
extern char *
ctime_r( const time_t *__timer, char *__buf );
////////////////////////////////
// gmtime_r() - POSIX.1 8.3.6 //
////////////////////////////////
//
// This converts a time_t into a struct tm expressed in UTC, and stores
// the result in the space occupied by __result
//
extern struct tm *
gmtime_r( const time_t *__timer, struct tm *__result );
///////////////////////////////////
// localtime_r() - POSIX.1 8.3.7 //
///////////////////////////////////
//
// This converts a time_t into a struct tm expressed in local time, and
// stores the result in the space occupied by __result
//
extern struct tm *
localtime_r( const time_t *__timer, struct tm *__result );
/////////////////////////////////////////////////////////
// strptime() -
/////////////////////////////////////////////////////////
//
// Parse a time string into a struct tm
//
extern char *
strptime( const char *__s, const char *__format,
struct tm *__timeptr) CYGBLD_ATTRIB_STRFTIME_FORMAT(2,0);
#endif // ifdef CYGFUN_LIBC_TIME_POSIX
//===========================================================================
// ISO C functions
// Time manipulation functions - ISO C 7.12.2
//////////////////////////////
// clock() - ISO C 7.12.2.1 //
//////////////////////////////
//
// Returns processor time used in "clock"s. For a single process,
// multi-threaded system this will just be the time since booting
//
extern clock_t
clock( void );
/////////////////////////////////
// difftime() - ISO C 7.12.2.2 //
/////////////////////////////////
//
// This returns (__time1 - __time0) in seconds
//
extern double
difftime( time_t __time1, time_t __time0 );
///////////////////////////////
// mktime() - ISO C 7.12.2.3 //
///////////////////////////////
//
// This converts a "struct tm" to a "time_t"
//
extern time_t
mktime( struct tm *__timeptr );
/////////////////////////////
// time() - ISO C 7.12.2.4 //
/////////////////////////////
//
// This returns calendar time as a time_t
//
extern time_t
time( time_t *__timer );
// Time conversion functions - ISO C 7.12.3
////////////////////////////////
// asctime() - ISO C 7.12.3.1 //
////////////////////////////////
//
// This returns a textual representation of a struct tm
//
extern char *
asctime( const struct tm *__timeptr );
//////////////////////////////
// ctime() - ISO C 7.12.3.2 //
//////////////////////////////
//
// This returns asctime(localtime(__timeptr))
//
extern char *
ctime( const time_t *__timer );
///////////////////////////////
// gmtime() - ISO C 7.12.3.3 //
///////////////////////////////
//
// This converts a time_t into a struct tm expressed in UTC
//
extern struct tm *
gmtime( const time_t *__timer );
//////////////////////////////////
// localtime() - ISO C 7.12.3.4 //
//////////////////////////////////
//
// This converts a time_t into a struct tm expressed in local time
//
extern struct tm *
localtime( const time_t *__timer );
/////////////////////////////////
// strftime() - ISO C 7.12.3.5 //
/////////////////////////////////
//
// This converts a string using format specifiers that signify various
// time-related quantities
//
extern size_t
strftime( char *__s, size_t __maxsize, const char *__format,
const struct tm *__timeptr) CYGBLD_ATTRIB_STRFTIME_FORMAT(3,0);
//===========================================================================
// Implementation-specific functions
////////////////////////////////////
// cyg_libc_time_setzoneoffsets() //
////////////////////////////////////
//
// This function sets the offsets used when Daylight Savings Time is enabled
// or disabled. The offsets are in time_t's
//
extern void
cyg_libc_time_setzoneoffsets( time_t __stdoffset, time_t __dstoffset );
////////////////////////////
// cyg_libc_time_setdst() //
////////////////////////////
//
// This function sets the state of Daylight Savings Time: on, off, or unknown
//
extern void
cyg_libc_time_setdst( Cyg_libc_time_dst __state );
////////////////////////////////////
// cyg_libc_time_getzoneoffsets() //
////////////////////////////////////
//
// This function retrieves the current state of the Daylight Savings Time
// and the offsets of both STD and DST
// The offsets are both in time_t's
//
extern Cyg_libc_time_dst
cyg_libc_time_getzoneoffsets( time_t *__stdoffset, time_t *__dstoffset );
/////////////////////////////
// cyg_libc_time_settime() //
/////////////////////////////
//
// This function sets the current time for the system. The time is
// specified as a time_t in UTC. It returns non-zero on error.
//
extern cyg_bool
cyg_libc_time_settime( time_t __utctime );
#ifdef __cplusplus
} // extern "C"
#endif
#include <cyg/libc/time/time.inl>
#endif // CYGONCE_LIBC_TIME_TIME_H multiple inclusion protection
// EOF time.h
|