From 87ae131cb210ac5eb42037ed9552ad01e839f05d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Sun, 13 Oct 2024 09:53:25 -0700 Subject: [PATCH] CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID are not available in WASI libc --- wasi/wasi.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/wasi/wasi.c b/wasi/wasi.c index 4e59b17..fd37338 100644 --- a/wasi/wasi.c +++ b/wasi/wasi.c @@ -1754,13 +1754,21 @@ wasiClockTimeGet( break; } #endif -#ifdef _POSIX_CPUTIME +/* Don't check for _POSIX_CPUTIME, because e.g. WASI libc defines it, + * but it does not have CLOCK_PROCESS_CPUTIME_ID. + * See https://github.com/WebAssembly/wasi-libc/issues/513 + */ +#ifdef CLOCK_PROCESS_CPUTIME_ID case WASI_CLOCK_PROCESS_CPUTIME_ID: { nativeClockID = CLOCK_PROCESS_CPUTIME_ID; break; } #endif -#ifdef _POSIX_THREAD_CPUTIME +/* Don't check for _POSIX_THREAD_CPUTIME, because e.g. WASI libc defines it, + * but it does not have CLOCK_THREAD_CPUTIME_ID. + * See https://github.com/WebAssembly/wasi-libc/issues/513 + */ +#ifdef CLOCK_THREAD_CPUTIME_ID case WASI_CLOCK_THREAD_CPUTIME_ID: { nativeClockID = CLOCK_THREAD_CPUTIME_ID; break; @@ -2028,13 +2036,21 @@ wasiClockResGet( break; } #endif -#ifdef _POSIX_CPUTIME +/* Don't check for _POSIX_CPUTIME, because e.g. WASI libc defines it, + * but it does not have CLOCK_PROCESS_CPUTIME_ID. + * See https://github.com/WebAssembly/wasi-libc/issues/513 + */ +#ifdef CLOCK_PROCESS_CPUTIME_ID case WASI_CLOCK_PROCESS_CPUTIME_ID: { nativeClockID = CLOCK_PROCESS_CPUTIME_ID; break; } #endif -#ifdef _POSIX_THREAD_CPUTIME +/* Don't check for _POSIX_THREAD_CPUTIME, because e.g. WASI libc defines it, + * but it does not have CLOCK_THREAD_CPUTIME_ID. + * See https://github.com/WebAssembly/wasi-libc/issues/513 + */ +#ifdef CLOCK_THREAD_CPUTIME_ID case WASI_CLOCK_THREAD_CPUTIME_ID: { nativeClockID = CLOCK_THREAD_CPUTIME_ID; break;