]> git.proxmox.com Git - wasi-libc.git/blob - libc-bottom-half/cloudlibc/src/libc/time/time.c
Update to cloudlibc 8835639f27fc42d32096d59d294a0bbb857dc368.
[wasi-libc.git] / libc-bottom-half / cloudlibc / src / libc / time / time.c
1 // Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
2 //
3 // SPDX-License-Identifier: BSD-2-Clause
4
5 #include <common/time.h>
6
7 #include <wasi/core.h>
8 #include <time.h>
9
10 time_t time(time_t *tloc) {
11 __wasi_timestamp_t ts = 0;
12 (void)__wasi_clock_time_get(__WASI_CLOCK_REALTIME, NSEC_PER_SEC, &ts);
13 if (tloc != NULL)
14 *tloc = ts / NSEC_PER_SEC;
15 return ts / NSEC_PER_SEC;
16 }