Skip to content

Add support for WASI in CFDate.c #2880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CoreFoundation/NumberDate.subproj/CFDate.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#endif
#endif

#if TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD
#if TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WASI
#include <sys/time.h>
#endif

Expand Down Expand Up @@ -115,7 +115,7 @@ CF_EXPORT CFTimeInterval CFGetSystemUptime(void) {
#if TARGET_OS_MAC
uint64_t tsr = mach_absolute_time();
return (CFTimeInterval)((double)tsr * __CF1_TSRRate);
#elif TARGET_OS_LINUX || TARGET_OS_BSD
#elif TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WASI
struct timespec res;
if (clock_gettime(CLOCK_MONOTONIC, &res) != 0) {
HALT;
Expand Down Expand Up @@ -177,7 +177,7 @@ CF_PRIVATE void __CFDateInitialize(void) {
}
__CFTSRRate = (double)freq.QuadPart;
__CF1_TSRRate = 1.0 / __CFTSRRate;
#elif TARGET_OS_LINUX || TARGET_OS_BSD
#elif TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WASI
struct timespec res;
if (clock_getres(CLOCK_MONOTONIC, &res) != 0) {
HALT;
Expand Down