From a96c7093512a0923ee7536c3c5b3517b352fc675 Mon Sep 17 00:00:00 2001 From: Cpasjuste Date: Tue, 2 Oct 2018 14:54:51 +0200 Subject: [PATCH] switch: increase thread stack size (fix a lot of stuff) switch: enable load balancing across cores (@fincs) --- src/thread/switch/SDL_systhread.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/thread/switch/SDL_systhread.c b/src/thread/switch/SDL_systhread.c index 4ea162ae1..95875012d 100644 --- a/src/thread/switch/SDL_systhread.c +++ b/src/thread/switch/SDL_systhread.c @@ -31,7 +31,7 @@ #include "SDL_thread.h" #include "../SDL_systhread.h" -#define STACK_SIZE 0x5000 +#define STACK_SIZE 0x20000 static void SDL_SYS_RunThread(void *data) @@ -41,13 +41,28 @@ SDL_SYS_RunThread(void *data) int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) { - Result res = threadCreate(&thread->handle, SDL_SYS_RunThread, args, STACK_SIZE, 0x2C, -2); - if (res != 0) { + Result res; + u64 core_mask = 0; + + res = svcGetInfo(&core_mask, 0, CUR_PROCESS_HANDLE, 0); + if (R_FAILED(res)) { + return SDL_SetError("svcGetInfo() failed: 0x%08X", res); + } + + res = threadCreate(&thread->handle, SDL_SYS_RunThread, args, STACK_SIZE, 0x2C, -2); + if (R_FAILED(res)) { + return SDL_SetError("threadCreate() failed: 0x%08X", res); + } + + res = svcSetThreadCoreMask(thread->handle.handle, -1, (u32) core_mask); + if (R_FAILED(res)) { + threadClose(&thread->handle); return SDL_SetError("threadCreate() failed: 0x%08X", res); } res = threadStart(&thread->handle); - if (res != 0) { + if (R_FAILED(res)) { + threadClose(&thread->handle); return SDL_SetError("threadStart() failed: 0x%08X", res); }