diff options
| author | Michael Brown | 2012-03-19 17:09:41 +0100 |
|---|---|---|
| committer | Michael Brown | 2012-03-19 18:35:46 +0100 |
| commit | bd6805a8c18f859a8f467965f2ee780817d8a81e (patch) | |
| tree | d228abb380a1acf56ccadce6ea98de2918696631 /src/include | |
| parent | [crypto] Use correct constraint for byte-addressable register (diff) | |
| download | ipxe-bd6805a8c18f859a8f467965f2ee780817d8a81e.tar.gz ipxe-bd6805a8c18f859a8f467965f2ee780817d8a81e.tar.xz ipxe-bd6805a8c18f859a8f467965f2ee780817d8a81e.zip | |
[libc] Add mktime() function
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/sys/time.h | 24 | ||||
| -rw-r--r-- | src/include/time.h | 37 |
2 files changed, 36 insertions, 25 deletions
diff --git a/src/include/sys/time.h b/src/include/sys/time.h index 21fb7e99d..6c9b7421b 100644 --- a/src/include/sys/time.h +++ b/src/include/sys/time.h @@ -1,20 +1,18 @@ #ifndef _SYS_TIME_H #define _SYS_TIME_H -#include <time.h> +/** @file + * + * Date and time + */ -typedef unsigned long suseconds_t; +#include <stdint.h> -struct timeval { - time_t tv_sec; /* seconds */ - suseconds_t tv_usec; /* microseconds */ -}; - -struct timezone { - int tz_minuteswest; /* minutes W of Greenwich */ - int tz_dsttime; /* type of dst correction */ -}; - -extern int gettimeofday ( struct timeval *tv, struct timezone *tz ); +/** Seconds since the Epoch + * + * We use a 64-bit type to avoid Y2K38 issues, since we may have to + * handle distant future dates (e.g. X.509 certificate expiry dates). + */ +typedef int64_t time_t; #endif /* _SYS_TIME_H */ diff --git a/src/include/time.h b/src/include/time.h index 6ea927c32..f33300ab3 100644 --- a/src/include/time.h +++ b/src/include/time.h @@ -1,22 +1,35 @@ #ifndef _TIME_H #define _TIME_H -typedef unsigned long time_t; +/** @file + * + * Date and time + */ +#include <sys/time.h> + +/** Broken-down time */ struct tm { - int tm_sec; /* seconds */ - int tm_min; /* minutes */ - int tm_hour; /* hours */ - int tm_mday; /* day of the month */ - int tm_mon; /* month */ - int tm_year; /* year */ - int tm_wday; /* day of the week */ - int tm_yday; /* day in the year */ - int tm_isdst; /* daylight saving time */ + /** Seconds [0,60] */ + int tm_sec; + /** Minutes [0,59] */ + int tm_min; + /** Hour [0,23] */ + int tm_hour; + /** Day of month [1,31] */ + int tm_mday; + /** Month of year [0,11] */ + int tm_mon; + /** Years since 1900 */ + int tm_year; + /** Day of week [0,6] (Sunday=0) */ + int tm_wday; + /** Day of year [0,365] */ + int tm_yday; + /** Daylight savings flag */ + int tm_isdst; }; -extern time_t time ( time_t *t ); - extern time_t mktime ( struct tm *tm ); #endif /* _TIME_H */ |
