Initialize light primitive system if needed

This commit is contained in:
fincs 2015-09-30 00:35:01 +02:00
parent 72ea825b2d
commit abd104fae7
2 changed files with 10 additions and 0 deletions

View File

@ -11,6 +11,8 @@ void __appExit();
void __libc_fini_array(void); void __libc_fini_array(void);
Result __sync_fini(void) __attribute__((weak));
void __attribute__((weak)) __attribute__((noreturn)) __libctru_exit(int rc) void __attribute__((weak)) __attribute__((noreturn)) __libctru_exit(int rc)
{ {
u32 tmp=0; u32 tmp=0;
@ -24,6 +26,9 @@ void __attribute__((weak)) __attribute__((noreturn)) __libctru_exit(int rc)
// Close some handles // Close some handles
__destroy_handle_list(); __destroy_handle_list();
if (__sync_fini)
__sync_fini();
// Jump to the loader if it provided a callback // Jump to the loader if it provided a callback
if (__system_retAddr) if (__system_retAddr)
__system_retAddr(); __system_retAddr();

View File

@ -18,6 +18,8 @@ void __appInit();
void __ctru_exit(int rc); void __ctru_exit(int rc);
int __libctru_gtod(struct _reent *ptr, struct timeval *tp, struct timezone *tz); int __libctru_gtod(struct _reent *ptr, struct timeval *tp, struct timezone *tz);
Result __sync_init(void) __attribute__((weak));
void __attribute__((weak)) __libctru_init(void (*retAddr)(void)) void __attribute__((weak)) __libctru_init(void (*retAddr)(void))
{ {
@ -27,6 +29,9 @@ void __attribute__((weak)) __libctru_init(void (*retAddr)(void))
__system_retAddr = __service_ptr ? retAddr : NULL; __system_retAddr = __service_ptr ? retAddr : NULL;
if (__sync_init)
__sync_init();
__system_allocateHeaps(); __system_allocateHeaps();
// Build argc/argv if present // Build argc/argv if present