Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
16 * Part of : Client API for ewsd library
17 * Contains the client API for using the emulator WSD library
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are met:
20 * Redistributions of source code must retain the above copyright notice, this
21 * list of conditions and the following disclaimer.
22 * Redistributions in binary form must reproduce the above copyright notice,
23 * this list of conditions and the following disclaimer in the documentation
24 * and/or other materials provided with the distribution.
25 * Neither the name of the <ORGANIZATION> nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51 _LIT(KVirtualAllocFailure, "WSD VirtualAlloc() failed");
52 _LIT(KPLSInitFailed, "WSD PLS init failed");
53 _LIT(KWsdArrayFull, "WSD process or lib array full");
56 A templated function that is used by a library (DLL) that requires to use
58 The function returns the PLS (Process Local Storage) object of the specified library,
59 for the current process. If the PLS object doesn't yet exist then it is allocated,
60 initialised, stored and returned.
61 The template type T is the type of the PLS object, and is supplied by the caller.
63 Takes as a parameter the TUid of the library DLL whose PLS is to be returned for the
64 current process. It also takes as a parameter a pointer to a (non-leaving, non-panicing)
65 initialisation function defined by the caller which takes a pointer to T (i.e. the
66 PLS object) as a parameter and returns one of the system wide error codes as a TInt.
67 This parameter is optional but it should be used when necessary to ensure that if Pls()
68 requires to create a PLS object then the object is completely initialised on its return.
69 The initialisation function is called after the PLS object has been allocated and its
70 constructor called if it is an instance of a class - neither the constructor nor the
71 initialisation function should call Pls().
73 Returns a pointer to the PLS object
76 T* Pls(const TUid& aLibraryUid, TInt (*aInitFunc)(T*) = 0)
78 // Fetch the PLS, if it has been set
79 T* p = (T*) CheckPls(aLibraryUid);
85 // Obtain ownership of the mutex
86 TAny* mutexHandle = ObtainPlsMutex();
88 // Check we haven't obtained the mutex from
89 // another thread that has just set the same PLS!
90 p = (T*) CheckPls(aLibraryUid);
93 ReleasePlsMutex(mutexHandle);
97 // Allocate the memory for the PLS object
98 p = (T*) AllocatePls(sizeof(T));
101 ReleasePlsMutex(mutexHandle);
102 User::Panic(KVirtualAllocFailure, KErrNoMemory);
105 // Do a placement new to construct the PLS object in the allocated memory
108 // Call the initialisation function (if one is provided)
109 // to complete initialisation of the PLS object
112 if (((*aInitFunc)(p)) != KErrNone)
115 ReleasePlsMutex(mutexHandle);
116 User::Panic(KPLSInitFailed, KErrGeneral);
120 // Finally, call SetPls() to store the PLS object.
121 // NOTE: This step is last to ensure that a PLS object returned by
122 // CheckPls() is completely constructed/initialised. This is important
123 // to handle the scenario in which the thread that is creating the PLS
124 // object is interrupted by another call to Pls() by another thread
125 if (SetPls(p, aLibraryUid) != KErrNone)
127 // SetPls() failed due to a size limit being reached in the wsdArray
129 ReleasePlsMutex(mutexHandle);
130 User::Panic(KWsdArrayFull, KErrNoMemory);
133 ReleasePlsMutex(mutexHandle);