diff options
author | Nicola Corna <nicola@corna.info> | 2017-08-14 20:29:16 +0200 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2017-08-21 16:53:20 +0000 |
commit | b016f144cc9301b42b9578131b49ac2100926383 (patch) | |
tree | 1baa8349a2abebb42d1c22a63d9cb4993fa92209 /payloads/libpayload/libc | |
parent | 7f395fe95bd525581214bc12bb7a231be766a502 (diff) | |
download | coreboot-b016f144cc9301b42b9578131b49ac2100926383.tar.xz |
libpayload: add time()
Change-Id: I97e393537ccc71ea454bb0d6cdbbb7ed32485f1e
Signed-off-by: Nicola Corna <nicola@corna.info>
Reviewed-on: https://review.coreboot.org/21011
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Diffstat (limited to 'payloads/libpayload/libc')
-rw-r--r-- | payloads/libpayload/libc/time.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/payloads/libpayload/libc/time.c b/payloads/libpayload/libc/time.c index 4ed788fbdc..46306bb1ba 100644 --- a/payloads/libpayload/libc/time.c +++ b/payloads/libpayload/libc/time.c @@ -121,13 +121,12 @@ static void gettimeofday_init(void) #endif /** - * Return the current time broken into a timeval structure. + * Return the current time expressed as seconds from 00:00:00 UTC, 1 Jan 1970. * - * @param tv A pointer to a timeval structure. - * @param tz Added for compatability - not used. - * @return 0 for success (this function cannot return non-zero currently). + * @param tp When not NULL, set this to the current time in seconds. + * @return The current time in seconds. */ -int gettimeofday(struct timeval *tv, void *tz) +time_t time(time_t *tp) { /* * Call the gtod init when we need it - this keeps the code from @@ -138,7 +137,22 @@ int gettimeofday(struct timeval *tv, void *tz) update_clock(); - tv->tv_sec = clock.secs; + if (tp) + *tp = clock.secs; + + return clock.secs; +} + +/** + * Return the current time broken into a timeval structure. + * + * @param tv A pointer to a timeval structure. + * @param tz Added for compatibility - not used. + * @return 0 for success (this function cannot return non-zero currently). + */ +int gettimeofday(struct timeval *tv, void *tz) +{ + tv->tv_sec = time(NULL); tv->tv_usec = clock.usecs; return 0; |