sl@0
|
1 |
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32\euser\epoc\arm\uc_exe.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "u32std.h"
|
sl@0
|
19 |
#include <u32exec.h>
|
sl@0
|
20 |
#include <e32svr.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
GLREF_C TInt E32Main();
|
sl@0
|
23 |
|
sl@0
|
24 |
extern "C" {
|
sl@0
|
25 |
|
sl@0
|
26 |
#if defined(__GCC32__)
|
sl@0
|
27 |
typedef void (*PFV)();
|
sl@0
|
28 |
extern PFV __CTOR_LIST__[];
|
sl@0
|
29 |
extern PFV __DTOR_LIST__[];
|
sl@0
|
30 |
|
sl@0
|
31 |
void globalDestructorFunc()
|
sl@0
|
32 |
{
|
sl@0
|
33 |
TUint i=1;
|
sl@0
|
34 |
while (__DTOR_LIST__[i])
|
sl@0
|
35 |
(*__DTOR_LIST__[i++])();
|
sl@0
|
36 |
}
|
sl@0
|
37 |
|
sl@0
|
38 |
void RunThread(TBool aNotFirst, SThreadCreateInfo& aInfo)
|
sl@0
|
39 |
{
|
sl@0
|
40 |
SStdEpocThreadCreateInfo& cinfo = (SStdEpocThreadCreateInfo&)aInfo;
|
sl@0
|
41 |
|
sl@0
|
42 |
#ifdef USE_INSTRUMENTED_HEAP
|
sl@0
|
43 |
cinfo.iFlags |= ETraceHeapAllocs;
|
sl@0
|
44 |
#elif defined(ENABLE_HEAP_MONITORING)
|
sl@0
|
45 |
cinfo.iFlags |= ETraceHeapAllocs|EMonitorHeapMemory;
|
sl@0
|
46 |
#endif
|
sl@0
|
47 |
TInt r = UserHeap::SetupThreadHeap(aNotFirst, cinfo);
|
sl@0
|
48 |
|
sl@0
|
49 |
if (r==KErrNone)
|
sl@0
|
50 |
r = UserSvr::DllSetTls(KGlobalDestructorTlsKey, KDllUid_Special, (TAny*)globalDestructorFunc);
|
sl@0
|
51 |
|
sl@0
|
52 |
if (r==KErrNone)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
if (aNotFirst)
|
sl@0
|
55 |
r = (*cinfo.iFunction)(cinfo.iPtr);
|
sl@0
|
56 |
else
|
sl@0
|
57 |
{
|
sl@0
|
58 |
// Init statics for implicitly linked DLLs
|
sl@0
|
59 |
User::InitProcess();
|
sl@0
|
60 |
|
sl@0
|
61 |
// Init statics for EXE
|
sl@0
|
62 |
TUint i=1;
|
sl@0
|
63 |
while (__CTOR_LIST__[i])
|
sl@0
|
64 |
(*__CTOR_LIST__[i++])();
|
sl@0
|
65 |
|
sl@0
|
66 |
r = E32Main();
|
sl@0
|
67 |
}
|
sl@0
|
68 |
}
|
sl@0
|
69 |
User::Exit(r);
|
sl@0
|
70 |
}
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
#elif defined(__ARMCC__)
|
sl@0
|
74 |
|
sl@0
|
75 |
TInt CallThrdProcEntry(TInt (*aFn)(void*), void* aPtr, TInt aNotFirst);
|
sl@0
|
76 |
|
sl@0
|
77 |
__weak void run_static_dtors(void);
|
sl@0
|
78 |
|
sl@0
|
79 |
void globalDestructorFunc()
|
sl@0
|
80 |
{
|
sl@0
|
81 |
int call_static_dtors = (int)run_static_dtors;
|
sl@0
|
82 |
if (call_static_dtors)
|
sl@0
|
83 |
run_static_dtors();
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
void RunThread(TBool aNotFirst, SThreadCreateInfo& aInfo)
|
sl@0
|
87 |
{
|
sl@0
|
88 |
SStdEpocThreadCreateInfo& cinfo = (SStdEpocThreadCreateInfo&)aInfo;
|
sl@0
|
89 |
|
sl@0
|
90 |
#ifdef USE_INSTRUMENTED_HEAP
|
sl@0
|
91 |
cinfo.iFlags |= ETraceHeapAllocs;
|
sl@0
|
92 |
#elif defined(ENABLE_HEAP_MONITORING)
|
sl@0
|
93 |
cinfo.iFlags |= ETraceHeapAllocs|EMonitorHeapMemory;
|
sl@0
|
94 |
#endif
|
sl@0
|
95 |
TInt r = UserHeap::SetupThreadHeap(aNotFirst, cinfo);
|
sl@0
|
96 |
|
sl@0
|
97 |
if (r==KErrNone)
|
sl@0
|
98 |
r = UserSvr::DllSetTls(KGlobalDestructorTlsKey, KDllUid_Special, (TAny*)globalDestructorFunc);
|
sl@0
|
99 |
|
sl@0
|
100 |
if (r==KErrNone)
|
sl@0
|
101 |
r = CallThrdProcEntry(cinfo.iFunction, cinfo.iPtr, aNotFirst);
|
sl@0
|
102 |
|
sl@0
|
103 |
User::Exit(r);
|
sl@0
|
104 |
}
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|
sl@0
|
107 |
#else
|
sl@0
|
108 |
#error not supported
|
sl@0
|
109 |
#endif
|