coreinit: Split pointer before passing to FiberThreadEntry

This commit is contained in:
Exverge 2024-07-10 16:28:33 -04:00
parent 72af6e8ae4
commit 011be25597
No known key found for this signature in database
GPG key ID: 19AAFC0AC6A9B35A
2 changed files with 16 additions and 1 deletions

View file

@ -25,7 +25,11 @@ void nnNfp_update();
namespace coreinit namespace coreinit
{ {
#ifdef __arm64__
void __OSFiberThreadEntry(uint32, uint32);
#else
void __OSFiberThreadEntry(void* thread); void __OSFiberThreadEntry(void* thread);
#endif
void __OSAddReadyThreadToRunQueue(OSThread_t* thread); void __OSAddReadyThreadToRunQueue(OSThread_t* thread);
void __OSRemoveThreadFromRunQueues(OSThread_t* thread); void __OSRemoveThreadFromRunQueues(OSThread_t* thread);
}; };
@ -49,7 +53,7 @@ namespace coreinit
struct OSHostThread struct OSHostThread
{ {
OSHostThread(OSThread_t* thread) : m_thread(thread), m_fiber(__OSFiberThreadEntry, this, this) OSHostThread(OSThread_t* thread) : m_thread(thread), m_fiber((void(*)(void*))__OSFiberThreadEntry, this, this)
{ {
} }
@ -1304,8 +1308,14 @@ namespace coreinit
__OSThreadStartTimeslice(hostThread->m_thread, &hostThread->ppcInstance); __OSThreadStartTimeslice(hostThread->m_thread, &hostThread->ppcInstance);
} }
#ifdef __arm64__
void __OSFiberThreadEntry(uint32 _high, uint32 _low)
{
uint64 _thread = (uint64) _high << 32 | _low;
#else
void __OSFiberThreadEntry(void* _thread) void __OSFiberThreadEntry(void* _thread)
{ {
#endif
OSHostThread* hostThread = (OSHostThread*)_thread; OSHostThread* hostThread = (OSHostThread*)_thread;
#if defined(ARCH_X86_64) #if defined(ARCH_X86_64)

View file

@ -15,7 +15,12 @@ Fiber::Fiber(void(*FiberEntryPoint)(void* userParam), void* userParam, void* pri
ctx->uc_stack.ss_sp = m_stackPtr; ctx->uc_stack.ss_sp = m_stackPtr;
ctx->uc_stack.ss_size = stackSize; ctx->uc_stack.ss_size = stackSize;
ctx->uc_link = &ctx[0]; ctx->uc_link = &ctx[0];
#ifdef __arm64__
// https://www.man7.org/linux/man-pages/man3/makecontext.3.html#NOTES
makecontext(ctx, (void(*)())FiberEntryPoint, 2, (uint64) userParam >> 32, userParam);
#else
makecontext(ctx, (void(*)())FiberEntryPoint, 1, userParam); makecontext(ctx, (void(*)())FiberEntryPoint, 1, userParam);
#endif
this->m_implData = (void*)ctx; this->m_implData = (void*)ctx;
} }