kernel/eka/euser/epoc/win32/uc_exe.cpp
author Tom Cosgrove <tom.cosgrove@nokia.com>
Fri, 28 May 2010 16:29:07 +0100
changeset 30 8aab599e3476
parent 0 a41df078684a
permissions -rw-r--r--
Fix for bug 2283 (RVCT 4.0 support is missing from PDK 3.0.h) Have multiple extension sections in the bld.inf, one for each version of the compiler. The RVCT version building the tools will build the runtime libraries for its version, but make sure we extract all the other versions from zip archives. Also add the archive for RVCT4.

// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
// e32\euser\epoc\win32\uc_exe.cpp
// 
//

#include <e32std.h>
#include <e32std_private.h>
#include <e32wins.h>
#include <u32exec.h>
#include <e32svr.h>

#ifdef __VC32__
#define __FLTUSED
#endif //__VC32__

// include the static data definitions
#include "win32crt.h"

// include compiler helpers
#include "x86hlp.inl"

GLREF_C TInt E32Main();

#ifdef __CW32__
TBool InitCWRuntime();
TBool CleanupCWRuntime();
#endif

void globalDestructorFunc()
	{
#ifdef __CW32__
	CleanupCWRuntime();
#else
	destroyStatics(); // this is a macro
#endif
	}

extern "C"
EXPORT_C TInt _E32Startup(TInt aReason, TAny* aInfo)
//
// Ordinal 1 - the EPOC executable entrypoint
//
	{
	if (TUint(aReason)<=TUint(KModuleEntryReasonThreadInit))
		{
		SStdEpocThreadCreateInfo& cinfo = *(SStdEpocThreadCreateInfo*)aInfo;

#ifdef USE_INSTRUMENTED_HEAP
		cinfo.iFlags |= ETraceHeapAllocs;
#elif defined(ENABLE_HEAP_MONITORING)
		cinfo.iFlags |= ETraceHeapAllocs|EMonitorHeapMemory;
#endif
		TInt r = UserHeap::SetupThreadHeap( (aReason!=KModuleEntryReasonProcessInit), cinfo);

		if (r==KErrNone)
			r = UserSvr::DllSetTls(KGlobalDestructorTlsKey, KDllUid_Special, (TAny*)globalDestructorFunc);

		if (r==KErrNone)
			{
			if (aReason==KModuleEntryReasonProcessInit)
				{
				// Init statics for implicitly linked DLLs
				User::InitProcess();

#ifdef __CW32__
				// Ensure runtime library gets initialised
				r = InitCWRuntime() ? KErrNone : KErrGeneral;
#endif

				if (r==KErrNone)
					{
					// Init statics for EXE
					constructStatics();

					r = E32Main();
					}
				}
			else
				r = (*cinfo.iFunction)(cinfo.iPtr);
			}
		User::Exit(r);
		}
	if (aReason==KModuleEntryReasonException)
		{
		User::HandleException(aInfo);
		return 0;
		}
	User::Invariant();
	return 0;
	}

GLDEF_C void __stdcall _E32Bootstrap()
//
// Win32 entrypoint, Boot epoc with auto-run
//
	{
	BootEpoc(ETrue);
	}