0
|
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 |
// e32\euser\epoc\up_dll_tls.cpp
|
|
15 |
// This file contains DLL stub functions relating to TLS
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include "up_std.h"
|
|
20 |
#include <e32svr.h>
|
|
21 |
#include "u32std.h"
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
/**
|
|
27 |
Sets the value of the Thread Local Storage (TLS) variable.
|
|
28 |
|
291
|
29 |
Note that the TLS value for a given DLL may be preserved even if the DLL has
|
|
30 |
been unloaded from the current process and loaded again since it was set. The
|
|
31 |
value is not guaranteed to be preserved. The DLL must take steps to ensure that
|
|
32 |
Dll::FreeTls is called for all relevant threads if this must be avoided.
|
|
33 |
|
0
|
34 |
@param aPtr The value to be assigned to the Thread Local Storage variable.
|
|
35 |
In practice, this is almost always a pointer to memory
|
|
36 |
that has previously been allocated, but does not necessarily
|
|
37 |
need to be so.
|
|
38 |
|
|
39 |
@return KErrNone, if successful, otherwise one of the other
|
|
40 |
system-wide error codes.
|
|
41 |
*/
|
|
42 |
TInt Dll::SetTls(TAny* aPtr)
|
|
43 |
{
|
|
44 |
#ifdef __EPOC32__
|
|
45 |
return UserSvr::DllSetTls(MODULE_HANDLE, *(((TInt*)MODULE_HANDLE)+3), aPtr);
|
|
46 |
#else
|
|
47 |
return UserSvr::DllSetTls(MODULE_HANDLE, KDllUid_Special, aPtr);
|
|
48 |
#endif
|
|
49 |
}
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
/**
|
|
55 |
Gets the value of the Thread Local Storage (TLS) variable.
|
|
56 |
|
291
|
57 |
Note that the TLS value for a given DLL may be preserved even if the DLL has
|
|
58 |
been unloaded from the current process and loaded again since it was set. The
|
|
59 |
value is not guaranteed to be preserved. The DLL must take steps to ensure that
|
|
60 |
Dll::FreeTls is called for all relevant threads if this must be avoided.
|
|
61 |
|
0
|
62 |
@return The value of the Thread Local Storage variable as set by
|
|
63 |
a previous call to Dll::SetTls(). If no value has previously
|
|
64 |
been set, then the returned value is NULL.
|
|
65 |
*/
|
|
66 |
TAny* Dll::Tls()
|
|
67 |
{
|
|
68 |
#ifdef __EPOC32__
|
|
69 |
return UserSvr::DllTls(MODULE_HANDLE, *(((TInt*)MODULE_HANDLE)+3));
|
|
70 |
#else
|
|
71 |
return UserSvr::DllTls(MODULE_HANDLE, KDllUid_Special);
|
|
72 |
#endif
|
|
73 |
}
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
/**
|
|
79 |
Removes the Thread Local Storage (TLS) variable.
|
|
80 |
|
|
81 |
A subsequent call to Dll::Tls() will return NULL.
|
|
82 |
*/
|
|
83 |
void Dll::FreeTls()
|
|
84 |
{
|
|
85 |
|
|
86 |
UserSvr::DllFreeTls(MODULE_HANDLE);
|
|
87 |
}
|