First public contribution.
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\euser\epoc\win32\uc_exe.cpp
19 #include <e32std_private.h>
28 // include the static data definitions
31 // include compiler helpers
34 GLREF_C TInt E32Main();
37 TBool InitCWRuntime();
38 TBool CleanupCWRuntime();
41 void globalDestructorFunc()
46 destroyStatics(); // this is a macro
51 EXPORT_C TInt _E32Startup(TInt aReason, TAny* aInfo)
53 // Ordinal 1 - the EPOC executable entrypoint
56 if (TUint(aReason)<=TUint(KModuleEntryReasonThreadInit))
58 SStdEpocThreadCreateInfo& cinfo = *(SStdEpocThreadCreateInfo*)aInfo;
60 #ifdef USE_INSTRUMENTED_HEAP
61 cinfo.iFlags |= ETraceHeapAllocs;
62 #elif defined(ENABLE_HEAP_MONITORING)
63 cinfo.iFlags |= ETraceHeapAllocs|EMonitorHeapMemory;
65 TInt r = UserHeap::SetupThreadHeap( (aReason!=KModuleEntryReasonProcessInit), cinfo);
68 r = UserSvr::DllSetTls(KGlobalDestructorTlsKey, KDllUid_Special, (TAny*)globalDestructorFunc);
72 if (aReason==KModuleEntryReasonProcessInit)
74 // Init statics for implicitly linked DLLs
78 // Ensure runtime library gets initialised
79 r = InitCWRuntime() ? KErrNone : KErrGeneral;
84 // Init statics for EXE
91 r = (*cinfo.iFunction)(cinfo.iPtr);
95 if (aReason==KModuleEntryReasonException)
97 User::HandleException(aInfo);
104 GLDEF_C void __stdcall _E32Bootstrap()
106 // Win32 entrypoint, Boot epoc with auto-run
114 #if defined(__SYMC__)
117 #define WIN32_LEAN_AND_MEAN
121 //Prevent early static init on win32
123 BOOL WINAPI _Win32DllMain(HINSTANCE, DWORD, LPVOID)
130 int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
132 //Should never be run