os/ossrv/genericopenlibs/cstdlib/UCRT/WWCRT0.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/UCRT/WWCRT0.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,62 @@
     1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// WCRT0.CPP
    1.18 +// EPOC32 version of crt0.c for pure C programs, adapted to cause the full Eikon
    1.19 +// environment to come into being and hence only used with WINS.
    1.20 +// 
    1.21 +//
    1.22 +
    1.23 +#include <e32std.h>
    1.24 +#include <e32base.h>
    1.25 +#include <e32svr.h>
    1.26 +#include <estlib.h>
    1.27 +#include <estw32.h>
    1.28 +#include <stdlib.h>
    1.29 +
    1.30 +extern "C" int wmain (int argc, wchar_t *argv[], wchar_t *envp[]);
    1.31 +
    1.32 +#ifndef EKA2
    1.33 +IMPORT_C void RegisterWsExe(const TDesC &aName);
    1.34 +#endif
    1.35 +
    1.36 +GLDEF_C TInt E32Main()
    1.37 +	{     
    1.38 +	CTrapCleanup::New();
    1.39 +
    1.40 +	RWin32Stream::StartServer();	// arrange for access to Win32 stdin/stdout/stderr
    1.41 +	SpawnPosixServerThread();	// arrange for multi-threaded operation
    1.42 +
    1.43 +	int argc=0;
    1.44 +	wchar_t** wargv=0;
    1.45 +	wchar_t** wenvp=0;
    1.46 +
    1.47 +
    1.48 +	__crt0(argc,wargv,wenvp);			// get args & environment from somewhere
    1.49 +
    1.50 +#ifndef EKA2
    1.51 +	// Cause the graphical Window Server to come into existence
    1.52 +	RSemaphore sem;
    1.53 +	sem.CreateGlobal(_L("WsExeSem"),0);
    1.54 +	RegisterWsExe(sem.FullName());
    1.55 +#endif
    1.56 +
    1.57 +	int ret=wmain(argc, wargv, wenvp);		// go
    1.58 +
    1.59 +	// no need to explicitly delete the cleanup stack here as all memory used by
    1.60 +	// the process will be released by RProcess::Terminate(), called from inside exit().
    1.61 +
    1.62 +	exit(ret);	// to get atexit processing, eventually terminates this process
    1.63 +
    1.64 +	return(KErrNone);
    1.65 +	}