about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-10-18 10:12:48 +0200
committerGitHub <noreply@github.com>2021-10-18 10:12:48 +0200
commit36bfcd21d4ff11db13ba8487d7d1f8323cee7610 (patch)
tree44020b7e0e52c958aa6d9f5a9453f302a41d27d5
parentfaa48276e5353a8303767ca7a94cc07cd8b81d91 (diff)
parente1a2230e9ca654cdd2b4230060a304d792843914 (diff)
downloadbox64-36bfcd21d4ff11db13ba8487d7d1f8323cee7610.tar.gz
box64-36bfcd21d4ff11db13ba8487d7d1f8323cee7610.zip
Merge pull request #135 from mogery/getattr-align-wrap
Add alignment wrapper to pthread_getattr_np.
-rwxr-xr-xsrc/libtools/threads.c5
-rw-r--r--src/wrapped/generated/functions_list.txt3
-rw-r--r--src/wrapped/generated/wrappedlibpthreadtypes.h2
-rw-r--r--src/wrapped/generated/wrapper.c2
-rw-r--r--src/wrapped/generated/wrapper.h1
-rwxr-xr-xsrc/wrapped/wrappedlibpthread_private.h4
6 files changed, 17 insertions, 0 deletions
diff --git a/src/libtools/threads.c b/src/libtools/threads.c
index 81ccba3a..31052118 100755
--- a/src/libtools/threads.c
+++ b/src/libtools/threads.c
@@ -417,6 +417,11 @@ EXPORT int my_pthread_attr_setstackaddr(x64emu_t* emu, pthread_attr_t* attr, voi
 	return pthread_attr_setstack(getAlignedAttr(attr), addr, size);
 	//return pthread_attr_setstackaddr(getAlignedAttr(attr), addr);
 }
+EXPORT int my_pthread_getattr_np(x64emu_t* emu, pthread_t thread_id, pthread_attr_t* attr)
+{
+	(void)emu;
+	return pthread_getattr_np(thread_id, getAlignedAttrWithInit(attr, 0));
+}
 #endif
 
 EXPORT int my_pthread_create(x64emu_t *emu, void* t, void* attr, void* start_routine, void* arg)
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index e3afbfc3..a4fdac0d 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -1864,6 +1864,7 @@
 #!defined(HAVE_LD80BITS) KFKp
 #!defined(HAVE_LD80BITS) vFppippKKC
 #defined(NOALIGN) iFipiip
+#!defined(NOALIGN) iFELp
 #!defined(NOALIGN) iFEppu
 #!defined(NOALIGN) iFEiiip
 #!defined(NOALIGN) iFEipii
@@ -2730,6 +2731,8 @@ wrappedlibpthread:
 - vFpi:
   - _pthread_cleanup_pop
   - _pthread_cleanup_pop_restore
+- iFLp:
+  - pthread_getattr_np
 - iFpi:
   - __pthread_mutexattr_settype
   - pthread_attr_setdetachstate
diff --git a/src/wrapped/generated/wrappedlibpthreadtypes.h b/src/wrapped/generated/wrappedlibpthreadtypes.h
index 2b0d9f50..f7c3a0de 100644
--- a/src/wrapped/generated/wrappedlibpthreadtypes.h
+++ b/src/wrapped/generated/wrappedlibpthreadtypes.h
@@ -14,6 +14,7 @@
 typedef void (*vFp_t)(void*);
 typedef int64_t (*iFp_t)(void*);
 typedef void (*vFpi_t)(void*, int64_t);
+typedef int64_t (*iFLp_t)(uintptr_t, void*);
 typedef int64_t (*iFpi_t)(void*, int64_t);
 typedef int64_t (*iFpL_t)(void*, uintptr_t);
 typedef int64_t (*iFpp_t)(void*, void*);
@@ -48,6 +49,7 @@ typedef int64_t (*iFpppp_t)(void*, void*, void*, void*);
 	GO(pthread_mutexattr_init, iFp_t) \
 	GO(_pthread_cleanup_pop, vFpi_t) \
 	GO(_pthread_cleanup_pop_restore, vFpi_t) \
+	GO(pthread_getattr_np, iFLp_t) \
 	GO(__pthread_mutexattr_settype, iFpi_t) \
 	GO(pthread_attr_setdetachstate, iFpi_t) \
 	GO(pthread_attr_setinheritsched, iFpi_t) \
diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c
index ad0b9857..e560a8d6 100644
--- a/src/wrapped/generated/wrapper.c
+++ b/src/wrapped/generated/wrapper.c
@@ -1909,6 +1909,7 @@ typedef int64_t (*iFipiip_t)(int64_t, void*, int64_t, int64_t, void*);
 #endif
 
 #if !defined(NOALIGN)
+typedef int64_t (*iFELp_t)(x64emu_t*, uintptr_t, void*);
 typedef int64_t (*iFEppu_t)(x64emu_t*, void*, void*, uint64_t);
 typedef int64_t (*iFEiiip_t)(x64emu_t*, int64_t, int64_t, int64_t, void*);
 typedef int64_t (*iFEipii_t)(x64emu_t*, int64_t, void*, int64_t, int64_t);
@@ -3792,6 +3793,7 @@ void iFipiip(x64emu_t *emu, uintptr_t fcn) { iFipiip_t fn = (iFipiip_t)fcn; R_RA
 #endif
 
 #if !defined(NOALIGN)
+void iFELp(x64emu_t *emu, uintptr_t fcn) { iFELp_t fn = (iFELp_t)fcn; R_RAX=(int64_t)fn(emu, (uintptr_t)R_RDI, (void*)R_RSI); }
 void iFEppu(x64emu_t *emu, uintptr_t fcn) { iFEppu_t fn = (iFEppu_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (uint64_t)R_RDX); }
 void iFEiiip(x64emu_t *emu, uintptr_t fcn) { iFEiiip_t fn = (iFEiiip_t)fcn; R_RAX=(int64_t)fn(emu, (int64_t)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (void*)R_RCX); }
 void iFEipii(x64emu_t *emu, uintptr_t fcn) { iFEipii_t fn = (iFEipii_t)fcn; R_RAX=(int64_t)fn(emu, (int64_t)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX); }
diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h
index a50ffddc..b2000113 100644
--- a/src/wrapped/generated/wrapper.h
+++ b/src/wrapped/generated/wrapper.h
@@ -1908,6 +1908,7 @@ void iFipiip(x64emu_t *emu, uintptr_t fnc);
 #endif
 
 #if !defined(NOALIGN)
+void iFELp(x64emu_t *emu, uintptr_t fnc);
 void iFEppu(x64emu_t *emu, uintptr_t fnc);
 void iFEiiip(x64emu_t *emu, uintptr_t fnc);
 void iFEipii(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped/wrappedlibpthread_private.h b/src/wrapped/wrappedlibpthread_private.h
index 469bea50..9722cb4c 100755
--- a/src/wrapped/wrappedlibpthread_private.h
+++ b/src/wrapped/wrappedlibpthread_private.h
@@ -116,7 +116,11 @@ GO(pthread_detach, iFL)
 GO(pthread_equal, iFLL)
 GO(pthread_exit, vFp)
 GOM(pthread_getaffinity_np, iFEpLp)
+#ifdef NOALIGN
 GO(pthread_getattr_np, iFLp)
+#else
+GOM(pthread_getattr_np, iFELp)
+#endif
 //GO(pthread_getconcurrency, iFv)
 //GO(pthread_getcpuclockid, iFup)
 GO(pthread_getschedparam, iFLpp)