Keep a single, portable implementation of OS::get_processor_count()

(cherry picked from commit 6bf02c0162)
This commit is contained in:
Pedro J. Estébanez 2022-08-24 09:50:33 +02:00 committed by Haoyu Qiu
parent 0754c7ee1a
commit 0873cf0656
5 changed files with 2 additions and 18 deletions

View file

@ -39,6 +39,7 @@
#include "servers/audio_server.h"
#include <stdarg.h>
#include <thread>
OS *OS::singleton = nullptr;
uint64_t OS::target_ticks = 0;
@ -525,7 +526,7 @@ String OS::get_unique_id() const {
}
int OS::get_processor_count() const {
return 1;
return std::thread::hardware_concurrency();
}
String OS::get_processor_name() const {

View file

@ -460,10 +460,6 @@ bool OS_Unix::set_environment(const String &p_var, const String &p_value) const
return setenv(p_var.utf8().get_data(), p_value.utf8().get_data(), /* overwrite: */ true) == 0;
}
int OS_Unix::get_processor_count() const {
return sysconf(_SC_NPROCESSORS_CONF);
}
String OS_Unix::get_user_data_dir() const {
String appname = get_safe_dir_name(ProjectSettings::get_singleton()->get("application/config/name"));
if (appname != "") {

View file

@ -95,8 +95,6 @@ public:
virtual bool set_environment(const String &p_var, const String &p_value) const;
virtual String get_locale() const;
virtual int get_processor_count() const;
virtual void debug_break();
virtual void initialize_debugging();

View file

@ -3339,16 +3339,6 @@ BOOL is_wow64() {
return wow64;
}
int OS_Windows::get_processor_count() const {
SYSTEM_INFO sysinfo;
if (is_wow64())
GetNativeSystemInfo(&sysinfo);
else
GetSystemInfo(&sysinfo);
return sysinfo.dwNumberOfProcessors;
}
String OS_Windows::get_processor_name() const {
const String id = "Hardware\\Description\\System\\CentralProcessor\\0";

View file

@ -552,7 +552,6 @@ public:
virtual String get_locale() const;
virtual int get_processor_count() const;
virtual String get_processor_name() const;
virtual LatinKeyboardVariant get_latin_keyboard_variant() const;