Mercurial > flash_v2
annotate packages/language/c/libc/current/include/time.h @ 66:bf00f99aec69 ecos-sw-2000-02-02
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
| author | jlarmour |
|---|---|
| date | Wed, 02 Feb 2000 19:57:02 +0000 |
| parents | c38311975d4f |
| children |
| rev | line source |
|---|---|
| 0 | 1 #ifndef CYGONCE_LIBC_TIME_H |
| 2 #define CYGONCE_LIBC_TIME_H | |
| 3 //=========================================================================== | |
| 4 // | |
| 5 // time.h | |
| 6 // | |
| 2 | 7 // Date and time routines from ISO C section 7.12 and POSIX 1003.1 |
| 0 | 8 // |
| 9 //=========================================================================== | |
| 10 //####COPYRIGHTBEGIN#### | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
11 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
12 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
13 // The contents of this file are subject to the Red Hat eCos Public License |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
14 // Version 1.1 (the "License"); you may not use this file except in |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
15 // compliance with the License. You may obtain a copy of the License at |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
16 // http://www.redhat.com/ |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
17 // |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
18 // Software distributed under the License is distributed on an "AS IS" |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
19 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
20 // License for the specific language governing rights and limitations under |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
21 // the License. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
22 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
23 // The Original Code is eCos - Embedded Configurable Operating System, |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
24 // released September 30, 1998. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
25 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
26 // The Initial Developer of the Original Code is Red Hat. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
27 // Portions created by Red Hat are |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
28 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
29 // All Rights Reserved. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
30 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
31 // |
| 0 | 32 //####COPYRIGHTEND#### |
| 33 //=========================================================================== | |
| 34 //#####DESCRIPTIONBEGIN#### | |
| 35 // | |
| 2 | 36 // Author(s): jlarmour |
| 37 // Contributors: jlarmour | |
| 38 // Date: 1999-02-25 | |
| 39 // Purpose: Provide definitions required by ISO C section 7.12 and | |
| 40 // POSIX 1003.1 8.3.4-8.3.7 | |
| 0 | 41 // Description: |
| 2 | 42 // Usage: #include <time.h> |
| 0 | 43 // |
| 44 //####DESCRIPTIONEND#### | |
| 45 // | |
| 46 //=========================================================================== | |
| 47 | |
| 48 // CONFIGURATION | |
| 49 | |
| 2 | 50 #include <pkgconf/libc.h> // C library configuration |
| 0 | 51 |
| 52 // INCLUDES | |
| 53 | |
| 2 | 54 #include <cyg/infra/cyg_type.h> // Common type definitions and support |
| 55 #include <stddef.h> // <time.h> is required to provide NULL | |
| 56 // and size_t, so we get them from compiler | |
| 0 | 57 |
| 58 // CONSTANTS | |
| 59 | |
| 60 // What to divide clock_t by to get seconds (para 7.12.1) | |
| 2 | 61 // According to CAE XSH, Issue 4, V2, CLOCKS_PER_SEC must be 1 million on all |
| 62 // XSI-conformant systems | |
| 63 #define CLOCKS_PER_SEC 1000000 | |
| 0 | 64 |
| 65 // TYPE DEFINITIONS | |
| 66 | |
| 2 | 67 // Define clock_t as per ISO C para 7.12.1 |
| 68 // We make it very big since CLOCKS_PER_SEC is so large - this should last | |
| 69 // for 584942 years :-) An int32 would only last a little over an hour :-( | |
| 0 | 70 typedef cyg_int64 clock_t; |
| 71 | |
| 2 | 72 // Define time_t as per ISO C para 7.12.1 |
| 73 // In the implementation we give it the meaning of seconds since the | |
| 74 // Epoch (00:00:00 GMT, 1970-01-01), but don't rely on this - always use | |
| 75 // the type opaquely | |
| 76 // A 32-bit value will overflow in the year 2038. Hopefully we will have | |
| 77 // moved forward from 32-bit CPUs by then, so making it a cyg_count* type | |
| 78 // may suffice ;-) | |
| 0 | 79 typedef cyg_count32 time_t; |
| 2 | 80 #define __time_t_defined // FIXME: this is temporary to stop newlib's |
| 81 // <sys/types.h> complaining. This should be resolved | |
| 82 // properly and a new <sys/types.h> provided | |
| 0 | 83 |
| 2 | 84 // Define struct tm as per ISO C para 7.12.1 |
| 0 | 85 struct tm { |
| 2 | 86 int tm_sec; // seconds after the minute - [0..61] |
| 87 // (note 61 allows for two leap seconds) | |
| 0 | 88 int tm_min; // minutes after the hour - [0..59] |
| 89 int tm_hour; // hours since midnight - [0..23] | |
| 90 int tm_mday; // days of the month - [1..31] | |
| 91 int tm_mon; // months since January - [0..11] | |
| 92 int tm_year; // years since 1900 | |
| 93 int tm_wday; // days since Sunday - [0..6] | |
| 94 int tm_yday; // days since January 1 - [0..365] | |
| 95 int tm_isdst; // Daylight Saving Time flag - positive if DST is in | |
| 96 // effect, 0 if not in effect, and negative if the info | |
| 97 // is not available | |
| 98 }; | |
| 99 | |
| 2 | 100 // The following struct is used by the implementation-defined functions |
| 101 // to manipulate the Daylight Savings Time state | |
| 102 typedef enum { | |
| 103 CYG_LIBC_TIME_DSTNA = -1, | |
| 104 CYG_LIBC_TIME_DSTOFF = 0, | |
| 105 CYG_LIBC_TIME_DSTON = 1 | |
| 106 } Cyg_libc_time_dst; | |
| 107 | |
| 0 | 108 // FUNCTION PROTOTYPES |
| 109 | |
| 2 | 110 #ifdef __cplusplus |
| 111 extern "C" { | |
| 112 #endif | |
| 113 | |
| 114 //=========================================================================== | |
| 115 // | |
| 116 // POSIX 1003.1 functions | |
| 117 | |
| 118 #ifdef CYGFUN_LIBC_TIME_POSIX | |
| 119 | |
| 120 ///////////////////////////////// | |
| 121 // asctime_r() - POSIX.1 8.3.4 // | |
| 122 ///////////////////////////////// | |
| 123 // | |
| 124 // This returns a textual representation of a struct tm, and writes | |
| 125 // the string to return into __buf | |
| 126 // | |
| 127 | |
| 128 extern char * | |
| 129 asctime_r( const struct tm *__timeptr, char *__buf ); | |
| 130 | |
| 131 /////////////////////////////// | |
| 132 // ctime_r() - POSIX.1 8.3.5 // | |
| 133 /////////////////////////////// | |
| 134 // | |
| 135 // This returns the equivalent of ctime() but writes to __buf | |
| 136 // to store the returned string | |
| 137 // | |
| 138 | |
| 139 extern char * | |
| 140 ctime_r( const time_t *__timer, char *__buf ); | |
| 141 | |
| 142 //////////////////////////////// | |
| 143 // gmtime_r() - POSIX.1 8.3.6 // | |
| 144 //////////////////////////////// | |
| 145 // | |
| 146 // This converts a time_t into a struct tm expressed in UTC, and stores | |
| 147 // the result in the space occupied by __result | |
| 148 // | |
| 149 | |
| 150 extern struct tm * | |
| 151 gmtime_r( const time_t *__timer, struct tm *__result ); | |
| 152 | |
| 153 /////////////////////////////////// | |
| 154 // localtime_r() - POSIX.1 8.3.7 // | |
| 155 /////////////////////////////////// | |
| 156 // | |
| 157 // This converts a time_t into a struct tm expressed in local time, and | |
| 158 // stores the result in the space occupied by __result | |
| 159 // | |
| 160 | |
| 161 extern struct tm * | |
| 162 localtime_r( const time_t *__timer, struct tm *__result ); | |
| 163 | |
| 164 | |
| 165 #endif // ifdef CYGFUN_LIBC_TIME_POSIX | |
| 166 | |
| 0 | 167 //=========================================================================== |
| 168 | |
| 2 | 169 // ISO C functions |
| 170 | |
| 171 // Time manipulation functions - ISO C 7.12.2 | |
| 0 | 172 |
| 2 | 173 ////////////////////////////// |
| 174 // clock() - ISO C 7.12.2.1 // | |
| 175 ////////////////////////////// | |
| 176 // | |
| 177 // Returns processor time used in "clock"s. For a single process, | |
| 178 // multi-threaded system this will just be the time since booting | |
| 179 // | |
| 180 | |
| 181 extern clock_t | |
| 0 | 182 clock( void ); |
| 183 | |
| 2 | 184 ///////////////////////////////// |
| 185 // difftime() - ISO C 7.12.2.2 // | |
| 186 ///////////////////////////////// | |
| 187 // | |
| 188 // This returns (__time1 - __time0) in seconds | |
| 189 // | |
| 190 | |
| 191 extern double | |
| 192 difftime( time_t __time1, time_t __time0 ); | |
| 193 | |
| 194 /////////////////////////////// | |
| 195 // mktime() - ISO C 7.12.2.3 // | |
| 196 /////////////////////////////// | |
| 197 // | |
| 198 // This converts a "struct tm" to a "time_t" | |
| 199 // | |
| 200 | |
| 201 extern time_t | |
| 202 mktime( struct tm *__timeptr ); | |
| 203 | |
| 204 ///////////////////////////// | |
| 205 // time() - ISO C 7.12.2.4 // | |
| 206 ///////////////////////////// | |
| 207 // | |
| 208 // This returns calendar time as a time_t | |
| 209 // | |
| 210 | |
| 211 extern time_t | |
| 212 time( time_t *__timer ); | |
| 213 | |
| 214 // Time conversion functions - ISO C 7.12.3 | |
| 215 | |
| 216 //////////////////////////////// | |
| 217 // asctime() - ISO C 7.12.3.1 // | |
| 218 //////////////////////////////// | |
| 219 // | |
| 220 // This returns a textual representation of a struct tm | |
| 221 // | |
| 222 | |
| 223 extern char * | |
| 224 asctime( const struct tm *__timeptr ); | |
| 225 | |
| 226 ////////////////////////////// | |
| 227 // ctime() - ISO C 7.12.3.2 // | |
| 228 ////////////////////////////// | |
| 229 // | |
| 230 // This returns asctime(localtime(__timeptr)) | |
| 231 // | |
| 232 | |
| 233 extern char * | |
| 234 ctime( const time_t *__timer ); | |
| 235 | |
| 236 /////////////////////////////// | |
| 237 // gmtime() - ISO C 7.12.3.3 // | |
| 238 /////////////////////////////// | |
| 239 // | |
| 240 // This converts a time_t into a struct tm expressed in UTC | |
| 241 // | |
| 242 | |
| 243 extern struct tm * | |
| 244 gmtime( const time_t *__timer ); | |
| 245 | |
| 246 ////////////////////////////////// | |
| 247 // localtime() - ISO C 7.12.3.4 // | |
| 248 ////////////////////////////////// | |
| 249 // | |
| 250 // This converts a time_t into a struct tm expressed in local time | |
| 251 // | |
| 252 | |
| 253 extern struct tm * | |
| 254 localtime( const time_t *__timer ); | |
| 255 | |
| 256 ///////////////////////////////// | |
| 257 // strftime() - ISO C 7.12.3.5 // | |
| 258 ///////////////////////////////// | |
| 259 // | |
| 260 // This converts a string using format specifiers that signify various | |
| 261 // time-related quantities | |
| 262 // | |
| 263 | |
| 264 extern size_t | |
| 265 strftime( char *__s, size_t __maxsize, const char *__format, | |
| 266 const struct tm *__timeptr) CYGPRI_LIBC_ATTRIB_FORMAT_STRFTIME; | |
| 267 | |
| 268 //=========================================================================== | |
| 269 | |
| 270 // Implementation-specific functions | |
| 271 | |
| 272 //////////////////////////////////// | |
| 273 // cyg_libc_time_setzoneoffsets() // | |
| 274 //////////////////////////////////// | |
| 275 // | |
| 276 // This function sets the offsets used when Daylight Savings Time is enabled | |
| 277 // or disabled. The offsets are in time_t's | |
| 278 // | |
| 279 | |
| 280 extern void | |
| 281 cyg_libc_time_setzoneoffsets( time_t __stdoffset, time_t __dstoffset ); | |
| 282 | |
| 283 //////////////////////////// | |
| 284 // cyg_libc_time_setdst() // | |
| 285 //////////////////////////// | |
| 286 // | |
| 287 // This function sets the state of Daylight Savings Time: on, off, or unknown | |
| 288 // | |
| 289 | |
| 290 extern void | |
| 291 cyg_libc_time_setdst( Cyg_libc_time_dst __state ); | |
| 292 | |
| 293 | |
| 294 //////////////////////////////////// | |
| 295 // cyg_libc_time_getzoneoffsets() // | |
| 296 //////////////////////////////////// | |
| 297 // | |
| 298 // This function retrieves the current state of the Daylight Savings Time | |
| 299 // and the offsets of both STD and DST | |
| 300 // The offsets are both in time_t's | |
| 301 // | |
| 302 | |
| 303 extern Cyg_libc_time_dst | |
| 304 cyg_libc_time_getzoneoffsets( time_t *__stdoffset, time_t *__dstoffset ); | |
| 305 | |
| 306 ///////////////////////////// | |
| 307 // cyg_libc_time_settime() // | |
| 308 ///////////////////////////// | |
| 309 // | |
| 310 // This function sets the current time for the system. The time is | |
| 311 // specified as a time_t in UTC. It returns non-zero on error. | |
| 312 // | |
| 313 | |
| 314 extern cyg_bool | |
| 315 cyg_libc_time_settime( time_t __utctime ); | |
| 316 | |
| 317 | |
| 318 #ifdef __cplusplus | |
| 319 } // extern "C" | |
| 320 #endif | |
| 321 | |
| 322 #include <time.inl> | |
| 0 | 323 |
| 324 #endif // CYGONCE_LIBC_TIME_H multiple inclusion protection | |
| 325 | |
| 326 // EOF time.h |
