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