]> git.proxmox.com Git - wasi-libc.git/blob - libc-bottom-half/cloudlibc/src/libc/time/time.c
f9ef839b0fb57f2dd08ef742275e450673909a06
[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 }