genericopenlibs/cstdlib/UCRT/WCRT0.CPP
changeset 0 e4d67989cc36
child 49 e5d77a29bdca
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     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 // EPOC32 version of crt0.c for pure C programs, adapted to cause the full Eikon
       
    15 // environment to come into being and hence only used with WINS.
       
    16 // 
       
    17 //
       
    18 
       
    19 #include <e32std.h>
       
    20 #include <e32base.h>
       
    21 #include <e32svr.h>
       
    22 #include <estlib.h>
       
    23 #include <estw32.h>
       
    24 #include <stdlib.h>
       
    25 
       
    26 extern "C" int main (int argc, char *argv[], char *envp[]);
       
    27 
       
    28 extern "C" void exit (int ret);
       
    29 
       
    30 #ifndef EKA2
       
    31 IMPORT_C void RegisterWsExe(const TDesC &aName);
       
    32 #endif
       
    33 
       
    34 GLDEF_C TInt E32Main()
       
    35 	{     
       
    36 	CTrapCleanup::New();
       
    37 
       
    38 	RWin32Stream::StartServer();	// arrange for access to Win32 stdin/stdout/stderr
       
    39 	SpawnPosixServerThread();	// arrange for multi-threaded operation
       
    40 
       
    41 	int argc=0;
       
    42 	char** argv=0;
       
    43 	char** envp=0;
       
    44 
       
    45 	__crt0(argc,argv,envp);			// 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=main(argc, argv, envp);		// 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 	}