mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[NTOS] Make the GET_HASH_ENTRY() macro return a pointer to the entry instead of the entry itself.
Implicitly it was already returning a pointer, which was then referenced using a "." instead of "->", giving the impression we were working on the returned object instead of the original data. - Convert some macros to inline functions svn path=/trunk/; revision=75580
This commit is contained in:
parent
3c64b4cbe9
commit
7462d87d28
3 changed files with 59 additions and 57 deletions
|
@ -82,7 +82,7 @@ CmpRemoveKeyHash(IN PCM_KEY_HASH KeyHash)
|
|||
ASSERT_VALID_HASH(KeyHash);
|
||||
|
||||
/* Lookup all the keys in this index entry */
|
||||
Prev = &GET_HASH_ENTRY(CmpCacheTable, KeyHash->ConvKey).Entry;
|
||||
Prev = &GET_HASH_ENTRY(CmpCacheTable, KeyHash->ConvKey)->Entry;
|
||||
while (TRUE)
|
||||
{
|
||||
/* Save the current one and make sure it's valid */
|
||||
|
@ -189,7 +189,7 @@ CmpGetNameControlBlock(IN PUNICODE_STRING NodeName)
|
|||
CmpAcquireNcbLockExclusiveByKey(ConvKey);
|
||||
|
||||
/* Get the hash entry */
|
||||
HashEntry = GET_HASH_ENTRY(CmpNameCacheTable, ConvKey).Entry;
|
||||
HashEntry = GET_HASH_ENTRY(CmpNameCacheTable, ConvKey)->Entry;
|
||||
while (HashEntry)
|
||||
{
|
||||
/* Get the current NCB */
|
||||
|
@ -290,8 +290,8 @@ CmpGetNameControlBlock(IN PUNICODE_STRING NodeName)
|
|||
|
||||
/* Insert the name in the hash table */
|
||||
HashEntry = &Ncb->NameHash;
|
||||
HashEntry->NextHash = GET_HASH_ENTRY(CmpNameCacheTable, ConvKey).Entry;
|
||||
GET_HASH_ENTRY(CmpNameCacheTable, ConvKey).Entry = HashEntry;
|
||||
HashEntry->NextHash = GET_HASH_ENTRY(CmpNameCacheTable, ConvKey)->Entry;
|
||||
GET_HASH_ENTRY(CmpNameCacheTable, ConvKey)->Entry = HashEntry;
|
||||
}
|
||||
|
||||
/* Release NCB lock */
|
||||
|
@ -327,7 +327,7 @@ CmpDereferenceNameControlBlockWithLock(IN PCM_NAME_CONTROL_BLOCK Ncb)
|
|||
if (!(--Ncb->RefCount))
|
||||
{
|
||||
/* Find the NCB in the table */
|
||||
Next = &GET_HASH_ENTRY(CmpNameCacheTable, Ncb->ConvKey).Entry;
|
||||
Next = &GET_HASH_ENTRY(CmpNameCacheTable, Ncb->ConvKey)->Entry;
|
||||
while (TRUE)
|
||||
{
|
||||
/* Check the current entry */
|
||||
|
|
|
@ -2081,14 +2081,14 @@ CmpReleaseTwoKcbLockByKey(IN ULONG ConvKey1,
|
|||
/* Get hash indexes */
|
||||
Index1 = GET_HASH_INDEX(ConvKey1);
|
||||
Index2 = GET_HASH_INDEX(ConvKey2);
|
||||
ASSERT((GET_HASH_ENTRY(CmpCacheTable, ConvKey2).Owner == KeGetCurrentThread()) ||
|
||||
ASSERT((GET_HASH_ENTRY(CmpCacheTable, ConvKey2)->Owner == KeGetCurrentThread()) ||
|
||||
(CmpTestRegistryLockExclusive()));
|
||||
|
||||
/* See which one is highest */
|
||||
if (Index1 < Index2)
|
||||
{
|
||||
/* Grab them in the proper order */
|
||||
ASSERT((GET_HASH_ENTRY(CmpCacheTable, ConvKey1).Owner == KeGetCurrentThread()) ||
|
||||
ASSERT((GET_HASH_ENTRY(CmpCacheTable, ConvKey1)->Owner == KeGetCurrentThread()) ||
|
||||
(CmpTestRegistryLockExclusive()));
|
||||
CmpReleaseKcbLockByKey(ConvKey2);
|
||||
CmpReleaseKcbLockByKey(ConvKey1);
|
||||
|
@ -2098,7 +2098,7 @@ CmpReleaseTwoKcbLockByKey(IN ULONG ConvKey1,
|
|||
/* Release the first one first, then the second */
|
||||
if (Index1 != Index2)
|
||||
{
|
||||
ASSERT((GET_HASH_ENTRY(CmpCacheTable, ConvKey1).Owner == KeGetCurrentThread()) ||
|
||||
ASSERT((GET_HASH_ENTRY(CmpCacheTable, ConvKey1)->Owner == KeGetCurrentThread()) ||
|
||||
(CmpTestRegistryLockExclusive()));
|
||||
CmpReleaseKcbLockByKey(ConvKey1);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#define GET_HASH_INDEX(ConvKey) \
|
||||
GET_HASH_KEY(ConvKey) % CmpHashTableSize
|
||||
#define GET_HASH_ENTRY(Table, ConvKey) \
|
||||
(Table[GET_HASH_INDEX(ConvKey)])
|
||||
(&Table[GET_HASH_INDEX(ConvKey)])
|
||||
#define ASSERT_VALID_HASH(h) \
|
||||
ASSERT_KCB_VALID(CONTAINING_RECORD((h), CM_KEY_CONTROL_BLOCK, KeyHash))
|
||||
|
||||
|
@ -81,37 +81,37 @@
|
|||
//
|
||||
#define CmpIsKcbLockedExclusive(k) \
|
||||
(GET_HASH_ENTRY(CmpCacheTable, \
|
||||
(k)->ConvKey).Owner == KeGetCurrentThread())
|
||||
|
||||
//
|
||||
// Exclusively acquires a KCB
|
||||
//
|
||||
#define CmpAcquireKcbLockExclusive(k) \
|
||||
{ \
|
||||
ExAcquirePushLockExclusive(&GET_HASH_ENTRY(CmpCacheTable, \
|
||||
(k)->ConvKey).Lock); \
|
||||
GET_HASH_ENTRY(CmpCacheTable, \
|
||||
(k)->ConvKey).Owner = KeGetCurrentThread(); \
|
||||
}
|
||||
(k)->ConvKey)->Owner == KeGetCurrentThread())
|
||||
|
||||
//
|
||||
// Exclusively acquires a KCB by index
|
||||
//
|
||||
#define CmpAcquireKcbLockExclusiveByIndex(i) \
|
||||
{ \
|
||||
ExAcquirePushLockExclusive(&CmpCacheTable[(i)].Lock); \
|
||||
CmpCacheTable[(i)].Owner = KeGetCurrentThread(); \
|
||||
FORCEINLINE
|
||||
VOID
|
||||
CmpAcquireKcbLockExclusiveByIndex(ULONG Index)
|
||||
{
|
||||
ExAcquirePushLockExclusive(&CmpCacheTable[Index].Lock);
|
||||
CmpCacheTable[Index].Owner = KeGetCurrentThread();
|
||||
}
|
||||
|
||||
//
|
||||
// Exclusively acquires a KCB
|
||||
//
|
||||
FORCEINLINE
|
||||
VOID
|
||||
CmpAcquireKcbLockExclusive(PCM_KEY_CONTROL_BLOCK Kcb)
|
||||
{
|
||||
CmpAcquireKcbLockExclusiveByIndex(GET_HASH_INDEX(Kcb->ConvKey));
|
||||
}
|
||||
|
||||
//
|
||||
// Exclusively acquires a KCB by key
|
||||
//
|
||||
#define CmpAcquireKcbLockExclusiveByKey(k) \
|
||||
{ \
|
||||
ExAcquirePushLockExclusive(&GET_HASH_ENTRY(CmpCacheTable, \
|
||||
(k)).Lock); \
|
||||
GET_HASH_ENTRY(CmpCacheTable, \
|
||||
(k)).Owner = KeGetCurrentThread(); \
|
||||
FORCEINLINE
|
||||
VOID
|
||||
CmpAcquireKcbLockExclusiveByKey(IN ULONG ConvKey)
|
||||
{
|
||||
CmpAcquireKcbLockExclusiveByIndex(GET_HASH_INDEX(ConvKey));
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,7 +121,7 @@
|
|||
#define CmpAcquireKcbLockShared(k) \
|
||||
{ \
|
||||
ExAcquirePushLockShared(&GET_HASH_ENTRY(CmpCacheTable, \
|
||||
(k)->ConvKey).Lock); \
|
||||
(k)->ConvKey)->Lock); \
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -141,42 +141,44 @@ CmpTryToConvertKcbSharedToExclusive(IN PCM_KEY_CONTROL_BLOCK k)
|
|||
{
|
||||
ASSERT(CmpIsKcbLockedExclusive(k) == FALSE);
|
||||
if (ExConvertPushLockSharedToExclusive(
|
||||
&GET_HASH_ENTRY(CmpCacheTable, k->ConvKey).Lock))
|
||||
&GET_HASH_ENTRY(CmpCacheTable, k->ConvKey)->Lock))
|
||||
{
|
||||
GET_HASH_ENTRY(CmpCacheTable,
|
||||
k->ConvKey).Owner = KeGetCurrentThread();
|
||||
k->ConvKey)->Owner = KeGetCurrentThread();
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Releases an exlusively or shared acquired KCB
|
||||
// Releases an exlusively or shared acquired KCB by index
|
||||
//
|
||||
#define CmpReleaseKcbLock(k) \
|
||||
{ \
|
||||
GET_HASH_ENTRY(CmpCacheTable, (k)->ConvKey).Owner = NULL; \
|
||||
ExReleasePushLock(&GET_HASH_ENTRY(CmpCacheTable, \
|
||||
(k)->ConvKey).Lock); \
|
||||
FORCEINLINE
|
||||
VOID
|
||||
CmpReleaseKcbLockByIndex(ULONG Index)
|
||||
{
|
||||
CmpCacheTable[Index].Owner = NULL;
|
||||
ExReleasePushLock(&CmpCacheTable[Index].Lock);
|
||||
}
|
||||
|
||||
//
|
||||
// Releases an exlusively or shared acquired KCB by index
|
||||
// Releases an exlusively or shared acquired KCB
|
||||
//
|
||||
#define CmpReleaseKcbLockByIndex(i) \
|
||||
{ \
|
||||
CmpCacheTable[(i)].Owner = NULL; \
|
||||
ExReleasePushLock(&CmpCacheTable[(i)].Lock); \
|
||||
FORCEINLINE
|
||||
VOID
|
||||
CmpReleaseKcbLock(PCM_KEY_CONTROL_BLOCK Kcb)
|
||||
{
|
||||
CmpReleaseKcbLockByIndex(GET_HASH_INDEX(Kcb->ConvKey));
|
||||
}
|
||||
|
||||
//
|
||||
// Releases an exlusively or shared acquired KCB by key
|
||||
//
|
||||
#define CmpReleaseKcbLockByKey(k) \
|
||||
{ \
|
||||
GET_HASH_ENTRY(CmpCacheTable, (k)).Owner = NULL; \
|
||||
ExReleasePushLock(&GET_HASH_ENTRY(CmpCacheTable, \
|
||||
(k)).Lock); \
|
||||
FORCEINLINE
|
||||
VOID
|
||||
CmpReleaseKcbLockByKey(ULONG ConvKey)
|
||||
{
|
||||
CmpReleaseKcbLockByIndex(GET_HASH_INDEX(ConvKey));
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -186,7 +188,7 @@ FORCEINLINE
|
|||
VOID
|
||||
CmpConvertKcbSharedToExclusive(IN PCM_KEY_CONTROL_BLOCK k)
|
||||
{
|
||||
ASSERT(CmpIsKcbLockedExclusive(k) == FALSE);
|
||||
ASSERT(CmpIsKcbLockedExclusive(k) == FALSE);
|
||||
CmpReleaseKcbLock(k);
|
||||
CmpAcquireKcbLockExclusive(k);
|
||||
}
|
||||
|
@ -197,7 +199,7 @@ CmpConvertKcbSharedToExclusive(IN PCM_KEY_CONTROL_BLOCK k)
|
|||
#define CmpAcquireNcbLockExclusive(n) \
|
||||
{ \
|
||||
ExAcquirePushLockExclusive(&GET_HASH_ENTRY(CmpNameCacheTable, \
|
||||
(n)->ConvKey).Lock); \
|
||||
(n)->ConvKey)->Lock); \
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -206,7 +208,7 @@ CmpConvertKcbSharedToExclusive(IN PCM_KEY_CONTROL_BLOCK k)
|
|||
#define CmpAcquireNcbLockExclusiveByKey(k) \
|
||||
{ \
|
||||
ExAcquirePushLockExclusive(&GET_HASH_ENTRY(CmpNameCacheTable, \
|
||||
(k)).Lock); \
|
||||
(k))->Lock); \
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -215,7 +217,7 @@ CmpConvertKcbSharedToExclusive(IN PCM_KEY_CONTROL_BLOCK k)
|
|||
#define CmpReleaseNcbLock(k) \
|
||||
{ \
|
||||
ExReleasePushLock(&GET_HASH_ENTRY(CmpNameCacheTable, \
|
||||
(k)->ConvKey).Lock); \
|
||||
(k)->ConvKey)->Lock); \
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -224,15 +226,15 @@ CmpConvertKcbSharedToExclusive(IN PCM_KEY_CONTROL_BLOCK k)
|
|||
#define CmpReleaseNcbLockByKey(k) \
|
||||
{ \
|
||||
ExReleasePushLock(&GET_HASH_ENTRY(CmpNameCacheTable, \
|
||||
(k)).Lock); \
|
||||
(k))->Lock); \
|
||||
}
|
||||
|
||||
//
|
||||
// Asserts that either the registry or the hash entry is locked
|
||||
// Asserts that either the registry or the KCB is locked
|
||||
//
|
||||
#define CMP_ASSERT_HASH_ENTRY_LOCK(k) \
|
||||
{ \
|
||||
ASSERT(((GET_HASH_ENTRY(CmpCacheTable, k).Owner == \
|
||||
ASSERT(((GET_HASH_ENTRY(CmpCacheTable, k)->Owner == \
|
||||
KeGetCurrentThread())) || \
|
||||
(CmpTestRegistryLockExclusive() == TRUE)); \
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue