mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
Added static initializers to handle global objects allocation
svn-id: r25078
This commit is contained in:
parent
bc041f4b25
commit
b500f02e61
@ -33,19 +33,25 @@
|
||||
// contrast to "PilotMain" for 68K applications.
|
||||
#define PNO_Main ARMlet_Main
|
||||
|
||||
#ifdef COMPILE_ZODIAC
|
||||
const void* twEmulState;
|
||||
Call68KFuncType* twCall68KFunc;
|
||||
#endif
|
||||
/* Prepare static initializers */
|
||||
extern long __sinit__[];
|
||||
extern void __ARMlet_Startup__();
|
||||
|
||||
/* simple function pointer */
|
||||
typedef void (*StaticInitializer)(void);
|
||||
|
||||
unsigned long PNO_Main(const void *emulStateP, void *userData68KP, Call68KFuncType *call68KFuncP) {
|
||||
#ifdef COMPILE_ZODIAC
|
||||
twEmulState = emulStateP;
|
||||
twCall68KFunc = call68KFuncP;
|
||||
#else
|
||||
global.emulStateP = (EmulStateType *)emulStateP;
|
||||
global.call68KFuncP = call68KFuncP;
|
||||
#endif
|
||||
|
||||
// handle static initializers
|
||||
if (__sinit__) {
|
||||
long base = (long)__ARMlet_Startup__;
|
||||
long s, *p;
|
||||
|
||||
for (p = __sinit__; p && (s = *p) != 0; p++)
|
||||
((StaticInitializer)(s + base))();
|
||||
}
|
||||
|
||||
return PilotMain(sysAppLaunchCmdNormalLaunch, userData68KP, 0);
|
||||
}
|
||||
|
@ -48,6 +48,8 @@ GlobalsDataType g_vars;
|
||||
GlobalsDataPtr gVars = &g_vars;
|
||||
UInt32 g_stackSize;
|
||||
|
||||
extern "C" void __destroy_global_chain(void);
|
||||
|
||||
static void palm_main(int argc, char **argvP) {
|
||||
#ifdef COMPILE_OS5
|
||||
if (gVars->advancedMode)
|
||||
@ -143,5 +145,8 @@ extern UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) {
|
||||
free(g_newStack);
|
||||
}
|
||||
|
||||
// Destroy all constructed global objects
|
||||
__destroy_global_chain();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ UInt32 __ARMlet_Startup__(const void*, void*, Call68KFuncType*);
|
||||
* mark the start and end of the various data sections.
|
||||
*/
|
||||
extern long __DataStart__[];
|
||||
extern long __sinit__[];
|
||||
extern long __RODataStart__[];
|
||||
extern long __BSSStart__[];
|
||||
extern long __BSSEnd__[];
|
||||
@ -64,6 +65,9 @@ extern long __CodeRelocEnd__[];
|
||||
extern long __DataRelocStart__[];
|
||||
extern long __DataRelocEnd__[];
|
||||
|
||||
/* simple function pointer */
|
||||
typedef void (*StaticInitializer)(void);
|
||||
|
||||
/*
|
||||
* This function performs relocation for Tapwave Native Application.
|
||||
*/
|
||||
@ -73,6 +77,14 @@ static void relocate(void)
|
||||
long base = (long) __ARMlet_Startup__;
|
||||
long *cur, *end;
|
||||
|
||||
// handle static initializers
|
||||
if (__sinit__) {
|
||||
long s, *p;
|
||||
|
||||
for (p = __sinit__; p && (s = *p) != 0; p++)
|
||||
((StaticInitializer)(s + base))();
|
||||
}
|
||||
|
||||
// handle code-to-data relocation
|
||||
cur = __CodeRelocStart__;
|
||||
end = __CodeRelocEnd__;
|
||||
|
Loading…
Reference in New Issue
Block a user