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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [language/] [c/] [libc/] [time/] [v2_0/] [include/] [time.h] - Blame information for rev 279

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

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

powered by: WebSVN 2.1.0

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