1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/dll/t_dll1.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,129 @@
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 +// e32test\dll\t_dll1.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include "t_dll.h"
1.22 +
1.23 +const TInt KHeapSize=0x2000;
1.24 +
1.25 +class TlsData
1.26 + {
1.27 +public:
1.28 + TlsData() : iData(0x12345678),iTest1(0),iTest2(0),iServer(0) {}
1.29 + TInt Data() {return(iData);}
1.30 + void SetData(TInt aValue) {iData=aValue;}
1.31 +public:
1.32 + TInt iData;
1.33 + TUint iTest1;
1.34 + TUint iTest2;
1.35 + TUint iServer;
1.36 + RSemaphore iSem;
1.37 + };
1.38 +inline TlsData& Tls()
1.39 + {return(*((TlsData*)Dll::Tls()));}
1.40 +
1.41 +EXPORT_C TInt TestDll1::Data()
1.42 +//
1.43 +// Return the current TLS data value
1.44 +//
1.45 + {
1.46 +
1.47 + return(Tls().Data());
1.48 + }
1.49 +
1.50 +EXPORT_C void TestDll1::SetData(TInt aValue)
1.51 +//
1.52 +// Return the current TLS data value
1.53 +//
1.54 + {
1.55 +
1.56 + Tls().SetData(aValue);
1.57 + }
1.58 +
1.59 +EXPORT_C TUint TestDll1::Test1()
1.60 +//
1.61 +// Return the test1 result.
1.62 +//
1.63 + {
1.64 +
1.65 + return(Tls().iTest1);
1.66 + }
1.67 +
1.68 +EXPORT_C TUint TestDll1::Test2()
1.69 +//
1.70 +// Return the test2 result.
1.71 +//
1.72 + {
1.73 +
1.74 + return(Tls().iTest2);
1.75 + }
1.76 +
1.77 +EXPORT_C TUint TestDll1::Server()
1.78 +//
1.79 +// Return the server result.
1.80 +//
1.81 + {
1.82 +
1.83 + return(Tls().iServer);
1.84 + }
1.85 +
1.86 +EXPORT_C RSemaphore TestDll1::Sem()
1.87 +//
1.88 +// Return the semaphore.
1.89 +//
1.90 + {
1.91 +
1.92 + return(Tls().iSem);
1.93 + }
1.94 +
1.95 +EXPORT_C TInt TestDll1::Attach(TBool aAttach)
1.96 + {
1.97 + TInt r = KErrNone;
1.98 + TlsData* pD;
1.99 + if (aAttach)
1.100 + {
1.101 + pD = new TlsData;
1.102 + r = Dll::SetTls(pD);
1.103 + __ASSERT_ALWAYS(r==KErrNone, User::Panic(_L("T_DLL1 att"),r));
1.104 + }
1.105 + else
1.106 + {
1.107 + delete &Tls();
1.108 + r = Dll::SetTls(NULL);
1.109 + __ASSERT_ALWAYS(r==KErrNone, User::Panic(_L("T_DLL1 det"),r));
1.110 + }
1.111 + return r;
1.112 + }
1.113 +
1.114 +
1.115 +
1.116 +EXPORT_C TInt TestDll1::GlobalAlloc(TInt )
1.117 + {
1.118 + return KErrNone;
1.119 + }
1.120 +EXPORT_C TBool TestDll1::GlobalAllocated()
1.121 + {
1.122 + return KErrNone;
1.123 + }
1.124 +EXPORT_C TInt TestDll1::GlobalRead(TInt ,TDes8 &)
1.125 + {
1.126 + return KErrNone;
1.127 + }
1.128 +EXPORT_C TInt TestDll1::GlobalWrite(TInt ,const TDesC8 &)
1.129 + {
1.130 + return KErrNone;
1.131 + }
1.132 +