Properly deinit logging, call missing __fini(), return instead of calling _Exit(0);

This commit is contained in:
Maschell 2022-01-21 19:02:31 +01:00
parent fb5f06064e
commit 2e44af129e
2 changed files with 18 additions and 5 deletions

View File

@ -31,7 +31,7 @@ INCLUDES := source
#-------------------------------------------------------------------------------
# options for code generation
#-------------------------------------------------------------------------------
CFLAGS := -g -Wall -O3 -ffunction-sections -fno-exceptions -fno-rtti\
CFLAGS := -g -Wall -O2 -ffunction-sections -fno-exceptions -fno-rtti\
$(MACHDEP)
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__

View File

@ -86,11 +86,19 @@ bool writeFileContent(const std::string &path, const std::string &content) {
return false;
}
extern "C" void __fini();
#ifdef DEBUG
bool module_log = false;
bool udp_log = false;
bool cafe_log = false;
#endif // DEBUG
int main(int argc, char **argv) {
#ifdef DEBUG
if (!WHBLogModuleInit()) {
WHBLogCafeInit();
WHBLogUdpInit();
if (!(module_log = WHBLogModuleInit())) {
cafe_log = WHBLogCafeInit();
udp_log = WHBLogUdpInit();
}
#endif // DEBUG
@ -230,7 +238,12 @@ int main(int argc, char **argv) {
}
ProcUIShutdown();
_Exit(0);
#ifdef DEBUG
if (module_log) { WHBLogModuleDeinit(); }
if (udp_log) { WHBLogUdpDeinit(); }
if (cafe_log) { WHBLogCafeDeinit(); }
#endif // DEBUG
__fini();
return 0;
}