/*---------------------------------------------------------------------------* Project: rsodemo File: d.c Copyright 2006 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $NoKeywords: $ *---------------------------------------------------------------------------*/ #include #define DLL_EXPORT extern #define DLL_SYMBOL(s) s #include "d.h" #undef DLL_EXPORT #undef DLL_SYMBOL #ifdef __cplusplus extern "C" { #endif typedef void (*voidfunctionptr) (void); /* ptr to function returning void */ __declspec(section ".init") extern voidfunctionptr _ctors[]; __declspec(section ".init") extern voidfunctionptr _dtors[]; void _prolog(void); void _epilog(void); void _unresolved(void); int g_intD = 5; #ifdef __cplusplus } #endif void _prolog(void) { voidfunctionptr *constructor; /* * call static initializers */ // for (constructor = _ctors; *constructor; constructor++) { (*constructor)(); } } void _epilog(void) { voidfunctionptr *destructor; /* * call destructors */ for (destructor = _dtors; *destructor; destructor++) { (*destructor)(); } } void _unresolved(void) { u32 i; u32* p; OSReport("\nError: D called an unlinked function.\n"); OSReport("Address: Back Chain LR Save\n"); for (i = 0, p = (u32*) OSGetStackPointer(); // get current sp p && (u32) p != 0xffffffff && i++ < 16; p = (u32*) *p) // get caller sp { OSReport("0x%08x: 0x%08x 0x%08x\n", p, p[0], p[1]); } OSReport("\n"); } // int FuncD_1(int a) { OSReport("FuncD_1 Call a = %d\n",a); return a; } // void FuncD_2(int a,int b) { OSReport("FuncD_2 Call a = %d b = %d\n",a,b); }