sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\euser\epoc\arm\uc_data.cpp sl@0: // sl@0: // sl@0: sl@0: #include "us_data.h" sl@0: sl@0: #ifdef __USERSIDE_THREAD_DATA__ sl@0: sl@0: TAny* TLocalThreadData::DllTls(TInt aHandle, TInt aDllUid) sl@0: { sl@0: if (!iTlsHeap) sl@0: return NULL; sl@0: STls tls; sl@0: tls.iHandle=aHandle; sl@0: TInt r=iTls.FindInSignedKeyOrder(tls); sl@0: if (r>=0 && iTls[r].iDllUid==aDllUid) sl@0: return iTls[r].iPtr; sl@0: return NULL; sl@0: } sl@0: sl@0: TInt TLocalThreadData::DllSetTls(TInt aHandle, TInt aDllUid, TAny* aPtr) sl@0: { sl@0: if (!iTlsHeap) sl@0: { sl@0: new (&iTls) RArray(KTlsArrayGranularity, _FOFF(STls,iHandle)); sl@0: iHeap->Open(); sl@0: iTlsHeap = iHeap; sl@0: } sl@0: sl@0: STls tls; sl@0: tls.iHandle = aHandle; sl@0: tls.iDllUid = aDllUid; sl@0: tls.iPtr = aPtr; sl@0: TInt i; sl@0: TInt r=iTls.FindInSignedKeyOrder(tls,i); sl@0: if (r==KErrNone) sl@0: iTls[i] = tls; sl@0: else sl@0: { sl@0: RAllocator* currentHeap = iHeap; sl@0: iHeap = iTlsHeap; sl@0: r = iTls.Insert(tls,i); sl@0: iHeap = currentHeap; sl@0: } sl@0: return r; sl@0: } sl@0: sl@0: void TLocalThreadData::DllFreeTls(TInt aHandle) sl@0: { sl@0: if (!iTlsHeap) sl@0: return; sl@0: sl@0: STls tls; sl@0: tls.iHandle=aHandle; sl@0: TInt r=iTls.FindInSignedKeyOrder(tls); sl@0: if (r>=0) sl@0: { sl@0: RAllocator* currentHeap = iHeap; sl@0: iHeap = iTlsHeap; sl@0: iTls.Remove(r); sl@0: iTls.Compress(); sl@0: iHeap = currentHeap; sl@0: } sl@0: } sl@0: sl@0: void TLocalThreadData::Close() sl@0: { sl@0: RAllocator* currentHeap = iHeap; sl@0: RAllocator* tlsHeap = iTlsHeap; sl@0: if (tlsHeap) sl@0: { sl@0: iHeap = tlsHeap; sl@0: iTls.Close(); sl@0: iHeap = currentHeap; sl@0: iTlsHeap = NULL; sl@0: tlsHeap->Close(); sl@0: } sl@0: } sl@0: sl@0: #endif