sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\euser\epoc\win32\uc_exe.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #ifdef __VC32__ sl@0: #define __FLTUSED sl@0: #endif //__VC32__ sl@0: sl@0: // include the static data definitions sl@0: #include "win32crt.h" sl@0: sl@0: // include compiler helpers sl@0: #include "x86hlp.inl" sl@0: sl@0: /** sl@0: We use this class to execute code before and after "main". sl@0: */ sl@0: class TExeInit sl@0: { sl@0: public: sl@0: TExeInit(); sl@0: ~TExeInit(); sl@0: }; sl@0: sl@0: sl@0: GLREF_C TInt E32Main(); sl@0: sl@0: /* sl@0: void globalDestructorFunc() sl@0: { sl@0: destroyStatics(); // this is a macro sl@0: } sl@0: */ sl@0: sl@0: extern "C" sl@0: EXPORT_C TInt _E32Startup(TInt aReason, TAny* aInfo) sl@0: // sl@0: // Ordinal 1 - the EPOC executable entrypoint sl@0: // sl@0: { sl@0: if (TUint(aReason)<=TUint(KModuleEntryReasonThreadInit)) sl@0: { sl@0: SStdEpocThreadCreateInfo& cinfo = *(SStdEpocThreadCreateInfo*)aInfo; sl@0: sl@0: #ifdef USE_INSTRUMENTED_HEAP sl@0: cinfo.iFlags |= ETraceHeapAllocs; sl@0: #elif defined(ENABLE_HEAP_MONITORING) sl@0: cinfo.iFlags |= ETraceHeapAllocs|EMonitorHeapMemory; sl@0: #endif sl@0: TInt r = UserHeap::SetupThreadHeap( (aReason!=KModuleEntryReasonProcessInit), cinfo); sl@0: sl@0: //if (r==KErrNone) sl@0: // r = UserSvr::DllSetTls(KGlobalDestructorTlsKey, KDllUid_Special, (TAny*)globalDestructorFunc); sl@0: sl@0: if (r==KErrNone) sl@0: { sl@0: if (aReason==KModuleEntryReasonProcessInit) sl@0: { sl@0: // Init statics for implicitly linked DLLs sl@0: User::InitProcess(); sl@0: sl@0: if (r==KErrNone) sl@0: { sl@0: // Init statics for EXE sl@0: //constructStatics(); sl@0: sl@0: r = E32Main(); sl@0: } sl@0: } sl@0: else sl@0: r = (*cinfo.iFunction)(cinfo.iPtr); sl@0: } sl@0: User::Exit(r); sl@0: } sl@0: if (aReason==KModuleEntryReasonException) sl@0: { sl@0: User::HandleException(aInfo); sl@0: return 0; sl@0: } sl@0: User::Invariant(); sl@0: return 0; sl@0: } sl@0: sl@0: sl@0: #ifdef WIN32 sl@0: sl@0: sl@0: #define WIN32_LEAN_AND_MEAN sl@0: #include sl@0: sl@0: sl@0: ////Prevent early static init on win32 sl@0: /** sl@0: Our Symbian OS EXEs are in fact Windows DLLs. sl@0: */ sl@0: extern "C" sl@0: BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) sl@0: { sl@0: return 1; sl@0: } sl@0: sl@0: /* sl@0: int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) sl@0: { sl@0: //Should never be run sl@0: return 0; sl@0: }; sl@0: */ sl@0: sl@0: sl@0: sl@0: sl@0: TExeInit::TExeInit() sl@0: { sl@0: sl@0: } sl@0: sl@0: TExeInit::~TExeInit() sl@0: { sl@0: sl@0: } sl@0: sl@0: sl@0: sl@0: #endif