diff options
Diffstat (limited to 'libc-bottom-half/cloudlibc/src/libc/time/time.c')
-rw-r--r-- | libc-bottom-half/cloudlibc/src/libc/time/time.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libc-bottom-half/cloudlibc/src/libc/time/time.c b/libc-bottom-half/cloudlibc/src/libc/time/time.c new file mode 100644 index 0000000..52bc0e4 --- /dev/null +++ b/libc-bottom-half/cloudlibc/src/libc/time/time.c @@ -0,0 +1,16 @@ +// Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/ +// +// SPDX-License-Identifier: BSD-2-Clause + +#include <common/time.h> + +#include <wasi/api.h> +#include <time.h> + +time_t time(time_t *tloc) { + __wasi_timestamp_t ts = 0; + (void)__wasi_clock_time_get(__WASI_CLOCKID_REALTIME, NSEC_PER_SEC, &ts); + if (tloc != NULL) + *tloc = ts / NSEC_PER_SEC; + return ts / NSEC_PER_SEC; +} |