1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/UCRT/WMCRT0.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,65 @@
1.4 +// Copyright (c) 1997-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 +// EPOC32 version of crt0.c for C programs which always want multi-threaded support
1.18 +//
1.19 +//
1.20 +
1.21 +#include <e32std.h>
1.22 +#include <e32base.h>
1.23 +#include <estlib.h> // for SpawnPosixServerThread()
1.24 +#include <stdlib.h>
1.25 +
1.26 +extern "C" int wmain (int argc, wchar_t *argv[], wchar_t *envp[]);
1.27 +
1.28 +GLDEF_C TInt E32Main()
1.29 + {
1.30 + CTrapCleanup::New();
1.31 +
1.32 + SpawnPosixServerThread(); // arrange for multi-threaded operation
1.33 +
1.34 + int argc=0;
1.35 + wchar_t** wargv=0;
1.36 + wchar_t** wenvp=0;
1.37 +
1.38 +
1.39 + __crt0(argc,wargv,wenvp); // get args & environment from somewhere
1.40 +
1.41 + int ret=wmain(argc, wargv, wenvp); // go
1.42 +
1.43 + // no need to explicitly delete the cleanup stack here as all memory used by
1.44 + // the process will be released by RProcess::Terminate(), called from inside exit().
1.45 +
1.46 + exit(ret); // finish with atexit processing
1.47 +
1.48 + return(KErrNone);
1.49 + }
1.50 +
1.51 +
1.52 +#ifdef __GCC32__
1.53 +
1.54 +/* stub function inserted into main() by GCC */
1.55 +#ifdef __MCORE__
1.56 +extern "C" void __main (void) {}
1.57 +#else
1.58 +extern "C" void __gccmain (void) {}
1.59 +#endif
1.60 +
1.61 +/* Default GCC entrypoint */
1.62 +extern "C" TInt _mainCRTStartup (void)
1.63 + {
1.64 + extern TInt _E32Startup();
1.65 + return _E32Startup();
1.66 + }
1.67 +
1.68 +#endif /* __GCC32__ */