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