Gate libuv path to Windows and add fallback for unsupported platforms

- Change #else to #elif OS(WINDOWS) to explicitly guard libuv code
- Add final #else with ENOTSUP error for platforms without support
- This matches the pattern used in Process_functionCpuUsage
- Prevents compilation failures on non-Linux/non-Darwin/non-Windows targets (e.g., BSD)

Note: Bundled libuv is v1.51.0 which includes uv_getrusage_thread (added in v1.50.0)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude Bot
2025-10-21 06:33:31 +00:00
parent 980294f711
commit ec9577262e

View File

@@ -3174,8 +3174,8 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionThreadCpuUsage, (JSC::JSGlobalObject *
double user = std::chrono::microseconds::period::den * rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec;
double system = std::chrono::microseconds::period::den * rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec;
#else
// Windows and other platforms - use libuv
#elif OS(WINDOWS)
// Windows: use libuv
uv_rusage_t rusage;
int err = uv_getrusage_thread(&rusage);
if (err) {
@@ -3188,6 +3188,10 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionThreadCpuUsage, (JSC::JSGlobalObject *
double user = std::chrono::microseconds::period::den * rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec;
double system = std::chrono::microseconds::period::den * rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec;
#else
// Other platforms: not supported yet
throwSystemError(throwScope, globalObject, "Thread CPU usage not supported on this platform"_s, "threadCpuUsage"_s, ENOTSUP);
return {};
#endif
if (callFrame->argumentCount() > 0) {