diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2022-09-13 16:17:37 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2022-09-13 16:17:37 +0200 |
| commit | 342241a24d4edf5a288d50c5b2bd04fef57a29d9 (patch) | |
| tree | 531a5dbddcb21a0284902edfc8bcb063edd7870d /src/libtools/threads.c | |
| parent | d047dcb9836e5224847963178817908f025bda88 (diff) | |
| download | box64-342241a24d4edf5a288d50c5b2bd04fef57a29d9.tar.gz box64-342241a24d4edf5a288d50c5b2bd04fef57a29d9.zip | |
Improved thread_self stack size detection
Diffstat (limited to 'src/libtools/threads.c')
| -rwxr-xr-x | src/libtools/threads.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/libtools/threads.c b/src/libtools/threads.c index 12352031..1a295345 100755 --- a/src/libtools/threads.c +++ b/src/libtools/threads.c @@ -440,7 +440,24 @@ EXPORT int my_pthread_attr_setstackaddr(x64emu_t* emu, pthread_attr_t* attr, voi 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)); + int ret = pthread_getattr_np(thread_id, getAlignedAttrWithInit(attr, 0)); + if(!ret && thread_id==pthread_self()) { + if(!emu->context->stacksizes) { + emu->context->stacksizes = kh_init(threadstack); + } + void* stack = emu->init_stack; + size_t sz = emu->size_stack; + if (!sz) { + // get default stack size + pthread_attr_t attr; + pthread_getattr_default_np(&attr); + pthread_attr_getstacksize(&attr, &sz); + pthread_attr_destroy(&attr); + // should stack be adjusted? + } + AddStackSize(emu->context->stacksizes, (uintptr_t)attr, stack, sz); + } + return ret; } EXPORT int my_pthread_getattr_default_np(x64emu_t* emu, pthread_attr_t* attr) { |