[coreboot-gerrit] Change in coreboot[master]: libpayload: add time()
Nicola Corna (Code Review)
gerrit at coreboot.org
Mon Aug 14 23:38:59 CEST 2017
Nicola Corna has uploaded this change for review. ( https://review.coreboot.org/21011
Change subject: libpayload: add time()
......................................................................
libpayload: add time()
Change-Id: I97e393537ccc71ea454bb0d6cdbbb7ed32485f1e
---
M payloads/libpayload/include/time.h
M payloads/libpayload/libc/time.c
2 files changed, 21 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/11/21011/1
diff --git a/payloads/libpayload/include/time.h b/payloads/libpayload/include/time.h
index 25f476c..8871824 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* tloc);
int gettimeofday(struct timeval *tv, void *tz);
/** @} */
diff --git a/payloads/libpayload/libc/time.c b/payloads/libpayload/libc/time.c
index 4ed788f..cfad278 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.
*
- * @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 tloc When not NULL, set this variable to the current time.
+ * @return The current time.
*/
-int gettimeofday(struct timeval *tv, void *tz)
+time_t time (time_t* tloc)
{
/*
* 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 (tloc)
+ *tloc = 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 compatability - 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: newchange
Gerrit-Change-Id: I97e393537ccc71ea454bb0d6cdbbb7ed32485f1e
Gerrit-Change-Number: 21011
Gerrit-PatchSet: 1
Gerrit-Owner: Nicola Corna <nicola at corna.info>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20170814/a5ac0e2d/attachment-0001.html>
More information about the coreboot-gerrit
mailing list