about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-12-15 13:21:58 +0100
committerptitSeb <sebastien.chev@gmail.com>2023-12-15 13:21:58 +0100
commitd8c40c166203698cb9694df12be2bfd9a61a3316 (patch)
tree16071f30278e6a0305ec8967e68f717415682a93 /src
parent7c0180c3b9cf1e71e7b778166d81b3d4aa6c1f6d (diff)
downloadbox64-d8c40c166203698cb9694df12be2bfd9a61a3316.tar.gz
box64-d8c40c166203698cb9694df12be2bfd9a61a3316.zip
Limit the number of CPU Core repported to 64 when running wine (or proton)
Diffstat (limited to 'src')
-rw-r--r--src/tools/my_cpuid.c2
-rw-r--r--src/wrapped/generated/functions_list.txt7
-rw-r--r--src/wrapped/generated/wrappedlibctypes.h4
-rw-r--r--src/wrapped/generated/wrapper.c7
-rw-r--r--src/wrapped/generated/wrapper.h3
-rw-r--r--src/wrapped/wrappedlibc.c10
-rw-r--r--src/wrapped/wrappedlibc_private.h4
7 files changed, 30 insertions, 7 deletions
diff --git a/src/tools/my_cpuid.c b/src/tools/my_cpuid.c
index d80a038e..258fb990 100644
--- a/src/tools/my_cpuid.c
+++ b/src/tools/my_cpuid.c
@@ -83,6 +83,8 @@ int getNCpu()
 {
     if(!nCPU)
         grabNCpu();
+    if(box64_wine && nCPU>64)
+        return 64;
     return nCPU;
 }
 
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index b676c3b0..6318aaed 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -38,7 +38,6 @@
 #() iFS
 #() iFP
 #() IFv
-#() IFi
 #() IFI
 #() IFf
 #() IFd
@@ -202,6 +201,7 @@
 #() iFpp
 #() iFpO
 #() iFSi
+#() IFEi
 #() IFEf
 #() IFEd
 #() IFEp
@@ -268,6 +268,7 @@
 #() DFDD
 #() DFDp
 #() DFpp
+#() lFEi
 #() lFii
 #() lFip
 #() lFui
@@ -3961,8 +3962,12 @@ wrappedlibc:
   - setjmp
   - stime
   - uname
+- IFi:
+  - sysconf
 - lFv:
   - syscall
+- lFi:
+  - __sysconf
 - LFL:
   - getauxval
 - pFp:
diff --git a/src/wrapped/generated/wrappedlibctypes.h b/src/wrapped/generated/wrappedlibctypes.h
index ff0c659e..a34bb540 100644
--- a/src/wrapped/generated/wrappedlibctypes.h
+++ b/src/wrapped/generated/wrappedlibctypes.h
@@ -17,7 +17,9 @@ typedef void (*vFp_t)(void*);
 typedef int32_t (*iFv_t)(void);
 typedef int32_t (*iFi_t)(int32_t);
 typedef int32_t (*iFp_t)(void*);
+typedef int64_t (*IFi_t)(int32_t);
 typedef intptr_t (*lFv_t)(void);
+typedef intptr_t (*lFi_t)(int32_t);
 typedef uintptr_t (*LFL_t)(uintptr_t);
 typedef void* (*pFp_t)(void*);
 typedef void (*vFpi_t)(void*, int32_t);
@@ -130,7 +132,9 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void*
 	GO(setjmp, iFp_t) \
 	GO(stime, iFp_t) \
 	GO(uname, iFp_t) \
+	GO(sysconf, IFi_t) \
 	GO(syscall, lFv_t) \
+	GO(__sysconf, lFi_t) \
 	GO(getauxval, LFL_t) \
 	GO(__deregister_frame_info, pFp_t) \
 	GO(mallinfo, pFp_t) \
diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c
index f2cd1667..e70a3853 100644
--- a/src/wrapped/generated/wrapper.c
+++ b/src/wrapped/generated/wrapper.c
@@ -74,7 +74,6 @@ typedef int32_t (*iFO_t)(int32_t);
 typedef int32_t (*iFS_t)(void*);
 typedef int32_t (*iFP_t)(void*);
 typedef int64_t (*IFv_t)(void);
-typedef int64_t (*IFi_t)(int32_t);
 typedef int64_t (*IFI_t)(int64_t);
 typedef int64_t (*IFf_t)(float);
 typedef int64_t (*IFd_t)(double);
@@ -238,6 +237,7 @@ typedef int32_t (*iFpL_t)(void*, uintptr_t);
 typedef int32_t (*iFpp_t)(void*, void*);
 typedef int32_t (*iFpO_t)(void*, int32_t);
 typedef int32_t (*iFSi_t)(void*, int32_t);
