Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wutstdc++: Decrease the stack size for gthread threads from 4 MiB to 128 KiB #269

Merged
merged 2 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/wutstdc++/wut_gthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <coreinit/mutex.h>

#define __WUT_MAX_KEYS (128)
#define __WUT_STACK_SIZE (4096*1024)
#define __WUT_STACK_SIZE (128*1024)

#define __WUT_ONCE_VALUE_INIT (0)
#define __WUT_ONCE_VALUE_STARTED (1)
Expand Down
9 changes: 6 additions & 3 deletions libraries/wutstdc++/wut_gthread_thread.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include "wut_gthread.h"

#include <stdint.h>
#include <malloc.h>
#include <string.h>
#include <sys/errno.h>
uint32_t __attribute__((weak)) __wut_thread_default_stack_size = __WUT_STACK_SIZE;

static void
__wut_thread_deallocator(OSThread *thread,
Expand All @@ -27,9 +29,10 @@ __wut_thread_create(OSThread **outThread,
if (!thread) {
return ENOMEM;
}

memset(thread, 0, sizeof(OSThread));

char *stack = (char *)memalign(16, __WUT_STACK_SIZE);
char *stack = (char *)memalign(16, __wut_thread_default_stack_size);
if (!stack) {
free(thread);
return ENOMEM;
Expand All @@ -39,8 +42,8 @@ __wut_thread_create(OSThread **outThread,
(OSThreadEntryPointFn)entryPoint,
(int)entryArgs,
NULL,
stack + __WUT_STACK_SIZE,
__WUT_STACK_SIZE,
stack + __wut_thread_default_stack_size,
__wut_thread_default_stack_size,
16,
OS_THREAD_ATTRIB_AFFINITY_ANY)) {
free(thread);
Expand Down