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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [language/] [c/] [libc/] [time/] [current/] [include/] [time.h] - Blame information for rev 810

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

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

powered by: WebSVN 2.1.0

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