thread: set arguments/fields before CreateThread

This commit is contained in:
Michael Scire 2021-07-19 22:32:46 -07:00
parent bee27ba607
commit f12f279f45

View File

@ -138,13 +138,7 @@ Result threadCreate(
void *tls = (void*)((uintptr_t)reent + reent_sz); void *tls = (void*)((uintptr_t)reent + reent_sz);
Handle handle; Handle handle;
rc = svcCreateThread( t->handle = INVALID_HANDLE;
&handle, (ThreadFunc) &_EntryWrap, args, (void*)stack_top,
prio, cpuid);
if (R_SUCCEEDED(rc))
{
t->handle = handle;
t->owns_stack_mem = owns_stack_mem; t->owns_stack_mem = owns_stack_mem;
t->stack_mem = stack_mem; t->stack_mem = stack_mem;
t->stack_mirror = stack_mirror; t->stack_mirror = stack_mirror;
@ -159,6 +153,14 @@ Result threadCreate(
args->reent = reent; args->reent = reent;
args->tls = tls; args->tls = tls;
rc = svcCreateThread(
&handle, (ThreadFunc) &_EntryWrap, args, (void*)stack_top,
prio, cpuid);
if (R_SUCCEEDED(rc))
{
t->handle = handle;
// Set up child thread's reent struct, inheriting standard file handles // Set up child thread's reent struct, inheriting standard file handles
_REENT_INIT_PTR(args->reent); _REENT_INIT_PTR(args->reent);
struct _reent* cur = getThreadVars()->reent; struct _reent* cur = getThreadVars()->reent;