+typedef int64_t (*IFEi_t)(x64emu_t*, int32_t);
 typedef int64_t (*IFEf_t)(x64emu_t*, float);
 typedef int64_t (*IFEd_t)(x64emu_t*, double);
 typedef int64_t (*IFEp_t)(x64emu_t*, void*);
@@ -304,6 +304,7 @@ typedef long double (*DFDi_t)(long double, int32_t);
 typedef long double (*DFDD_t)(long double, long double);
 typedef long double (*DFDp_t)(long double, void*);
 typedef long double (*DFpp_t)(void*, void*);
+typedef intptr_t (*lFEi_t)(x64emu_t*, int32_t);
 typedef intptr_t (*lFii_t)(int32_t, int32_t);
 typedef intptr_t (*lFip_t)(int32_t, void*);
 typedef intptr_t (*lFui_t)(uint32_t, int32_t);
@@ -3063,7 +3064,6 @@ void iFO(x64emu_t *emu, uintptr_t fcn) { iFO_t fn = (iFO_t)fcn; R_RAX=(int32_t)f
 void iFS(x64emu_t *emu, uintptr_t fcn) { iFS_t fn = (iFS_t)fcn; R_RAX=(int32_t)fn(io_convert((void*)R_RDI)); }
 void iFP(x64emu_t *emu, uintptr_t fcn) { iFP_t fn = (iFP_t)fcn; R_RAX=(int32_t)fn(*(void**)(R_RSP + 8)); }
 void IFv(x64emu_t *emu, uintptr_t fcn) { IFv_t fn = (IFv_t)fcn; R_RAX=(int64_t)fn(); }
-void IFi(x64emu_t *emu, uintptr_t fcn) { IFi_t fn = (IFi_t)fcn; R_RAX=(int64_t)fn((int32_t)R_RDI); }
 void IFI(x64emu_t *emu, uintptr_t fcn) { IFI_t fn = (IFI_t)fcn; R_RAX=(int64_t)fn((int64_t)R_RDI); }
 void IFf(x64emu_t *emu, uintptr_t fcn) { IFf_t fn = (IFf_t)fcn; R_RAX=(int64_t)fn(emu->xmm[0].f[0]); }
 void IFd(x64emu_t *emu, uintptr_t fcn) { IFd_t fn = (IFd_t)fcn; R_RAX=(int64_t)fn(emu->xmm[0].d[0]); }
@@ -3227,6 +3227,7 @@ void iFpL(x64emu_t *emu, uintptr_t fcn) { iFpL_t fn = (iFpL_t)fcn; R_RAX=(int32_
 void iFpp(x64emu_t *emu, uintptr_t fcn) { iFpp_t fn = (iFpp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (void*)R_RSI); }
 void iFpO(x64emu_t *emu, uintptr_t fcn) { iFpO_t fn = (iFpO_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, of_convert((int32_t)R_RSI)); }
 void iFSi(x64emu_t *emu, uintptr_t fcn) { iFSi_t fn = (iFSi_t)fcn; R_RAX=(int32_t)fn(io_convert((void*)R_RDI), (int32_t)R_RSI); }
+void IFEi(x64emu_t *emu, uintptr_t fcn) { IFEi_t fn = (IFEi_t)fcn; R_RAX=(int64_t)fn(emu, (int32_t)R_RDI); }
 void IFEf(x64emu_t *emu, uintptr_t fcn) { IFEf_t fn = (IFEf_t)fcn; R_RAX=(int64_t)fn(emu, emu->xmm[0].f[0]); }
 void IFEd(x64emu_t *emu, uintptr_t fcn) { IFEd_t fn = (IFEd_t)fcn; R_RAX=(int64_t)fn(emu, emu->xmm[0].d[0]); }
 void IFEp(x64emu_t *emu, uintptr_t fcn) { IFEp_t fn = (IFEp_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI); }
@@ -3293,6 +3294,7 @@ void DFDi(x64emu_t *emu, uintptr_t fcn) { DFDi_t fn = (DFDi_t)fcn; long double l
 void DFDD(x64emu_t *emu, uintptr_t fcn) { DFDD_t fn = (DFDD_t)fcn; long double ld=fn(LD2localLD((void*)(R_RSP + 8)), LD2localLD((void*)(R_RSP + 24))); fpu_do_push(emu); ST0val = ld; }
 void DFDp(x64emu_t *emu, uintptr_t fcn) { DFDp_t fn = (DFDp_t)fcn; long double ld=fn(LD2localLD((void*)(R_RSP + 8)), (void*)R_RDI); fpu_do_push(emu); ST0val = ld; }
 void DFpp(x64emu_t *emu, uintptr_t fcn) { DFpp_t fn = (DFpp_t)fcn; long double ld=fn((void*)R_RDI, (void*)R_RSI); fpu_do_push(emu); ST0val = ld; }
+void lFEi(x64emu_t *emu, uintptr_t fcn) { lFEi_t fn = (lFEi_t)fcn; R_RAX=(intptr_t)fn(emu, (int32_t)R_RDI); }
 void lFii(x64emu_t *emu, uintptr_t fcn) { lFii_t fn = (lFii_t)fcn; R_RAX=(intptr_t)fn((int32_t)R_RDI, (int32_t)R_RSI); }
 void lFip(x64emu_t *emu, uintptr_t fcn) { lFip_t fn = (lFip_t)fcn; R_RAX=(intptr_t)fn((int32_t)R_RDI, (void*)R_RSI); }
 void lFui(x64emu_t *emu, uintptr_t fcn) { lFui_t fn = (lFui_t)fcn; R_RAX=(intptr_t)fn((uint32_t)R_RDI, (int32_t)R_RSI); }
@@ -6056,7 +6058,6 @@ int isSimpleWrapper(wrapper_t fun) {
 	if (fun == &iFL) return 1;
 	if (fun == &iFp) return 1;
 	if (fun == &IFv) return 1;
-	if (fun == &IFi) return 1;
 	if (fun == &IFI) return 1;
 	if (fun == &IFf) return 2;
 	if (fun == &IFd) return 2;
diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h
index c0eaa59a..0dfcde42 100644
--- a/src/wrapped/generated/wrapper.h
+++ b/src/wrapped/generated/wrapper.h
@@ -75,7 +75,6 @@ void iFO(x64emu_t *emu, uintptr_t fnc);
 void iFS(x64emu_t *emu, uintptr_t fnc);
 void iFP(x64emu_t *emu, uintptr_t fnc);
 void IFv(x64emu_t *emu, uintptr_t fnc);
-void IFi(x64emu_t *emu, uintptr_t fnc);
 void IFI(x64emu_t *emu, uintptr_t fnc);
 void IFf(x64emu_t *emu, uintptr_t fnc);
 void IFd(x64emu_t *emu, uintptr_t fnc);
@@ -239,6 +238,7 @@ void iFpL(x64emu_t *emu, uintptr_t fnc);
 void iFpp(x64emu_t *emu, uintptr_t fnc);
 void iFpO(x64emu_t *emu, uintptr_t fnc);
 void iFSi(x64emu_t *emu, uintptr_t fnc);
+void IFEi(x64emu_t *emu, uintptr_t fnc);
 void IFEf(x64emu_t *emu, uintptr_t fnc);
 void IFEd(x64emu_t *emu, uintptr_t fnc);
 void IFEp(x64emu_t *emu, uintptr_t fnc);
@@ -305,6 +305,7 @@ void DFDi(x64emu_t *emu, uintptr_t fnc);
 void DFDD(x64emu_t *emu, uintptr_t fnc);
 void DFDp(x64emu_t *emu, uintptr_t fnc);
 void DFpp(x64emu_t *emu, uintptr_t fnc);
+void lFEi(x64emu_t *emu, uintptr_t fnc);
 void lFii(x64emu_t *emu, uintptr_t fnc);
 void lFip(x64emu_t *emu, uintptr_t fnc);
 void lFui(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c
index 1d3fb9e9..4db6b5fc 100644
--- a/src/wrapped/wrappedlibc.c
+++ b/src/wrapped/wrappedlibc.c
@@ -3347,6 +3347,16 @@ EXPORT int my_prctl(x64emu_t* emu, int option, unsigned long arg2, unsigned long
     return prctl(option, arg2, arg3, arg4, arg5);
 }
 
+#ifndef _SC_NPROCESSORS_ONLN
+#define _SC_NPROCESSORS_ONLN    84
+#endif 
+EXPORT long my_sysconf(x64emu_t* emu, int what) {
+    if(what==_SC_NPROCESSORS_ONLN) {
+        return getNCpu();
+    }
+    return sysconf(what);
+}
+EXPORT long my___sysconf(x64emu_t* emu, int what) __attribute__((alias("my_sysconf")));
 
 EXPORT char* my___progname = NULL;
 EXPORT char* my___progname_full = NULL;
diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h
index f3045d3d..6dd94b4b 100644
--- a/src/wrapped/wrappedlibc_private.h
+++ b/src/wrapped/wrappedlibc_private.h
@@ -2031,8 +2031,8 @@ GO(sync, vFv)
 GO(sync_file_range, iFillu)
 GO(syncfs, iFi)
 GOM(syscall, lFEv)
-GO(__sysconf, lFi)
-GO(sysconf, IFi)
+GOM(__sysconf, lFEi)
+GOM(sysconf, IFEi)
 GO(__sysctl, iFpipppL)
 GOW(sysctl, iFpipppL) // Deprecated
 DATA(_sys_errlist, sizeof(void*))