diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2025-06-08 16:41:51 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2025-06-08 16:41:51 +0200 |
| commit | 873be3cf879e3635a996bcdc34b3e3a6c15969a0 (patch) | |
| tree | 6f75051a27b56cb9ecbf1a22e0f5042b10177db3 /src | |
| parent | 685afa230291d64f350afbfdfa8fc82536d99f82 (diff) | |
| download | box64-873be3cf879e3635a996bcdc34b3e3a6c15969a0.tar.gz box64-873be3cf879e3635a996bcdc34b3e3a6c15969a0.zip | |
[RCFILE] Fixed MAXCPU so it works for wine apps too
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 4 | ||||
| -rw-r--r-- | src/include/my_cpuid.h | 2 | ||||
| -rw-r--r-- | src/os/my_cpuid_linux.c | 12 | ||||
| -rw-r--r-- | src/os/my_cpuid_wine.c | 11 | ||||
| -rw-r--r-- | src/tools/env.c | 6 |
5 files changed, 31 insertions, 4 deletions
diff --git a/src/core.c b/src/core.c index 5e164c7a..4404f6bf 100644 --- a/src/core.c +++ b/src/core.c @@ -219,7 +219,7 @@ void my_child_fork() } const char* getCpuName(); -int getNCpu(); +int getNCpuUnmasked(); #ifdef DYNAREC void GatherDynarecExtensions() @@ -445,7 +445,7 @@ static void displayMiscInfo() #endif // grab ncpu and cpu name - int ncpu = getNCpu(); + int ncpu = getNCpuUnmasked(); const char* cpuname = getCpuName(); printf_log(LOG_INFO, "Running on %s with %d core%s, pagesize: %zd\n", cpuname, ncpu, ncpu > 1 ? "s" : "", box64_pagesize); diff --git a/src/include/my_cpuid.h b/src/include/my_cpuid.h index 985e9cb6..3904517c 100644 --- a/src/include/my_cpuid.h +++ b/src/include/my_cpuid.h @@ -8,5 +8,7 @@ uint32_t helper_getcpu(x64emu_t* emu); // get the numa/cpu id actually running uint32_t get_random32(); uint64_t get_random64(); int getNCpu(); +int getNCpuUnmasked(); +int canNCpuBeChanged(); const char* getBoxCpuName(); #endif //__MY_CPUID_H__ diff --git a/src/os/my_cpuid_linux.c b/src/os/my_cpuid_linux.c index c783a44a..5979975a 100644 --- a/src/os/my_cpuid_linux.c +++ b/src/os/my_cpuid_linux.c @@ -76,6 +76,7 @@ int get_cpuMhz() } static int nCPU = 0; static double bogoMips = 100.; +static int read_ncpu = 0; void grabNCpu() { nCPU = 1; // default number of CPU to 1 @@ -107,10 +108,21 @@ int getNCpu() { if(!nCPU) grabNCpu(); + read_ncpu = 1; if(BOX64ENV(maxcpu) && nCPU>BOX64ENV(maxcpu)) return BOX64ENV(maxcpu); return nCPU; } +int getNCpuUnmasked() +{ + if(!nCPU) + grabNCpu(); + return nCPU; +} +int canNCpuBeChanged() +{ + return read_ncpu?0:1; +} double getBogoMips() { diff --git a/src/os/my_cpuid_wine.c b/src/os/my_cpuid_wine.c index 85e8e8a8..d5774bc1 100644 --- a/src/os/my_cpuid_wine.c +++ b/src/os/my_cpuid_wine.c @@ -8,6 +8,7 @@ NTSYSAPI ULONG WINAPI NtGetTickCount(VOID); NTSYSAPI ULONG NTAPI RtlRandom(ULONG *seed); static int nCPU = 0; +static int read_ncpu = 0; void grabNCpu() { SYSTEM_INFO sysinfo; @@ -22,6 +23,16 @@ int getNCpu() return BOX64ENV(maxcpu); return nCPU; } +int getNCpuUnmasked() +{ + if(!nCPU) + grabNCpu(); + return nCPU; +} +int canNCpuBeChanged() +{ + return read_ncpu?0:1; +} const char* getBoxCpuName() { diff --git a/src/tools/env.c b/src/tools/env.c index ed1bf326..3cd12818 100644 --- a/src/tools/env.c +++ b/src/tools/env.c @@ -121,6 +121,7 @@ static void parseRange(const char* s, uintptr_t* start, uintptr_t* end) } void AddNewLibs(const char* list); +int canNCpuBeChanged(); static void applyCustomRules() { @@ -196,8 +197,9 @@ static void applyCustomRules() #endif } - if (box64env.maxcpu == 0 || (!box64_wine && box64env.new_maxcpu < box64env.maxcpu)) { - box64env.maxcpu = box64env.new_maxcpu; + if (box64env.maxcpu == 0 || (box64env.new_maxcpu < box64env.maxcpu)) { + if(canNCpuBeChanged()) + box64env.maxcpu = box64env.new_maxcpu; } #ifndef _WIN32 |