diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-11-18 13:41:18 -0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-12-15 23:55:45 +0000 |
commit | 12e2abf6abad06b572a18af832afc33140a8207b (patch) | |
tree | b8f05701c9984405e208318d5bbe34914810dfd2 /libc | |
parent | cddfff5e590d0d6015563e68eade601db93f03df (diff) | |
download | chrome-ec-12e2abf6abad06b572a18af832afc33140a8207b.tar.gz |
libc/syscalls: Add gettimeofday
BRANCH=none
BUG=b:234181908, b:254530679
TEST=make buildall
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I326f1b4103fa7ce577758d5baa42cd572af8affa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4062463
Reviewed-by: Andrea Grandi <agrandi@google.com>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'libc')
-rw-r--r-- | libc/syscalls.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libc/syscalls.c b/libc/syscalls.c index 16cac352d3..afe92c2d06 100644 --- a/libc/syscalls.c +++ b/libc/syscalls.c @@ -11,6 +11,7 @@ * https://sourceware.org/git/?p=newlib-cygwin.git;a=tree;f=libgloss/libnosys. */ +#include "gettimeofday.h" #include "panic.h" #include "software_panic.h" #include "task.h" @@ -66,3 +67,28 @@ int mkdir(const char *pathname, mode_t mode) errno = ENOSYS; return -1; } + +/** + * Get the time. + * + * This function is called from the libc gettimeofday() function. + * + * @warning This does not match gettimeofday() exactly; it does not return the + * time since the Unix Epoch. + * + * @param[out] tv time + * @param[in] tz ignored + * @return 0 on success + * @return -1 on error (errno is set to indicate error) + */ +int _gettimeofday(struct timeval *restrict tv, void *restrict tz) +{ + enum ec_error_list ret = ec_gettimeofday(tv, tz); + + if (ret == EC_ERROR_INVAL) { + errno = EFAULT; + return -1; + } + + return 0; +} |