[Scummvm-git-logs] scummvm master -> d3e9cdb98619d30c2d971a51ee60ffc4da8e8bfc
sev-
sev at scummvm.org
Mon Nov 1 19:31:26 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
d3e9cdb986 3DS: Set stack size w/o starting SVM inside a thread
Commit: d3e9cdb98619d30c2d971a51ee60ffc4da8e8bfc
https://github.com/scummvm/scummvm/commit/d3e9cdb98619d30c2d971a51ee60ffc4da8e8bfc
Author: Michael Ball (ballm4788 at gmail.com)
Date: 2021-11-01T20:31:23+01:00
Commit Message:
3DS: Set stack size w/o starting SVM inside a thread
This commit introduces a simpler method for setting the stack size. By setting a global variable __stacksize__,
we can override the identically-named, weak-attributed __stacksize__ defined in libctru. This is an intentional
feature of libctru, and renders it unnecessary to run ScummVM from within a thread.
Source: https://github.com/devkitPro/libctru/commit/192b88b6a21d83345a4635deba417c191c156c80
Explanation: https://gbatemp.net/threads/homebrew-development.360646/page-245#post-6362424
Usage in the wild: https://github.com/masterfeizz/ioQuake3DS/blob/master/code/ctr/ctr_main.c#L44
Changed paths:
backends/platform/3ds/main.cpp
diff --git a/backends/platform/3ds/main.cpp b/backends/platform/3ds/main.cpp
index 544e78cb86..0da971716b 100644
--- a/backends/platform/3ds/main.cpp
+++ b/backends/platform/3ds/main.cpp
@@ -30,28 +30,8 @@ enum {
SYSTEM_MODEL_2DS = 3
};
-struct CommandLine {
- int argumentCount;
- char** argumentsValue;
-
- CommandLine(int argc, char** argv): argumentCount(argc), argumentsValue(argv) {}
-};
-
-static void mainThreadFunc(void *threadParams) {
- g_system = new N3DS::OSystem_3DS();
- assert(g_system);
-
-#ifdef DYNAMIC_MODULES
- PluginManager::instance().addPluginProvider(new CTRPluginProvider());
-#endif
-
- CommandLine *commandLine = static_cast<CommandLine *>(threadParams);
- int res = scummvm_main(commandLine->argumentCount, commandLine->argumentsValue);
-
- g_system->destroy();
-
- threadExit(res);
-};
+// Set the size of the stack.
+u32 __stacksize__ = 64 * 1024;
int main(int argc, char *argv[]) {
// Initialize basic libctru stuff
@@ -75,17 +55,16 @@ int main(int argc, char *argv[]) {
socInit((u32 *)soc_sharedmem, soc_sharedmem_size);
#endif
- // Start ScummVM in a separate thread to be able to set the stack size.
- // The default stack is not large enough.
- CommandLine commandLine(argc, argv);
+ g_system = new N3DS::OSystem_3DS();
+ assert(g_system);
+
+#ifdef DYNAMIC_MODULES
+ PluginManager::instance().addPluginProvider(new CTRPluginProvider());
+#endif
- s32 mainThreadPriority = 0;
- svcGetThreadPriority(&mainThreadPriority, CUR_THREAD_HANDLE);
+ int res = scummvm_main(argc, argv);
- Thread mainThread = threadCreate(&mainThreadFunc, &commandLine, 64 * 1024, mainThreadPriority, -2, false);
- threadJoin(mainThread, U64_MAX);
- int res = threadGetExitCode(mainThread);
- threadFree(mainThread);
+ g_system->destroy();
// Turn on both screen backlights before exiting.
if (R_SUCCEEDED(gspLcdInit())) {
More information about the Scummvm-git-logs
mailing list