os/kernelhwsrv/kernel/eka/euser/epoc/symc/uc_exe.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 /**
    35 We use this class to execute code before and after "main".
    36 */
    37 class TExeInit
    38    {
    39 public:
    40    TExeInit();
    41    ~TExeInit();
    42    };
    43 
    44 
    45 GLREF_C TInt E32Main();
    46 
    47 /*
    48 void globalDestructorFunc()
    49 	{
    50 	destroyStatics(); // this is a macro
    51 	}
    52 */
    53 
    54 extern "C"
    55 EXPORT_C TInt _E32Startup(TInt aReason, TAny* aInfo)
    56 //
    57 // Ordinal 1 - the EPOC executable entrypoint
    58 //
    59 	{
    60 	if (TUint(aReason)<=TUint(KModuleEntryReasonThreadInit))
    61 		{
    62 		SStdEpocThreadCreateInfo& cinfo = *(SStdEpocThreadCreateInfo*)aInfo;
    63 
    64 #ifdef USE_INSTRUMENTED_HEAP
    65 		cinfo.iFlags |= ETraceHeapAllocs;
    66 #elif defined(ENABLE_HEAP_MONITORING)
    67 		cinfo.iFlags |= ETraceHeapAllocs|EMonitorHeapMemory;
    68 #endif
    69 		TInt r = UserHeap::SetupThreadHeap( (aReason!=KModuleEntryReasonProcessInit), cinfo);
    70 
    71 		//if (r==KErrNone)
    72 		//	r = UserSvr::DllSetTls(KGlobalDestructorTlsKey, KDllUid_Special, (TAny*)globalDestructorFunc);
    73 
    74 		if (r==KErrNone)
    75 			{
    76 			if (aReason==KModuleEntryReasonProcessInit)
    77 				{
    78 				// Init statics for implicitly linked DLLs
    79 				User::InitProcess();
    80 
    81 				if (r==KErrNone)
    82 					{
    83 					// Init statics for EXE
    84 					//constructStatics();
    85 
    86 					r = E32Main();
    87 					}
    88 				}
    89 			else
    90 				r = (*cinfo.iFunction)(cinfo.iPtr);
    91 			}
    92 		User::Exit(r);
    93 		}
    94 	if (aReason==KModuleEntryReasonException)
    95 		{
    96 		User::HandleException(aInfo);
    97 		return 0;
    98 		}
    99 	User::Invariant();
   100 	return 0;
   101 	}
   102 
   103 
   104 #ifdef WIN32
   105 
   106 
   107 #define WIN32_LEAN_AND_MEAN
   108 #include <windows.h>
   109 
   110 
   111 ////Prevent early static init on win32
   112 /**
   113 Our Symbian OS EXEs are in fact Windows DLLs.
   114 */
   115 extern "C"
   116 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
   117    {
   118    return 1;
   119    }
   120 
   121 /*
   122 int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
   123    {
   124 	//Should never be run
   125 	return 0;
   126    };
   127 */
   128 
   129 
   130 
   131 
   132 TExeInit::TExeInit()
   133    {
   134 
   135    }
   136 
   137 TExeInit::~TExeInit()
   138    {
   139 
   140    }
   141 
   142 
   143 
   144 #endif