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