mirror of
https://github.com/ptitSeb/box64.git
synced 2025-02-17 04:49:17 +00:00
Introduce new BOX64_MAXCPU to cap the number of cpu core exposed, and created profile for wine, wine64 and GridAutosport using it
This commit is contained in:
parent
7d0f807880
commit
715ce5dbe9
@ -231,6 +231,11 @@ Handling of x87 80bits long double
|
||||
* 0 : Try to handle 80bits long double as precise as possible (Default)
|
||||
* 1 : Handle them as double
|
||||
|
||||
#### BOX64_MAXCPU
|
||||
Maximum CPU Core exposed
|
||||
* 0 : Don't cap the number of cpu core exposed (Default)
|
||||
* XXX : Cap the maximum CPU Core exposed to XXX (usefull with wine64 or GridAutosport for example)
|
||||
|
||||
#### BOX64_SYNC_ROUNDING *
|
||||
Box64 will sync rounding mode with fesetround/fegetround.
|
||||
* 0 : Disable rounding mode syncing. (Default.)
|
||||
|
@ -10,6 +10,7 @@ extern int box64_dynarec;
|
||||
extern uintptr_t box64_pagesize;
|
||||
extern uintptr_t box64_load_addr;
|
||||
extern int box64_dynarec_test;
|
||||
extern int box64_maxcpu;
|
||||
#ifdef DYNAREC
|
||||
extern int box64_dynarec_dump;
|
||||
extern int box64_dynarec_trace;
|
||||
|
14
src/main.c
14
src/main.c
@ -49,6 +49,7 @@ int box64_nosandbox = 0;
|
||||
int box64_inprocessgpu = 0;
|
||||
int box64_malloc_hack = 0;
|
||||
int box64_dynarec_test = 0;
|
||||
int box64_maxcpu = 0;
|
||||
#ifdef DYNAREC
|
||||
int box64_dynarec = 1;
|
||||
int box64_dynarec_dump = 0;
|
||||
@ -971,6 +972,19 @@ void LoadLogEnv()
|
||||
if(box64_showbt)
|
||||
printf_log(LOG_INFO, "Show a Backtrace when a Segfault signal is caught\n");
|
||||
}
|
||||
p = getenv("BOX64_MAXCPU");
|
||||
if(p) {
|
||||
int maxcpu = 0;
|
||||
if(sscanf(p, "%d", &maxcpu)==1)
|
||||
box64_maxcpu = maxcpu;
|
||||
if(box64_maxcpu<0)
|
||||
box64_maxcpu = 0;
|
||||
if(box64_maxcpu) {
|
||||
printf_log(LOG_NONE, "Will not expose more than %d cpu cores\n", box64_maxcpu);
|
||||
} else {
|
||||
printf_log(LOG_NONE, "Will not limit the number of cpu cores exposed\n");
|
||||
}
|
||||
}
|
||||
box64_pagesize = sysconf(_SC_PAGESIZE);
|
||||
if(!box64_pagesize)
|
||||
box64_pagesize = 4096;
|
||||
|
@ -83,8 +83,8 @@ int getNCpu()
|
||||
{
|
||||
if(!nCPU)
|
||||
grabNCpu();
|
||||
if(box64_wine && nCPU>64)
|
||||
return 64;
|
||||
if(box64_maxcpu && nCPU>box64_maxcpu)
|
||||
return box64_maxcpu;
|
||||
return nCPU;
|
||||
}
|
||||
|
||||
|
@ -109,6 +109,7 @@ ENTRYBOOL(BOX64_EXIT, want_exit) \
|
||||
ENTRYBOOL(BOX64_LIBCEF, box64_libcef) \
|
||||
ENTRYBOOL(BOX64_SDL2_JGUID, box64_sdl2_jguid) \
|
||||
ENTRYINT(BOX64_MALLOC_HACK, box64_malloc_hack, 0, 2, 2) \
|
||||
ENTRYINTPOS(BOX64_MAXCPU, box64_maxcpu) \
|
||||
ENTRYSTRING_(BOX64_ENV, new_env) \
|
||||
|
||||
#ifdef HAVE_TRACE
|
||||
|
@ -1723,6 +1723,15 @@ EXPORT int32_t my_open64(x64emu_t* emu, void* pathname, int32_t flags, uint32_t
|
||||
lseek(tmp, 0, SEEK_SET);
|
||||
return tmp;
|
||||
}
|
||||
if(box64_maxcpu && (!strcmp(pathname, "/sys/devices/system/cpu/present") || !strcmp(pathname, "/sys/devices/system/cpu/online")) && (getNCpu()>=box64_maxcpu)) {
|
||||
// special case for cpu present (to limit to 64 cores)
|
||||
int tmp = shm_open(TMP_CPUPRESENT, O_RDWR | O_CREAT, S_IRWXU);
|
||||
if(tmp<0) return open64(pathname, mode); // error fallback
|
||||
shm_unlink(TMP_CPUPRESENT); // remove the shm file, but it will still exist because it's currently in use
|
||||
CreateCPUPresentFile(tmp);
|
||||
lseek(tmp, 0, SEEK_SET);
|
||||
return tmp;
|
||||
}
|
||||
#endif
|
||||
return open64(pathname, flags, mode);
|
||||
}
|
||||
@ -1748,7 +1757,7 @@ EXPORT FILE* my_fopen64(x64emu_t* emu, const char* path, const char* mode)
|
||||
lseek(tmp, 0, SEEK_SET);
|
||||
return fdopen(tmp, mode);
|
||||
}
|
||||
if(box64_wine && (!strcmp(path, "/sys/devices/system/cpu/present") || !strcmp(path, "/sys/devices/system/cpu/online")) && (getNCpu()>=64)) {
|
||||
if(box64_maxcpu && (!strcmp(path, "/sys/devices/system/cpu/present") || !strcmp(path, "/sys/devices/system/cpu/online")) && (getNCpu()>=box64_maxcpu)) {
|
||||
// special case for cpu present (to limit to 64 cores)
|
||||
int tmp = shm_open(TMP_CPUPRESENT, O_RDWR | O_CREAT, S_IRWXU);
|
||||
if(tmp<0) return fopen64(path, mode); // error fallback
|
||||
@ -2263,8 +2272,6 @@ EXPORT int32_t my___cxa_thread_atexit_impl(x64emu_t* emu, void* dtor, void* obj,
|
||||
//printf_log(LOG_INFO, "Warning, call to __cxa_thread_atexit_impl(%p, %p, %p) ignored\n", dtor, obj, dso);
|
||||
AddCleanup1Arg(emu, dtor, obj, dso);
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT int32_t my___register_atfork(x64emu_t *emu, void* prepare, void* parent, void* child, void* handle)
|
||||
|
@ -59,6 +59,15 @@ BOX64_DYNAREC_ALIGNED_ATOMICS=1
|
||||
[geekbench6]
|
||||
BOX64_ENV=BOX64_DYNAREC_STRONGMEM=3
|
||||
|
||||
[GridAutosport]
|
||||
BOX64_DYNAREC_STRONGMEM=1
|
||||
BOX64_NOSANDBOX=1
|
||||
BOX64_DYNAREC_ALIGNED_ATOMICS=1
|
||||
BOX64_SHOWSEGV=1
|
||||
BOX64_SHOWBT=1
|
||||
BOX64_MAXCPU=16
|
||||
|
||||
|
||||
[heroic]
|
||||
BOX64_NOSANDBOX=1
|
||||
BOX64_INPROCESSGPU=1
|
||||
@ -151,6 +160,12 @@ BOX64_MALLOC_HACK=2
|
||||
BOX64_NOSANDBOX=1
|
||||
BOX64_INPROCESSGPU=1
|
||||
|
||||
[wine]
|
||||
BOX64_MAXCPU=32
|
||||
|
||||
[wine64]
|
||||
BOX64_MAXCPU=64
|
||||
|
||||
#
|
||||
# Wine process
|
||||
#
|
||||
|
Loading…
x
Reference in New Issue
Block a user