mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user