src/s60main/qts60main_mcrt0.cpp
changeset 0 1918ee327afb
child 3 41300fa6a67c
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Symbian application wrapper of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 // MCRT0.CPP
       
    43 //
       
    44 // © Portions copyright (c) 2005-2006 Nokia Corporation.  All rights reserved.
       
    45 // Copyright (c) Symbian Software Ltd 1997-2004.  All rights reserved.
       
    46 //
       
    47 
       
    48 // EPOC32 version of crt0.c for C programs which always want multi-threaded support
       
    49 
       
    50 #include <e32std.h>
       
    51 #include <exception> // must be before e32base.h so uncaught_exception gets defined
       
    52 #include <e32base.h>
       
    53 #include "estlib.h"
       
    54 
       
    55 // Needed for QT_TRYCATCH_LEAVING.
       
    56 #include <qglobal.h>
       
    57 
       
    58 #ifdef __ARMCC__
       
    59 __asm int CallMain(int argc, char *argv[], char *envp[])
       
    60 {
       
    61     import main
       
    62     code32
       
    63     b main
       
    64 }
       
    65 #define CALLMAIN(argc, argv, envp) CallMain(argc, argv, envp)
       
    66 #else
       
    67 extern "C" int main(int argc, char *argv[], char *envp[]);
       
    68 #define CALLMAIN(argc, argv, envp) main(argc, argv, envp)
       
    69 #endif
       
    70 
       
    71 // Dummy function to handle GCCE toolchain problem
       
    72 extern "C" GLDEF_C int __GccGlueInit()
       
    73 {
       
    74     return 0;
       
    75 }
       
    76 
       
    77 extern "C" IMPORT_C void exit(int ret);
       
    78 
       
    79 GLDEF_C TInt QtMainWrapper()
       
    80 {
       
    81     int argc = 0;
       
    82     char **argv = 0;
       
    83     char **envp = 0;
       
    84     // get args & environment
       
    85     __crt0(argc, argv, envp);
       
    86     CleanupArrayDelete<char*>::PushL(argv);
       
    87     CleanupArrayDelete<char*>::PushL(envp);
       
    88     //Call user(application)'s main
       
    89     int ret = 0;
       
    90     QT_TRYCATCH_LEAVING(ret = CALLMAIN(argc, argv, envp););
       
    91     CleanupStack::PopAndDestroy(2, argv);
       
    92     return ret;
       
    93 }
       
    94 
       
    95 
       
    96 #ifdef __GCC32__
       
    97 
       
    98 /* stub function inserted into main() by GCC */
       
    99 extern "C" void __gccmain(void) {}
       
   100 
       
   101 /* Default GCC entrypoint */
       
   102 extern "C" TInt _mainCRTStartup(void)
       
   103 {
       
   104     extern TInt _E32Startup();
       
   105     return _E32Startup();
       
   106 }
       
   107 
       
   108 #endif /* __GCC32__ */
       
   109 
       
   110 #ifdef __EABI__
       
   111 
       
   112 // standard entrypoint for C runtime, expected by some linkers
       
   113 // Symbian OS does not currently use this function
       
   114 extern "C" void __main() {}
       
   115 #endif