From 9c9a3784556d519c6aba3b1c899e86e73aacfaeb Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Fri, 5 Apr 2024 20:43:45 +0200 Subject: [PATCH] LibCore: Implement Core::System::hardware_concurrency() --- Userland/Libraries/LibCore/System.cpp | 5 +++++ Userland/Libraries/LibCore/System.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index 820ccb9b1f8..aa6eb7d999e 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -1739,6 +1739,11 @@ ErrorOr posix_fallocate(int fd, off_t offset, off_t length) // the distinction between these libraries moot. static constexpr StringView INTERNAL_DEFAULT_PATH_SV = "/usr/local/sbin:/usr/local/bin:/usr/bin:/bin"sv; +unsigned hardware_concurrency() +{ + return sysconf(_SC_NPROCESSORS_ONLN); +} + ErrorOr resolve_executable_from_environment(StringView filename, int flags) { if (filename.is_empty()) diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index f37f699f67a..a57d1f8faf0 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -276,6 +276,8 @@ ErrorOr getaddrinfo(char const* nodename, char const* servnam ErrorOr posix_fallocate(int fd, off_t offset, off_t length); #endif +unsigned hardware_concurrency(); + ErrorOr resolve_executable_from_environment(StringView filename, int flags = 0); ErrorOr current_executable_path();