diff options
Diffstat (limited to 'src/s60main')
-rw-r--r-- | src/s60main/newallocator_hook.cpp | 58 | ||||
-rw-r--r-- | src/s60main/qts60main.cpp | 61 | ||||
-rw-r--r-- | src/s60main/qts60main_mcrt0.cpp | 112 | ||||
-rw-r--r-- | src/s60main/s60main.pro | 38 |
4 files changed, 269 insertions, 0 deletions
diff --git a/src/s60main/newallocator_hook.cpp b/src/s60main/newallocator_hook.cpp new file mode 100644 index 0000000000..9cc6afb728 --- /dev/null +++ b/src/s60main/newallocator_hook.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Symbian application wrapper of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <e32std.h> +#include <qglobal.h> + +struct SStdEpocThreadCreateInfo; + +Q_CORE_EXPORT TInt qt_symbian_SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo); + + +/* \internal + * + * Uses link-time symbol preemption to capture a call from the application + * startup. On return, there is some kind of heap allocator installed on the + * thread. +*/ +TInt UserHeap::SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo) +{ + return qt_symbian_SetupThreadHeap(aNotFirst, aInfo); +} diff --git a/src/s60main/qts60main.cpp b/src/s60main/qts60main.cpp new file mode 100644 index 0000000000..c6fd39b7b0 --- /dev/null +++ b/src/s60main/qts60main.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Symbian application wrapper of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// INCLUDE FILES +#include <exception> // must be before e32base.h so uncaught_exception gets defined +#include <e32base.h> +#include <qglobal.h> + +GLDEF_C TInt QtMainWrapper(); + +/** + * A normal Symbian OS executable provides an E32Main() function which is + * called by the operating system to start the program. + */ +GLDEF_C TInt E32Main() +{ + CTrapCleanup *cleanupStack = CTrapCleanup::New(); + Q_CHECK_PTR(cleanupStack); + TInt err = 0; + TRAP(err, err = QtMainWrapper()); + delete cleanupStack; + + return err; +} diff --git a/src/s60main/qts60main_mcrt0.cpp b/src/s60main/qts60main_mcrt0.cpp new file mode 100644 index 0000000000..d397864903 --- /dev/null +++ b/src/s60main/qts60main_mcrt0.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Symbian application wrapper of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// MCRT0.CPP +// +// Portions copyright (c) 2005-2006 Nokia Corporation. All rights reserved. +// Copyright (c) Symbian Software Ltd 1997-2004. All rights reserved. +// + +// EPOC32 version of crt0.c for C programs which always want multi-threaded support + +#include <e32std.h> +#include <exception> // must be before e32base.h so uncaught_exception gets defined +#include <e32base.h> +#include "estlib.h" + +// Needed for QT_TRYCATCH_LEAVING. +#include <qglobal.h> + +#ifdef __ARMCC__ +__asm int CallMain(int argc, char *argv[], char *envp[]) +{ + import main + code32 + b main +} +#define CALLMAIN(argc, argv, envp) CallMain(argc, argv, envp) +#else +extern "C" int main(int argc, char *argv[], char *envp[]); +#define CALLMAIN(argc, argv, envp) main(argc, argv, envp) +#endif + +// Dummy function to handle GCCE toolchain problem +extern "C" GLDEF_C int __GccGlueInit() +{ + return 0; +} + +extern "C" IMPORT_C void exit(int ret); + +GLDEF_C TInt QtMainWrapper() +{ + int argc = 0; + // these variables are declared static in the expectation that this function is not reentrant + // and so that memory analysis tools can trace any memory allocated in __crt0() to global memory ownership. + static char **argv = 0; + static char **envp = 0; + // get args & environment + __crt0(argc, argv, envp); + //Call user(application)'s main + TRAPD(ret, QT_TRYCATCH_LEAVING(ret = CALLMAIN(argc, argv, envp);)); + return ret; +} + + +#ifdef __GCC32__ + +/* stub function inserted into main() by GCC */ +extern "C" void __gccmain(void) {} + +/* Default GCC entrypoint */ +extern "C" TInt _mainCRTStartup(void) +{ + extern TInt _E32Startup(); + return _E32Startup(); +} + +#endif /* __GCC32__ */ + +#ifdef __EABI__ + +// standard entrypoint for C runtime, expected by some linkers +// Symbian OS does not currently use this function +extern "C" void __main() {} +#endif diff --git a/src/s60main/s60main.pro b/src/s60main/s60main.pro new file mode 100644 index 0000000000..4c598e2857 --- /dev/null +++ b/src/s60main/s60main.pro @@ -0,0 +1,38 @@ +# Additional Qt project file for qtmain lib on Symbian +TEMPLATE = lib +TARGET = qtmain +DESTDIR = $$QMAKE_LIBDIR_QT +QT = + +CONFIG += staticlib warn_on +CONFIG -= qt shared + +symbian { + # Note: UID only needed for ensuring that no filename generation conflicts occur + TARGET.UID3 = 0x2001E61F + CONFIG += png zlib + CONFIG -= jpeg + INCLUDEPATH += tmp $$QMAKE_INCDIR_QT/QtCore $$MW_LAYER_SYSTEMINCLUDE + SOURCES = qts60main.cpp \ + qts60main_mcrt0.cpp \ + newallocator_hook.cpp + + # s60main needs to be built in ARM mode for GCCE to work. + CONFIG += do_not_build_as_thumb + + # staticlib should not have any lib depencies in s60 + # This seems not to work, some hard coded libs are still added as dependency + LIBS = + + # Workaround for abld toolchain problem to make ARMV6 qtmain.lib link with GCCE apps + symbian-abld: QMAKE_CXXFLAGS.ARMCC += --dllimport_runtime + + # Having MMP_RULES_DONT_EXPORT_ALL_CLASS_IMPEDIMENTA will cause s60main.lib be unlinkable + # against GCCE apps, so remove it + MMP_RULES -= $$MMP_RULES_DONT_EXPORT_ALL_CLASS_IMPEDIMENTA + symbian-armcc:QMAKE_CXXFLAGS *= --export_all_vtbl +} else { + error("$$_FILE_ is intended only for Symbian!") +} + +include(../qbase.pri) |