]>
Commit | Line | Data |
---|---|---|
320054e8 DG |
1 | // Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/ |
2 | // | |
3 | // SPDX-License-Identifier: BSD-2-Clause | |
4 | ||
5 | #include <common/time.h> | |
6 | ||
446cb3f1 | 7 | #include <wasi/api.h> |
320054e8 DG |
8 | #include <time.h> |
9 | ||
10 | time_t time(time_t *tloc) { | |
11 | __wasi_timestamp_t ts = 0; | |
446cb3f1 | 12 | #ifdef __wasilibc_unmodified_upstream |
1cc98f27 | 13 | (void)__wasi_clock_time_get(__WASI_CLOCK_REALTIME, NSEC_PER_SEC, &ts); |
446cb3f1 DG |
14 | #else |
15 | (void)__wasi_clock_time_get(__WASI_CLOCKID_REALTIME, NSEC_PER_SEC, &ts); | |
16 | #endif | |
320054e8 DG |
17 | if (tloc != NULL) |
18 | *tloc = ts / NSEC_PER_SEC; | |
19 | return ts / NSEC_PER_SEC; | |
20 | } |