os/ossrv/genericopenlibs/cstdlib/UCRT/ECRT0.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 pure C programs
    15 // 
    16 //
    17 
    18 #include <e32std.h>
    19 #include <e32base.h>
    20 #include <estlib.h>
    21 #include <stdlib.h>
    22 
    23 #ifdef __ARMCC__
    24 __asm int CallMain(int argc, char *argv[], char *envp[])
    25 {
    26        import main
    27        code32
    28        b main
    29 }
    30 #define CALLMAIN(argc, argv, envp) CallMain(argc, argv, envp)
    31 #else
    32 extern "C" int main (int argc, char *argv[], char *envp[]);
    33 #define CALLMAIN(argc, argv, envp) main(argc, argv, envp)
    34 #endif
    35 
    36 GLDEF_C TInt E32Main()
    37 	{     
    38 	CTrapCleanup::New();
    39 
    40 	int argc=0;
    41 	char** argv=0;
    42 	char** envp=0;
    43 
    44 	__crt0(argc,argv,envp);			// get args & environment from somewhere
    45 	int ret=CALLMAIN(argc, argv, envp);		// go
    46 
    47 	// no need to explicitly delete the cleanup stack here as all memory used by
    48 	// the process will be released by RProcess::Terminate(), called from inside exit().
    49 
    50 	exit(ret);				// finish with atexit processing
    51 
    52 	return(KErrNone);
    53 	}
    54 
    55 
    56 #if defined __GCC32__ && !defined __X86GCC__
    57 
    58 /* stub function inserted into main() by GCC */
    59 extern "C" void __gccmain (void) {}
    60 
    61 /* Default GCC entrypoint */
    62 extern "C" TInt _mainCRTStartup (void) 
    63     {
    64     extern TInt _E32Startup();
    65     return _E32Startup();
    66     }
    67 
    68 #endif /* __GCC32__ */
    69 
    70 // X86GCC uses def files derived from EABI
    71 #if (defined (__EABI__) || defined (__X86GCC__))
    72 
    73 // standard entrypoint for C runtime, expected by some linkers
    74 // Symbian OS does not currently use this function
    75 extern "C" void __main() {}
    76 #endif
    77 
    78 
    79