mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
- Make InitializeListHead, InsertHeadList, InsertTailList and
RemoveEntryList an inline functions instead of macros to match DDK. It's important because using macros can lead to variable name conflicts. - Make PopEntryList, PushEntryList a macro instead of inline function (to match DDK). - RemoveEntryList, RemoveHeadList and RemoveTailList shouldn't zero Blink and Flink of the removed entry. The MS documentation is wrong and there has been already submitted an official bug report for that. svn path=/trunk/; revision=11478
This commit is contained in:
parent
f9f887791c
commit
0ca74773d6
6 changed files with 142 additions and 252 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: rtl.h,v 1.37 2004/10/24 20:37:25 weiden Exp $
|
||||
/* $Id: rtl.h,v 1.38 2004/10/30 14:02:01 navaraf Exp $
|
||||
*
|
||||
*/
|
||||
#ifndef __DDK_RTL_H
|
||||
|
@ -88,10 +88,11 @@
|
|||
* ARGUMENTS:
|
||||
* ListHead = Caller supplied storage for the head of the list
|
||||
*/
|
||||
#define InitializeListHead(ListHead) \
|
||||
{ \
|
||||
(ListHead)->Flink = (ListHead); \
|
||||
(ListHead)->Blink = (ListHead); \
|
||||
static __inline VOID
|
||||
InitializeListHead(
|
||||
IN PLIST_ENTRY ListHead)
|
||||
{
|
||||
ListHead->Flink = ListHead->Blink = ListHead;
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,19 +108,17 @@
|
|||
* ListHead = Head of the list
|
||||
* Entry = Entry to insert
|
||||
*/
|
||||
#define InsertHeadList(ListHead, ListEntry) \
|
||||
{ \
|
||||
PLIST_ENTRY OldFlink; \
|
||||
OldFlink = (ListHead)->Flink; \
|
||||
(ListEntry)->Flink = OldFlink; \
|
||||
(ListEntry)->Blink = (ListHead); \
|
||||
OldFlink->Blink = (ListEntry); \
|
||||
(ListHead)->Flink = (ListEntry); \
|
||||
ASSERT((ListEntry) != NULL); \
|
||||
ASSERT((ListEntry)->Blink!=NULL); \
|
||||
ASSERT((ListEntry)->Blink->Flink == (ListEntry)); \
|
||||
ASSERT((ListEntry)->Flink != NULL); \
|
||||
ASSERT((ListEntry)->Flink->Blink == (ListEntry)); \
|
||||
static __inline VOID
|
||||
InsertHeadList(
|
||||
IN PLIST_ENTRY ListHead,
|
||||
IN PLIST_ENTRY Entry)
|
||||
{
|
||||
PLIST_ENTRY OldFlink;
|
||||
OldFlink = ListHead->Flink;
|
||||
Entry->Flink = OldFlink;
|
||||
Entry->Blink = ListHead;
|
||||
OldFlink->Blink = Entry;
|
||||
ListHead->Flink = Entry;
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,14 +136,17 @@
|
|||
* ListHead = Head of the list
|
||||
* Entry = Entry to insert
|
||||
*/
|
||||
#define InsertTailList(ListHead, ListEntry) \
|
||||
{ \
|
||||
PLIST_ENTRY OldBlink; \
|
||||
OldBlink = (ListHead)->Blink; \
|
||||
(ListEntry)->Flink = (ListHead); \
|
||||
(ListEntry)->Blink = OldBlink; \
|
||||
OldBlink->Flink = (ListEntry); \
|
||||
(ListHead)->Blink = (ListEntry); \
|
||||
static __inline VOID
|
||||
InsertTailList(
|
||||
IN PLIST_ENTRY ListHead,
|
||||
IN PLIST_ENTRY Entry)
|
||||
{
|
||||
PLIST_ENTRY OldBlink;
|
||||
OldBlink = ListHead->Blink;
|
||||
Entry->Flink = ListHead;
|
||||
Entry->Blink = OldBlink;
|
||||
OldBlink->Flink = Entry;
|
||||
ListHead->Blink = Entry;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -178,49 +180,24 @@
|
|||
* RETURNS:
|
||||
* The removed entry
|
||||
*/
|
||||
/*
|
||||
#define PopEntryList(ListHead) \
|
||||
(ListHead)->Next; \
|
||||
{ \
|
||||
PSINGLE_LIST_ENTRY FirstEntry; \
|
||||
FirstEntry = (ListHead)->Next; \
|
||||
if (FirstEntry != NULL) \
|
||||
{ \
|
||||
(ListHead)->Next = FirstEntry->Next; \
|
||||
} \
|
||||
PSINGLE_LIST_ENTRY _FirstEntry; \
|
||||
_FirstEntry = (ListHead)->Next; \
|
||||
if (_FirstEntry != NULL) \
|
||||
(ListHead)->Next = _FirstEntry->Next; \
|
||||
}
|
||||
*/
|
||||
static inline PSINGLE_LIST_ENTRY
|
||||
PopEntryList(PSINGLE_LIST_ENTRY ListHead)
|
||||
{
|
||||
PSINGLE_LIST_ENTRY ListEntry;
|
||||
|
||||
ListEntry = ListHead->Next;
|
||||
if (ListEntry!=NULL)
|
||||
{
|
||||
ListHead->Next = ListEntry->Next;
|
||||
}
|
||||
|
||||
return(ListEntry);
|
||||
}
|
||||
|
||||
#define RtlCopyMemory(Destination,Source,Length) \
|
||||
memcpy((Destination),(Source),(Length))
|
||||
|
||||
static
|
||||
inline
|
||||
VOID
|
||||
PushEntryList (
|
||||
PSINGLE_LIST_ENTRY ListHead,
|
||||
PSINGLE_LIST_ENTRY Entry
|
||||
)
|
||||
{
|
||||
Entry->Next = ListHead->Next;
|
||||
ListHead->Next = Entry;
|
||||
}
|
||||
#define PushEntryList(_ListHead, _Entry) \
|
||||
(_Entry)->Next = (_ListHead)->Next; \
|
||||
(_ListHead)->Next = (_Entry); \
|
||||
|
||||
/*
|
||||
*VOID
|
||||
*BOOLEAN
|
||||
*RemoveEntryList (
|
||||
* PLIST_ENTRY Entry
|
||||
* );
|
||||
|
@ -231,21 +208,18 @@ PushEntryList (
|
|||
* ARGUMENTS:
|
||||
* ListEntry = Entry to remove
|
||||
*/
|
||||
#define RemoveEntryList(ListEntry) \
|
||||
{ \
|
||||
PLIST_ENTRY OldFlink; \
|
||||
PLIST_ENTRY OldBlink; \
|
||||
ASSERT((ListEntry) != NULL); \
|
||||
ASSERT((ListEntry)->Blink!=NULL); \
|
||||
ASSERT((ListEntry)->Blink->Flink == (ListEntry)); \
|
||||
ASSERT((ListEntry)->Flink != NULL); \
|
||||
ASSERT((ListEntry)->Flink->Blink == (ListEntry)); \
|
||||
OldFlink = (ListEntry)->Flink; \
|
||||
OldBlink = (ListEntry)->Blink; \
|
||||
OldFlink->Blink = OldBlink; \
|
||||
OldBlink->Flink = OldFlink; \
|
||||
(ListEntry)->Flink = NULL; \
|
||||
(ListEntry)->Blink = NULL; \
|
||||
static __inline BOOLEAN
|
||||
RemoveEntryList(
|
||||
IN PLIST_ENTRY Entry)
|
||||
{
|
||||
PLIST_ENTRY OldFlink;
|
||||
PLIST_ENTRY OldBlink;
|
||||
|
||||
OldFlink = Entry->Flink;
|
||||
OldBlink = Entry->Blink;
|
||||
OldFlink->Blink = OldBlink;
|
||||
OldBlink->Flink = OldFlink;
|
||||
return (OldFlink == OldBlink);
|
||||
}
|
||||
|
||||
|
||||
|
@ -264,42 +238,18 @@ PushEntryList (
|
|||
* RETURNS:
|
||||
* The removed entry
|
||||
*/
|
||||
/*
|
||||
#define RemoveHeadList(ListHead) \
|
||||
(ListHead)->Flink; \
|
||||
{RemoveEntryList((ListHead)->Flink)}
|
||||
*/
|
||||
/*
|
||||
PLIST_ENTRY
|
||||
RemoveHeadList (
|
||||
PLIST_ENTRY ListHead
|
||||
);
|
||||
*/
|
||||
|
||||
static
|
||||
inline
|
||||
PLIST_ENTRY
|
||||
RemoveHeadList (
|
||||
PLIST_ENTRY ListHead
|
||||
)
|
||||
static __inline PLIST_ENTRY
|
||||
RemoveHeadList(
|
||||
IN PLIST_ENTRY ListHead)
|
||||
{
|
||||
PLIST_ENTRY Old;
|
||||
PLIST_ENTRY OldFlink;
|
||||
PLIST_ENTRY OldBlink;
|
||||
PLIST_ENTRY Flink;
|
||||
PLIST_ENTRY Entry;
|
||||
|
||||
Old = ListHead->Flink;
|
||||
|
||||
OldFlink = ListHead->Flink->Flink;
|
||||
OldBlink = ListHead->Flink->Blink;
|
||||
OldFlink->Blink = OldBlink;
|
||||
OldBlink->Flink = OldFlink;
|
||||
if (Old != ListHead)
|
||||
{
|
||||
Old->Flink = NULL;
|
||||
Old->Blink = NULL;
|
||||
}
|
||||
|
||||
return(Old);
|
||||
Entry = ListHead->Flink;
|
||||
Flink = Entry->Flink;
|
||||
ListHead->Flink = Flink;
|
||||
Flink->Blink = ListHead;
|
||||
return Entry;
|
||||
}
|
||||
|
||||
|
||||
|
@ -318,42 +268,18 @@ RemoveHeadList (
|
|||
* RETURNS:
|
||||
* The removed entry
|
||||
*/
|
||||
/*
|
||||
#define RemoveTailList(ListHead) \
|
||||
(ListHead)->Blink; \
|
||||
{RemoveEntryList((ListHead)->Blink)}
|
||||
*/
|
||||
/*
|
||||
PLIST_ENTRY
|
||||
RemoveTailList (
|
||||
PLIST_ENTRY ListHead
|
||||
);
|
||||
*/
|
||||
|
||||
static
|
||||
inline
|
||||
PLIST_ENTRY
|
||||
RemoveTailList (
|
||||
PLIST_ENTRY ListHead
|
||||
)
|
||||
static __inline PLIST_ENTRY
|
||||
RemoveTailList(
|
||||
IN PLIST_ENTRY ListHead)
|
||||
{
|
||||
PLIST_ENTRY Old;
|
||||
PLIST_ENTRY OldFlink;
|
||||
PLIST_ENTRY OldBlink;
|
||||
PLIST_ENTRY Blink;
|
||||
PLIST_ENTRY Entry;
|
||||
|
||||
Old = ListHead->Blink;
|
||||
|
||||
OldFlink = ListHead->Blink->Flink;
|
||||
OldBlink = ListHead->Blink->Blink;
|
||||
OldFlink->Blink = OldBlink;
|
||||
OldBlink->Flink = OldFlink;
|
||||
if (Old != ListHead)
|
||||
{
|
||||
Old->Flink = NULL;
|
||||
Old->Blink = NULL;
|
||||
}
|
||||
|
||||
return(Old);
|
||||
Entry = ListHead->Blink;
|
||||
Blink = Entry->Blink;
|
||||
ListHead->Blink = Blink;
|
||||
Blink->Flink = ListHead;
|
||||
return Entry;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: utils.c,v 1.99 2004/07/14 02:40:45 navaraf Exp $
|
||||
/* $Id: utils.c,v 1.100 2004/10/30 14:02:03 navaraf Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -2415,7 +2415,7 @@ LdrpDetachProcess(BOOL UnloadAll)
|
|||
((UnloadAll && Module->LoadCount >= 0) || Module->LoadCount == 0))
|
||||
{
|
||||
/* remove the module entry from the list */
|
||||
RemoveEntryList (&Module->InLoadOrderModuleList)
|
||||
RemoveEntryList (&Module->InLoadOrderModuleList);
|
||||
RemoveEntryList (&Module->InInitializationOrderModuleList);
|
||||
|
||||
NtUnmapViewOfSection (NtCurrentProcess (), Module->BaseAddress);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: atom.c,v 1.6 2004/05/13 20:48:31 navaraf Exp $
|
||||
/* $Id: atom.c,v 1.7 2004/10/30 14:02:04 navaraf Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -285,7 +285,7 @@ RtlAddAtomToAtomTable(IN PRTL_ATOM_TABLE AtomTable,
|
|||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
InsertTailList(&AtomTable->Slot[Hash], &Entry->List)
|
||||
InsertTailList(&AtomTable->Slot[Hash], &Entry->List);
|
||||
RtlCreateUnicodeString (&Entry->Name,
|
||||
AtomName);
|
||||
Entry->RefCount = 1;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: callback.c,v 1.12 2004/08/15 16:39:01 chorns Exp $
|
||||
/* $Id: callback.c,v 1.13 2004/10/30 14:02:04 navaraf Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ex/callback.c
|
||||
|
@ -391,7 +391,7 @@ ExRegisterCallback(
|
|||
/* Add Callback if 1) No Callbacks registered or 2) Multiple Callbacks allowed */
|
||||
if(CallbackObject->AllowMultipleCallbacks || IsListEmpty(&CallbackObject->RegisteredCallbacks))
|
||||
{
|
||||
InsertTailList(&CallbackObject->RegisteredCallbacks,&CallbackRegistration->RegisteredCallbacks)
|
||||
InsertTailList(&CallbackObject->RegisteredCallbacks,&CallbackRegistration->RegisteredCallbacks);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: atom.c,v 1.11 2004/08/15 16:39:11 chorns Exp $
|
||||
/* $Id: atom.c,v 1.12 2004/10/30 14:02:04 navaraf Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -377,7 +377,7 @@ RtlAddAtomToAtomTable(IN PRTL_ATOM_TABLE AtomTable,
|
|||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
InsertTailList(&AtomTable->Slot[Hash], &Entry->List)
|
||||
InsertTailList(&AtomTable->Slot[Hash], &Entry->List);
|
||||
RtlCreateUnicodeString (&Entry->Name,
|
||||
AtomName);
|
||||
Entry->RefCount = 1;
|
||||
|
|
|
@ -4161,49 +4161,37 @@ RtlAssert(
|
|||
|
||||
/** Runtime library routines **/
|
||||
|
||||
/*
|
||||
* VOID
|
||||
* InitializeListHead(
|
||||
* IN PLIST_ENTRY ListHead)
|
||||
*/
|
||||
#define InitializeListHead(_ListHead) \
|
||||
{ \
|
||||
(_ListHead)->Flink = (_ListHead); \
|
||||
(_ListHead)->Blink = (_ListHead); \
|
||||
static __inline VOID
|
||||
InitializeListHead(
|
||||
IN PLIST_ENTRY ListHead)
|
||||
{
|
||||
ListHead->Flink = ListHead->Blink = ListHead;
|
||||
}
|
||||
|
||||
/*
|
||||
* VOID
|
||||
* InsertHeadList(
|
||||
* IN PLIST_ENTRY ListHead,
|
||||
* IN PLIST_ENTRY Entry)
|
||||
*/
|
||||
#define InsertHeadList(_ListHead, \
|
||||
_Entry) \
|
||||
{ \
|
||||
PLIST_ENTRY _OldFlink; \
|
||||
_OldFlink = (_ListHead)->Flink; \
|
||||
(_Entry)->Flink = _OldFlink; \
|
||||
(_Entry)->Blink = (_ListHead); \
|
||||
_OldFlink->Blink = (_Entry); \
|
||||
(_ListHead)->Flink = (_Entry); \
|
||||
static __inline VOID
|
||||
InsertHeadList(
|
||||
IN PLIST_ENTRY ListHead,
|
||||
IN PLIST_ENTRY Entry)
|
||||
{
|
||||
PLIST_ENTRY OldFlink;
|
||||
OldFlink = ListHead->Flink;
|
||||
Entry->Flink = OldFlink;
|
||||
Entry->Blink = ListHead;
|
||||
OldFlink->Blink = Entry;
|
||||
ListHead->Flink = Entry;
|
||||
}
|
||||
|
||||
/*
|
||||
* VOID
|
||||
* InsertTailList(
|
||||
* IN PLIST_ENTRY ListHead,
|
||||
* IN PLIST_ENTRY Entry)
|
||||
*/
|
||||
#define InsertTailList(_ListHead, \
|
||||
_Entry) \
|
||||
{ \
|
||||
PLIST_ENTRY _OldBlink; \
|
||||
_OldBlink = (_ListHead)->Blink; \
|
||||
(_Entry)->Flink = (_ListHead); \
|
||||
(_Entry)->Blink = _OldBlink; \
|
||||
_OldBlink->Flink = (_Entry); \
|
||||
(_ListHead)->Blink = (_Entry); \
|
||||
static __inline VOID
|
||||
InsertTailList(
|
||||
IN PLIST_ENTRY ListHead,
|
||||
IN PLIST_ENTRY Entry)
|
||||
{
|
||||
PLIST_ENTRY OldBlink;
|
||||
OldBlink = ListHead->Blink;
|
||||
Entry->Flink = ListHead;
|
||||
Entry->Blink = OldBlink;
|
||||
OldBlink->Flink = Entry;
|
||||
ListHead->Blink = Entry;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4214,19 +4202,19 @@ RtlAssert(
|
|||
#define IsListEmpty(_ListHead) \
|
||||
((_ListHead)->Flink == (_ListHead))
|
||||
|
||||
static __inline PSINGLE_LIST_ENTRY
|
||||
PopEntryList(
|
||||
IN PSINGLE_LIST_ENTRY ListHead)
|
||||
{
|
||||
PSINGLE_LIST_ENTRY Entry;
|
||||
|
||||
Entry = ListHead->Next;
|
||||
if (Entry != NULL)
|
||||
{
|
||||
ListHead->Next = Entry->Next;
|
||||
}
|
||||
return Entry;
|
||||
}
|
||||
/*
|
||||
* PSINGLE_LIST_ENTRY
|
||||
* PopEntryList(
|
||||
* IN PSINGLE_LIST_ENTRY ListHead)
|
||||
*/
|
||||
#define PopEntryList(ListHead) \
|
||||
(ListHead)->Next; \
|
||||
{ \
|
||||
PSINGLE_LIST_ENTRY _FirstEntry; \
|
||||
_FirstEntry = (ListHead)->Next; \
|
||||
if (_FirstEntry != NULL) \
|
||||
(ListHead)->Next = _FirstEntry->Next; \
|
||||
}
|
||||
|
||||
/*
|
||||
* VOID
|
||||
|
@ -4234,73 +4222,49 @@ PopEntryList(
|
|||
* IN PSINGLE_LIST_ENTRY ListHead,
|
||||
* IN PSINGLE_LIST_ENTRY Entry)
|
||||
*/
|
||||
#define PushEntryList(_ListHead, \
|
||||
_Entry) \
|
||||
{ \
|
||||
#define PushEntryList(_ListHead, _Entry) \
|
||||
(_Entry)->Next = (_ListHead)->Next; \
|
||||
(_ListHead)->Next = (_Entry); \
|
||||
}
|
||||
|
||||
/*
|
||||
* VOID
|
||||
* RemoveEntryList(
|
||||
* IN PLIST_ENTRY Entry)
|
||||
*/
|
||||
#define RemoveEntryList(_Entry) \
|
||||
{ \
|
||||
PLIST_ENTRY _OldFlink; \
|
||||
PLIST_ENTRY _OldBlink; \
|
||||
_OldFlink = (_Entry)->Flink; \
|
||||
_OldBlink = (_Entry)->Blink; \
|
||||
_OldFlink->Blink = _OldBlink; \
|
||||
_OldBlink->Flink = _OldFlink; \
|
||||
(_Entry)->Flink = NULL; \
|
||||
(_Entry)->Blink = NULL; \
|
||||
static __inline BOOLEAN
|
||||
RemoveEntryList(
|
||||
IN PLIST_ENTRY Entry)
|
||||
{
|
||||
PLIST_ENTRY OldFlink;
|
||||
PLIST_ENTRY OldBlink;
|
||||
|
||||
OldFlink = Entry->Flink;
|
||||
OldBlink = Entry->Blink;
|
||||
OldFlink->Blink = OldBlink;
|
||||
OldBlink->Flink = OldFlink;
|
||||
return (OldFlink == OldBlink);
|
||||
}
|
||||
|
||||
static __inline PLIST_ENTRY
|
||||
RemoveHeadList(
|
||||
IN PLIST_ENTRY ListHead)
|
||||
{
|
||||
PLIST_ENTRY OldFlink;
|
||||
PLIST_ENTRY OldBlink;
|
||||
PLIST_ENTRY Entry;
|
||||
PLIST_ENTRY Flink;
|
||||
PLIST_ENTRY Entry;
|
||||
|
||||
Entry = ListHead->Flink;
|
||||
OldFlink = ListHead->Flink->Flink;
|
||||
OldBlink = ListHead->Flink->Blink;
|
||||
OldFlink->Blink = OldBlink;
|
||||
OldBlink->Flink = OldFlink;
|
||||
|
||||
if (Entry != ListHead)
|
||||
{
|
||||
Entry->Flink = NULL;
|
||||
Entry->Blink = NULL;
|
||||
}
|
||||
|
||||
return Entry;
|
||||
Entry = ListHead->Flink;
|
||||
Flink = Entry->Flink;
|
||||
ListHead->Flink = Flink;
|
||||
Flink->Blink = ListHead;
|
||||
return Entry;
|
||||
}
|
||||
|
||||
static __inline PLIST_ENTRY
|
||||
RemoveTailList(
|
||||
IN PLIST_ENTRY ListHead)
|
||||
{
|
||||
PLIST_ENTRY OldFlink;
|
||||
PLIST_ENTRY OldBlink;
|
||||
PLIST_ENTRY Entry;
|
||||
PLIST_ENTRY Blink;
|
||||
PLIST_ENTRY Entry;
|
||||
|
||||
Entry = ListHead->Blink;
|
||||
OldFlink = ListHead->Blink->Flink;
|
||||
OldBlink = ListHead->Blink->Blink;
|
||||
OldFlink->Blink = OldBlink;
|
||||
OldBlink->Flink = OldFlink;
|
||||
|
||||
if (Entry != ListHead)
|
||||
{
|
||||
Entry->Flink = NULL;
|
||||
Entry->Blink = NULL;
|
||||
}
|
||||
|
||||
Entry = ListHead->Blink;
|
||||
Blink = Entry->Blink;
|
||||
ListHead->Blink = Blink;
|
||||
Blink->Flink = ListHead;
|
||||
return Entry;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue