mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
Merge pull request #11399 from JosJuice/jit-one-stack
Jit: Don't use a second stack
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
#include <Windows.h>
|
||||
#include <processthreadsapi.h>
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
@ -185,6 +186,41 @@ void SetCurrentThreadName(const char* name)
|
||||
#endif
|
||||
}
|
||||
|
||||
std::tuple<void*, size_t> GetCurrentThreadStack()
|
||||
{
|
||||
void* stack_addr;
|
||||
size_t stack_size;
|
||||
|
||||
pthread_t self = pthread_self();
|
||||
|
||||
#ifdef __APPLE__
|
||||
stack_size = pthread_get_stacksize_np(self);
|
||||
stack_addr = reinterpret_cast<u8*>(pthread_get_stackaddr_np(self)) - stack_size;
|
||||
#elif defined __OpenBSD__
|
||||
stack_t stack;
|
||||
pthread_stackseg_np(self, &stack);
|
||||
|
||||
stack_addr = reinterpret_cast<u8*>(stack->ss_sp) - stack->ss_size;
|
||||
stack_size = stack->ss_size;
|
||||
#else
|
||||
pthread_attr_t attr;
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_get_np(self, &attr);
|
||||
#else
|
||||
// Linux and NetBSD
|
||||
pthread_getattr_np(self, &attr);
|
||||
#endif
|
||||
|
||||
pthread_attr_getstack(&attr, &stack_addr, &stack_size);
|
||||
|
||||
pthread_attr_destroy(&attr);
|
||||
#endif
|
||||
|
||||
return std::make_tuple(stack_addr, stack_size);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace Common
|
||||
|
@ -5,6 +5,10 @@
|
||||
|
||||
#include <thread>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <tuple>
|
||||
#endif
|
||||
|
||||
// Don't include Common.h here as it will break LogManager
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
@ -35,4 +39,9 @@ inline void YieldCPU()
|
||||
|
||||
void SetCurrentThreadName(const char* name);
|
||||
|
||||
#ifndef _WIN32
|
||||
// Returns the lowest address of the stack and the size of the stack
|
||||
std::tuple<void*, size_t> GetCurrentThreadStack();
|
||||
#endif
|
||||
|
||||
} // namespace Common
|
||||
|
Reference in New Issue
Block a user