os/ossrv/genericopenlibs/cstdlib/UCRT/WWCRT0.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1998-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 "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 // WCRT0.CPP
    15 // EPOC32 version of crt0.c for pure C programs, adapted to cause the full Eikon
    16 // environment to come into being and hence only used with WINS.
    17 // 
    18 //
    19 
    20 #include <e32std.h>
    21 #include <e32base.h>
    22 #include <e32svr.h>
    23 #include <estlib.h>
    24 #include <estw32.h>
    25 #include <stdlib.h>
    26 
    27 extern "C" int wmain (int argc, wchar_t *argv[], wchar_t *envp[]);
    28 
    29 #ifndef EKA2
    30 IMPORT_C void RegisterWsExe(const TDesC &aName);
    31 #endif
    32 
    33 GLDEF_C TInt E32Main()
    34 	{     
    35 	CTrapCleanup::New();
    36 
    37 	RWin32Stream::StartServer();	// arrange for access to Win32 stdin/stdout/stderr
    38 	SpawnPosixServerThread();	// arrange for multi-threaded operation
    39 
    40 	int argc=0;
    41 	wchar_t** wargv=0;
    42 	wchar_t** wenvp=0;
    43 
    44 
    45 	__crt0(argc,wargv,wenvp);			// get args & environment from somewhere
    46 
    47 #ifndef EKA2
    48 	// Cause the graphical Window Server to come into existence
    49 	RSemaphore sem;
    50 	sem.CreateGlobal(_L("WsExeSem"),0);
    51 	RegisterWsExe(sem.FullName());
    52 #endif
    53 
    54 	int ret=wmain(argc, wargv, wenvp);		// go
    55 
    56 	// no need to explicitly delete the cleanup stack here as all memory used by
    57 	// the process will be released by RProcess::Terminate(), called from inside exit().
    58 
    59 	exit(ret);	// to get atexit processing, eventually terminates this process
    60 
    61 	return(KErrNone);
    62 	}