2014-12-25 11:50:38 +01:00
|
|
|
#include <sys/iosupport.h>
|
2015-02-23 18:41:10 +01:00
|
|
|
#include <sys/time.h>
|
2014-12-25 11:50:38 +01:00
|
|
|
#include <string.h>
|
2015-11-15 18:37:04 +01:00
|
|
|
|
2014-12-25 11:50:38 +01:00
|
|
|
#include <3ds/types.h>
|
|
|
|
#include <3ds/svc.h>
|
2015-11-15 18:37:04 +01:00
|
|
|
#include <3ds/env.h>
|
2014-12-25 11:50:38 +01:00
|
|
|
|
|
|
|
void (*__system_retAddr)(void);
|
|
|
|
|
|
|
|
void __system_allocateHeaps();
|
|
|
|
void __system_initArgv();
|
2014-12-26 00:27:36 +01:00
|
|
|
void __appInit();
|
2014-12-25 11:50:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
void __ctru_exit(int rc);
|
2015-02-23 18:41:10 +01:00
|
|
|
int __libctru_gtod(struct _reent *ptr, struct timeval *tp, struct timezone *tz);
|
2014-12-25 11:50:38 +01:00
|
|
|
|
2015-09-30 00:35:01 +02:00
|
|
|
Result __sync_init(void) __attribute__((weak));
|
|
|
|
|
2014-12-30 23:37:53 +01:00
|
|
|
void __attribute__((weak)) __libctru_init(void (*retAddr)(void))
|
2014-12-25 11:50:38 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
// Register newlib exit() syscall
|
|
|
|
__syscalls.exit = __ctru_exit;
|
2015-02-23 18:41:10 +01:00
|
|
|
__syscalls.gettod_r = __libctru_gtod;
|
|
|
|
|
2015-11-15 18:37:04 +01:00
|
|
|
__system_retAddr = envIsHomebrew() ? retAddr : NULL;
|
2014-12-25 11:50:38 +01:00
|
|
|
|
2015-09-30 00:35:01 +02:00
|
|
|
if (__sync_init)
|
|
|
|
__sync_init();
|
|
|
|
|
2014-12-25 11:50:38 +01:00
|
|
|
__system_allocateHeaps();
|
|
|
|
|
|
|
|
// Build argc/argv if present
|
|
|
|
__system_initArgv();
|
|
|
|
|
|
|
|
}
|