2008-09-12 15:09:17 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS Runtime Library
|
|
|
|
* PURPOSE: Slist Routines
|
|
|
|
* FILE: lib/rtl/slist.c
|
|
|
|
* PROGRAMERS: Stefan Ginsberg (stefan__100__@hotmail.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
#include <rtl.h>
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
/* FUNCTIONS ***************************************************************/
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
RtlInitializeSListHead(IN PSLIST_HEADER ListHead)
|
|
|
|
{
|
2008-10-25 07:12:41 +00:00
|
|
|
#ifdef _WIN64
|
[RTL]
Merge from amd64 branch
35738,37004,37308,37324,37330,37331,37332,37370,37419,37424,37425,37428,37473,37492,37844,37911,37987,40604,41006,43686,43951,43953,43980,43993,44001,44289,44295,44296,44428,44966,44967,44968
- Implement amd64 specific RTL functions: RtlLookupFunctionTable, RtlLookupFunctionEntry, RtlCaptureContext, RtlVirtualUnwind, RtlWalkFrameChain, RtlGetCallersAddress, RtlRaiseException (Timo Kreuzer)
- Implement amd64 asm functions: RtlCompareMemory, DebugService, RtlInterlockedPopEntrySList, RtlInterlockedPushEntrySList and RtlInterlockedFlushSList (Timo Kreuzer)
- Don't use double in rtl's sprintf / swprintf, use double_t union instead. (Stefan Ginsberg)
svn path=/trunk/; revision=44970
2010-01-06 00:39:07 +00:00
|
|
|
ListHead->Alignment = 0;
|
|
|
|
ListHead->Region = 0;
|
|
|
|
ListHead->Header8.Init = 1;
|
|
|
|
// ListHead->Header8.HeaderType = 1; // FIXME: depending on cmpxchg16b support?
|
2008-10-25 07:12:41 +00:00
|
|
|
#else
|
|
|
|
ListHead->Alignment = 0;
|
|
|
|
#endif
|
2008-09-12 15:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PSLIST_ENTRY
|
|
|
|
NTAPI
|
|
|
|
RtlFirstEntrySList(IN const SLIST_HEADER *ListHead)
|
|
|
|
{
|
2008-10-25 07:12:41 +00:00
|
|
|
#ifdef _WIN64
|
[RTL]
Merge from amd64 branch
35738,37004,37308,37324,37330,37331,37332,37370,37419,37424,37425,37428,37473,37492,37844,37911,37987,40604,41006,43686,43951,43953,43980,43993,44001,44289,44295,44296,44428,44966,44967,44968
- Implement amd64 specific RTL functions: RtlLookupFunctionTable, RtlLookupFunctionEntry, RtlCaptureContext, RtlVirtualUnwind, RtlWalkFrameChain, RtlGetCallersAddress, RtlRaiseException (Timo Kreuzer)
- Implement amd64 asm functions: RtlCompareMemory, DebugService, RtlInterlockedPopEntrySList, RtlInterlockedPushEntrySList and RtlInterlockedFlushSList (Timo Kreuzer)
- Don't use double in rtl's sprintf / swprintf, use double_t union instead. (Stefan Ginsberg)
svn path=/trunk/; revision=44970
2010-01-06 00:39:07 +00:00
|
|
|
if (ListHead->Header8.HeaderType)
|
|
|
|
{
|
|
|
|
return (PVOID)(ListHead->Region & ~0xF);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
union {
|
|
|
|
PVOID P;
|
|
|
|
struct {
|
|
|
|
ULONG64 Reserved:4;
|
|
|
|
ULONG64 NextEntry:39;
|
|
|
|
ULONG64 Reserved2:21;
|
|
|
|
} Bits;
|
|
|
|
} Pointer;
|
|
|
|
|
|
|
|
Pointer.P = (PVOID)ListHead;
|
|
|
|
Pointer.Bits.NextEntry = ListHead->Header8.NextEntry;
|
|
|
|
return Pointer.P;
|
|
|
|
}
|
2008-10-25 07:12:41 +00:00
|
|
|
#else
|
|
|
|
return ListHead->Next.Next;
|
|
|
|
#endif
|
2008-09-12 15:09:17 +00:00
|
|
|
}
|
|
|
|
|
2012-02-10 17:36:11 +00:00
|
|
|
WORD
|
2008-09-12 15:09:17 +00:00
|
|
|
NTAPI
|
|
|
|
RtlQueryDepthSList(IN PSLIST_HEADER ListHead)
|
|
|
|
{
|
2008-10-25 07:12:41 +00:00
|
|
|
#ifdef _WIN64
|
2012-02-10 17:36:11 +00:00
|
|
|
return ListHead->Header8.HeaderType ?
|
|
|
|
(WORD)ListHead->Header16.Sequence : (WORD)ListHead->Header8.Sequence;
|
2008-10-25 07:12:41 +00:00
|
|
|
#else
|
|
|
|
return ListHead->Depth;
|
|
|
|
#endif
|
2008-09-12 15:09:17 +00:00
|
|
|
}
|