os/kernelhwsrv/kernel/eka/euser/epoc/win32/uc_exe.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // e32\euser\epoc\win32\uc_exe.cpp
    15 // 
    16 //
    17 
    18 #include <e32std.h>
    19 #include <e32std_private.h>
    20 #include <e32wins.h>
    21 #include <u32exec.h>
    22 #include <e32svr.h>
    23 
    24 #ifdef __VC32__
    25 #define __FLTUSED
    26 #endif //__VC32__
    27 
    28 // include the static data definitions
    29 #include "win32crt.h"
    30 
    31 // include compiler helpers
    32 #include "x86hlp.inl"
    33 
    34 GLREF_C TInt E32Main();
    35 
    36 #ifdef __CW32__
    37 TBool InitCWRuntime();
    38 TBool CleanupCWRuntime();
    39 #endif
    40 
    41 void globalDestructorFunc()
    42 	{
    43 #ifdef __CW32__
    44 	CleanupCWRuntime();
    45 #else
    46 	destroyStatics(); // this is a macro
    47 #endif
    48 	}
    49 
    50 extern "C"
    51 EXPORT_C TInt _E32Startup(TInt aReason, TAny* aInfo)
    52 //
    53 // Ordinal 1 - the EPOC executable entrypoint
    54 //
    55 	{
    56 	if (TUint(aReason)<=TUint(KModuleEntryReasonThreadInit))
    57 		{
    58 		SStdEpocThreadCreateInfo& cinfo = *(SStdEpocThreadCreateInfo*)aInfo;
    59 
    60 #ifdef USE_INSTRUMENTED_HEAP
    61 		cinfo.iFlags |= ETraceHeapAllocs;
    62 #elif defined(ENABLE_HEAP_MONITORING)
    63 		cinfo.iFlags |= ETraceHeapAllocs|EMonitorHeapMemory;
    64 #endif
    65 		TInt r = UserHeap::SetupThreadHeap( (aReason!=KModuleEntryReasonProcessInit), cinfo);
    66 
    67 		if (r==KErrNone)
    68 			r = UserSvr::DllSetTls(KGlobalDestructorTlsKey, KDllUid_Special, (TAny*)globalDestructorFunc);
    69 
    70 		if (r==KErrNone)
    71 			{
    72 			if (aReason==KModuleEntryReasonProcessInit)
    73 				{
    74 				// Init statics for implicitly linked DLLs
    75 				User::InitProcess();
    76 
    77 #ifdef __CW32__
    78 				// Ensure runtime library gets initialised
    79 				r = InitCWRuntime() ? KErrNone : KErrGeneral;
    80 #endif
    81 
    82 				if (r==KErrNone)
    83 					{
    84 					// Init statics for EXE
    85 					constructStatics();
    86 
    87 					r = E32Main();
    88 					}
    89 				}
    90 			else
    91 				r = (*cinfo.iFunction)(cinfo.iPtr);
    92 			}
    93 		User::Exit(r);
    94 		}
    95 	if (aReason==KModuleEntryReasonException)
    96 		{
    97 		User::HandleException(aInfo);
    98 		return 0;
    99 		}
   100 	User::Invariant();
   101 	return 0;
   102 	}
   103 
   104 GLDEF_C void __stdcall _E32Bootstrap()
   105 //
   106 // Win32 entrypoint, Boot epoc with auto-run
   107 //
   108 	{
   109 	BootEpoc(ETrue);
   110 	}
   111 
   112 
   113 
   114 #if defined(__SYMC__) 
   115 
   116 /*
   117 #define WIN32_LEAN_AND_MEAN
   118 #include <windows.h>
   119 
   120 
   121 //Prevent early static init on win32
   122 extern "C"
   123 BOOL WINAPI _Win32DllMain(HINSTANCE, DWORD, LPVOID)
   124 	{
   125 	return 1;
   126 	}
   127 
   128 
   129 
   130 int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
   131 {
   132 	//Should never be run
   133 	return 0;
   134 };
   135 */
   136 
   137 
   138 #endif