|
1 // Copyright (c) 1995-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 the License "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 // e32test\dll\t_dll2.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 #include "t_dll.h" |
|
20 |
|
21 const TInt KHeapSize=0x2000; |
|
22 |
|
23 class TlsData |
|
24 { |
|
25 public: |
|
26 TlsData() : iData(0xabcdabcd),iTest1(0),iTest2(0),iServer(0) {} |
|
27 TInt Data() {return(iData);} |
|
28 void SetData(TInt aValue) {iData=aValue;} |
|
29 public: |
|
30 TInt iData; |
|
31 TUint iTest1; |
|
32 TUint iTest2; |
|
33 TUint iServer; |
|
34 RSemaphore iSem; |
|
35 }; |
|
36 inline TlsData& Tls() |
|
37 {return(*((TlsData*)Dll::Tls()));} |
|
38 |
|
39 EXPORT_C TInt TestDll2::Data() |
|
40 // |
|
41 // Return the current TLS data value |
|
42 // |
|
43 { |
|
44 |
|
45 return(Tls().Data()); |
|
46 } |
|
47 |
|
48 EXPORT_C void TestDll2::SetData(TInt aValue) |
|
49 // |
|
50 // Return the current TLS data value |
|
51 // |
|
52 { |
|
53 |
|
54 Tls().SetData(aValue); |
|
55 } |
|
56 |
|
57 EXPORT_C TUint TestDll2::Test1() |
|
58 // |
|
59 // Return the test1 result. |
|
60 // |
|
61 { |
|
62 |
|
63 return(Tls().iTest1); |
|
64 } |
|
65 |
|
66 EXPORT_C TUint TestDll2::Test2() |
|
67 // |
|
68 // Return the test2 result. |
|
69 // |
|
70 { |
|
71 |
|
72 return(Tls().iTest2); |
|
73 } |
|
74 |
|
75 EXPORT_C TUint TestDll2::Server() |
|
76 // |
|
77 // Return the server result. |
|
78 // |
|
79 { |
|
80 |
|
81 return(Tls().iServer); |
|
82 } |
|
83 |
|
84 EXPORT_C RSemaphore TestDll2::Sem() |
|
85 // |
|
86 // Return the semaphore. |
|
87 // |
|
88 { |
|
89 |
|
90 return(Tls().iSem); |
|
91 } |
|
92 |
|
93 EXPORT_C TInt TestDll2::Attach(TBool aAttach) |
|
94 { |
|
95 TInt r = KErrNone; |
|
96 TlsData* pD; |
|
97 if (aAttach) |
|
98 { |
|
99 pD = new TlsData; |
|
100 r = Dll::SetTls(pD); |
|
101 __ASSERT_ALWAYS(r==KErrNone, User::Panic(_L("T_DLL2 att"),r)); |
|
102 } |
|
103 else |
|
104 { |
|
105 delete &Tls(); |
|
106 r = Dll::SetTls(NULL); |
|
107 __ASSERT_ALWAYS(r==KErrNone, User::Panic(_L("T_DLL2 det"),r)); |
|
108 } |
|
109 return r; |
|
110 } |
|
111 |
|
112 |
|
113 EXPORT_C TInt TestDll2::GlobalAlloc(TInt ) |
|
114 { |
|
115 return KErrNotSupported; |
|
116 } |
|
117 EXPORT_C TBool TestDll2::GlobalAllocated() |
|
118 { |
|
119 return KErrNotSupported; |
|
120 } |
|
121 EXPORT_C TInt TestDll2::GlobalRead(TInt ,TDes8 &) |
|
122 { |
|
123 return KErrNotSupported; |
|
124 } |
|
125 EXPORT_C TInt TestDll2::GlobalWrite(TInt ,const TDesC8 &) |
|
126 { |
|
127 return KErrNotSupported; |
|
128 } |
|
129 |