[coreboot-gerrit] Change in coreboot[master]: libpayload: add time()
Martin Roth (Code Review)
gerrit at coreboot.org
Mon Aug 21 18:53:21 CEST 2017
Martin Roth has submitted this change and it was merged. ( https://review.coreboot.org/21011 )
Change subject: libpayload: add time()
......................................................................
libpayload: add time()
Change-Id: I97e393537ccc71ea454bb0d6cdbbb7ed32485f1e
Signed-off-by: Nicola Corna <nicola at corna.info>
Reviewed-on: https://review.coreboot.org/21011
Tested-by: build bot (Jenkins) <no-reply at coreboot.org>
Reviewed-by: Nico Huber <nico.h at gmx.de>
Reviewed-by: Paul Menzel <paulepanter at users.sourceforge.net>
---
M payloads/libpayload/include/time.h
M payloads/libpayload/libc/time.c
2 files changed, 21 insertions(+), 6 deletions(-)
Approvals:
build bot (Jenkins): Verified
Nico Huber: Looks good to me, approved
Paul Menzel: Looks good to me, but someone else must approve
diff --git a/payloads/libpayload/include/time.h b/payloads/libpayload/include/time.h
index 25f476c..42be725 100644
--- a/payloads/libpayload/include/time.h
+++ b/payloads/libpayload/include/time.h
@@ -44,6 +44,7 @@
suseconds_t tv_usec; /**< Microseconds */
};
+time_t time(time_t *tp);
int gettimeofday(struct timeval *tv, void *tz);
/** @} */
diff --git a/payloads/libpayload/libc/time.c b/payloads/libpayload/libc/time.c
index 4ed788f..46306bb 100644
--- a/payloads/libpayload/libc/time.c
+++ b/payloads/libpayload/libc/time.c
@@ -121,13 +121,12 @@
#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 @@
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;
--
To view, visit https://review.coreboot.org/21011
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I97e393537ccc71ea454bb0d6cdbbb7ed32485f1e
Gerrit-Change-Number: 21011
Gerrit-PatchSet: 6
Gerrit-Owner: Nicola Corna <nicola at corna.info>
Gerrit-Reviewer: Julius Werner <jwerner at chromium.org>
Gerrit-Reviewer: Martin Roth <martinroth at google.com>
Gerrit-Reviewer: Nico Huber <nico.h at gmx.de>
Gerrit-Reviewer: Paul Menzel <paulepanter at users.sourceforge.net>
Gerrit-Reviewer: build bot (Jenkins) <no-reply at coreboot.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20170821/449a3efd/attachment.html>
More information about the coreboot-gerrit
mailing list