os/ossrv/genericopenlibs/cstdlib/UCRT/WMCRT0.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1997-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 C programs which always want multi-threaded support
    15 // 
    16 //
    17 
    18 #include <e32std.h>
    19 #include <e32base.h>
    20 #include <estlib.h>	// for SpawnPosixServerThread()
    21 #include <stdlib.h>
    22 
    23 extern "C" int wmain (int argc, wchar_t *argv[], wchar_t *envp[]);
    24 
    25 GLDEF_C TInt E32Main()
    26 	{     
    27 	CTrapCleanup::New();
    28 
    29 	SpawnPosixServerThread();		// arrange for multi-threaded operation
    30 
    31 	int argc=0;
    32 	wchar_t** wargv=0;
    33 	wchar_t** wenvp=0;
    34 
    35 
    36 	__crt0(argc,wargv,wenvp);			// get args & environment from somewhere
    37 
    38 	int ret=wmain(argc, wargv, wenvp);		// go
    39 
    40 	// no need to explicitly delete the cleanup stack here as all memory used by
    41 	// the process will be released by RProcess::Terminate(), called from inside exit().
    42 
    43 	exit(ret);				// finish with atexit processing
    44 
    45 	return(KErrNone);
    46 	}
    47 
    48 
    49 #ifdef __GCC32__
    50 
    51 /* stub function inserted into main() by GCC */
    52 #ifdef __MCORE__
    53 extern "C" void __main (void) {}
    54 #else
    55 extern "C" void __gccmain (void) {}
    56 #endif
    57 
    58 /* Default GCC entrypoint */
    59 extern "C" TInt _mainCRTStartup (void) 
    60     {
    61     extern TInt _E32Startup();
    62     return _E32Startup();
    63     }
    64 
    65 #endif /* __GCC32__ */