Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\euser\epoc\win32\uc_utl.cpp
20 #include <e32base_private.h>
21 #include <e32hashtab.h>
25 typedef void (*TBootEpoc)(TBool);
27 #ifdef __LEAVE_EQUALS_THROW__
29 // Stub versions of TTrap exports to keep X86 and WINS versions of euser.def
35 IMPORT_C TInt Trap(TInt& aResult);
36 IMPORT_C static void UnTrap();
42 EXPORT_C TInt TTrap::Trap(TInt&)
45 TTrapHandler* h = Exec::PushTrapFrame(this);
52 EXPORT_C void TTrap::UnTrap()
57 EXPORT_C TInt TTrap::Trap(TInt&)
62 EXPORT_C void TTrap::UnTrap()
69 EXPORT_C void EmptyFunction()
70 //Function with an empty body
74 GLDEF_C void Panic(TCdtArchitecturePanic aPanic)
76 // Panic the process with USER as the category.
79 _LIT(KCategory,"USER-Arch");
80 User::Panic(KCategory,aPanic);
86 EXPORT_C TInt User::IsRomAddress(TBool& aBool, TAny* aPtr)
88 // The FileServer loads ROM files as ReadOnly Memory Mapped Files
89 // We check the access rights of the given address for :
94 Tests whether the specified address is in the ROM.
96 @param aBool True, if the address at aPtr is within the ROM; false,
98 @param aPtr The address to be tested.
100 @return Always KErrNone.
103 const TInt KRomMask = 0xFF;
104 const TInt KRomAccess = PAGE_READONLY;
107 MEMORY_BASIC_INFORMATION mi;
110 if (VirtualQuery(aPtr, &mi, sizeof(mi)) != 0 && (mi.Protect & KRomMask) == KRomAccess)
118 EXPORT_C void BootEpoc(TBool aAutoRun)
120 HINSTANCE epoc = LoadLibraryA("ekern.exe");
123 TBootEpoc ep = (TBootEpoc)GetProcAddress(epoc, "_E32Startup");
130 EXPORT_C void RFastLock::Wait()
132 if (InterlockedDecrement((LPLONG)&iCount) < -1)
136 EXPORT_C void RFastLock::Signal()
138 if (InterlockedIncrement((LPLONG)&iCount) < 0)
139 RSemaphore::Signal();
142 // Hash an 8 bit string at aPtr, length aLen bytes.
143 __NAKED__ TUint32 DefaultStringHash(const TUint8* /*aPtr*/, TInt /*aLen*/)
146 _asm mov esi, [esp+8]
147 _asm mov ecx, [esp+12]
154 _asm mov edx, 9E3779B9h
173 _asm mov edx, 9E3779B9h
180 // Hash a 16 bit string at aPtr, length aLen bytes.
181 __NAKED__ TUint32 DefaultWStringHash(const TUint16* /*aPtr*/, TInt /*aLen*/)
184 _asm mov esi, [esp+8]
185 _asm mov ecx, [esp+12]
190 _asm mov edx, [esi+4]
195 _asm mov edx, 9E3779B9h
217 _asm mov edx, 9E3779B9h
228 Calculate a 32 bit hash from a 32 bit integer.
230 @param aInt The integer to be hashed.
231 @return The calculated 32 bit hash value.
233 EXPORT_C __NAKED__ TUint32 DefaultHash::Integer(const TInt& /*aInt*/)
235 _asm mov edx, [esp+4]
236 _asm mov eax, 9E3779B9h
237 _asm mul dword ptr [edx]