/* C++ Library Copyright 1983-2009 Green Hills Software,Inc. This program is the property of Green Hills Software, Inc, its contents are proprietary information and no part of it is to be disclosed to anyone except employees of Green Hills Software, Inc., or as agreed in writing signed by the President of Green Hills Software, Inc. */ /* * This file defines the _main function. _main calls the constructor functions * in the global _ctors table of function pointers. * * This file will not be linked into C++ shared objects or DLLs on Linux, * Solaris, or Windows. It's important that _main is not exported from a * shared object on these targets. The _ctors global array should also not be * exported from a shared object. */ #include typedef void (*vfpt)(); extern vfpt _ctors[]; void __call_dtors(void); #if defined(GHS_TDEH) // trg/ppc/default.gpj sets USE_TDEH which causes // src/edg/lib_src/lib*edge.gpj and integrity_edg_objs.gpj to set -DGHS_TDEH. // rtos/intlib/sharedcppobjects.c is duplicated from here. The // src/configuration/defaults/bld_rules/ppc.bod file has a GHS_SUPPORTS_TDEH // which allows INTEGRITY to use #ifdef GHS_TDEH, but this usage is dead now. #pragma weak __ghs_uw_reg_eh_table #pragma weak __ghsbegin_ghs_tdeh_table #pragma weak __ghsend_ghs_tdeh_table extern void* __ghsbegin_ghs_tdeh_table; extern void* __ghsend_ghs_tdeh_table; extern "C" void __ghs_uw_reg_eh_table(void* begtable, void* endtable); #endif /* Initialize the static constructors using the _ctors array. Set up the call to __call_dtors at the exit. */ extern "C" void _main(void) { int i = 0; static int been_here = 0; if (been_here) return; been_here = 1; /*-----------------------------*/ /* initialize TDEH */ /*-----------------------------*/ #if defined(GHS_TDEH) #if defined(__ghs_pic) static void (* tdeh_init_funcp)(void*, void*) = __ghs_uw_reg_eh_table; if (tdeh_init_funcp) #else /* defined(__ghs_pic) */ if (__ghs_uw_reg_eh_table) #endif /* defined(__ghs_pic) */ __ghs_uw_reg_eh_table(&__ghsbegin_ghs_tdeh_table, &__ghsend_ghs_tdeh_table); #endif atexit(__call_dtors); while (_ctors[i]) (*_ctors[i++])(); }