os/ossrv/genericopenlibs/cstdlib/UCRT/ECRT0.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/UCRT/ECRT0.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,79 @@
     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 pure C programs
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <e32std.h>
    1.22 +#include <e32base.h>
    1.23 +#include <estlib.h>
    1.24 +#include <stdlib.h>
    1.25 +
    1.26 +#ifdef __ARMCC__
    1.27 +__asm int CallMain(int argc, char *argv[], char *envp[])
    1.28 +{
    1.29 +       import main
    1.30 +       code32
    1.31 +       b main
    1.32 +}
    1.33 +#define CALLMAIN(argc, argv, envp) CallMain(argc, argv, envp)
    1.34 +#else
    1.35 +extern "C" int main (int argc, char *argv[], char *envp[]);
    1.36 +#define CALLMAIN(argc, argv, envp) main(argc, argv, envp)
    1.37 +#endif
    1.38 +
    1.39 +GLDEF_C TInt E32Main()
    1.40 +	{     
    1.41 +	CTrapCleanup::New();
    1.42 +
    1.43 +	int argc=0;
    1.44 +	char** argv=0;
    1.45 +	char** envp=0;
    1.46 +
    1.47 +	__crt0(argc,argv,envp);			// get args & environment from somewhere
    1.48 +	int ret=CALLMAIN(argc, argv, envp);		// go
    1.49 +
    1.50 +	// no need to explicitly delete the cleanup stack here as all memory used by
    1.51 +	// the process will be released by RProcess::Terminate(), called from inside exit().
    1.52 +
    1.53 +	exit(ret);				// finish with atexit processing
    1.54 +
    1.55 +	return(KErrNone);
    1.56 +	}
    1.57 +
    1.58 +
    1.59 +#if defined __GCC32__ && !defined __X86GCC__
    1.60 +
    1.61 +/* stub function inserted into main() by GCC */
    1.62 +extern "C" void __gccmain (void) {}
    1.63 +
    1.64 +/* Default GCC entrypoint */
    1.65 +extern "C" TInt _mainCRTStartup (void) 
    1.66 +    {
    1.67 +    extern TInt _E32Startup();
    1.68 +    return _E32Startup();
    1.69 +    }
    1.70 +
    1.71 +#endif /* __GCC32__ */
    1.72 +
    1.73 +// X86GCC uses def files derived from EABI
    1.74 +#if (defined (__EABI__) || defined (__X86GCC__))
    1.75 +
    1.76 +// standard entrypoint for C runtime, expected by some linkers
    1.77 +// Symbian OS does not currently use this function
    1.78 +extern "C" void __main() {}
    1.79 +#endif
    1.80 +
    1.81 +
    1.82 +