1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/euser/epoc/arm/uc_exe.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,109 @@
1.4 +// Copyright (c) 1995-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 the License "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 +// e32\euser\epoc\arm\uc_exe.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include "u32std.h"
1.22 +#include <u32exec.h>
1.23 +#include <e32svr.h>
1.24 +
1.25 +GLREF_C TInt E32Main();
1.26 +
1.27 +extern "C" {
1.28 +
1.29 +#if defined(__GCC32__)
1.30 +typedef void (*PFV)();
1.31 +extern PFV __CTOR_LIST__[];
1.32 +extern PFV __DTOR_LIST__[];
1.33 +
1.34 +void globalDestructorFunc()
1.35 + {
1.36 + TUint i=1;
1.37 + while (__DTOR_LIST__[i])
1.38 + (*__DTOR_LIST__[i++])();
1.39 + }
1.40 +
1.41 +void RunThread(TBool aNotFirst, SThreadCreateInfo& aInfo)
1.42 + {
1.43 + SStdEpocThreadCreateInfo& cinfo = (SStdEpocThreadCreateInfo&)aInfo;
1.44 +
1.45 +#ifdef USE_INSTRUMENTED_HEAP
1.46 + cinfo.iFlags |= ETraceHeapAllocs;
1.47 +#elif defined(ENABLE_HEAP_MONITORING)
1.48 + cinfo.iFlags |= ETraceHeapAllocs|EMonitorHeapMemory;
1.49 +#endif
1.50 + TInt r = UserHeap::SetupThreadHeap(aNotFirst, cinfo);
1.51 +
1.52 + if (r==KErrNone)
1.53 + r = UserSvr::DllSetTls(KGlobalDestructorTlsKey, KDllUid_Special, (TAny*)globalDestructorFunc);
1.54 +
1.55 + if (r==KErrNone)
1.56 + {
1.57 + if (aNotFirst)
1.58 + r = (*cinfo.iFunction)(cinfo.iPtr);
1.59 + else
1.60 + {
1.61 + // Init statics for implicitly linked DLLs
1.62 + User::InitProcess();
1.63 +
1.64 + // Init statics for EXE
1.65 + TUint i=1;
1.66 + while (__CTOR_LIST__[i])
1.67 + (*__CTOR_LIST__[i++])();
1.68 +
1.69 + r = E32Main();
1.70 + }
1.71 + }
1.72 + User::Exit(r);
1.73 + }
1.74 +}
1.75 +
1.76 +#elif defined(__ARMCC__)
1.77 +
1.78 +TInt CallThrdProcEntry(TInt (*aFn)(void*), void* aPtr, TInt aNotFirst);
1.79 +
1.80 +__weak void run_static_dtors(void);
1.81 +
1.82 +void globalDestructorFunc()
1.83 + {
1.84 + int call_static_dtors = (int)run_static_dtors;
1.85 + if (call_static_dtors)
1.86 + run_static_dtors();
1.87 + }
1.88 +
1.89 +void RunThread(TBool aNotFirst, SThreadCreateInfo& aInfo)
1.90 + {
1.91 + SStdEpocThreadCreateInfo& cinfo = (SStdEpocThreadCreateInfo&)aInfo;
1.92 +
1.93 +#ifdef USE_INSTRUMENTED_HEAP
1.94 + cinfo.iFlags |= ETraceHeapAllocs;
1.95 +#elif defined(ENABLE_HEAP_MONITORING)
1.96 + cinfo.iFlags |= ETraceHeapAllocs|EMonitorHeapMemory;
1.97 +#endif
1.98 + TInt r = UserHeap::SetupThreadHeap(aNotFirst, cinfo);
1.99 +
1.100 + if (r==KErrNone)
1.101 + r = UserSvr::DllSetTls(KGlobalDestructorTlsKey, KDllUid_Special, (TAny*)globalDestructorFunc);
1.102 +
1.103 + if (r==KErrNone)
1.104 + r = CallThrdProcEntry(cinfo.iFunction, cinfo.iPtr, aNotFirst);
1.105 +
1.106 + User::Exit(r);
1.107 + }
1.108 +}
1.109 +
1.110 +#else
1.111 +#error not supported
1.112 +#endif