CVS: winex/dlls/ntdll Makefile.in, 1.6, 1.7 ntdll.spec, 1.47, 1.48 slist.c, NONE, 1.1

[email protected]
Newsgroups gmane.comp.emulators.winex.cvs
Message-ID <[email protected]>
Subject: winex/dlls/ntdll Makefile.in,1.6,1.7 ntdll.spec,1.47,1.48 slist.c,NONE,1.1Update of /var/lib/cvsd/cvsroot/winex/dlls/ntdll
In directory agravaine:/tmp/cvs-serv20216/dlls/ntdll

Modified Files:
	Makefile.in ntdll.spec 
Added Files:
	slist.c 
Log Message:

- integrate SList implementation contributed by Tim Beckmann



Index: Makefile.in
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/ntdll/Makefile.in,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Makefile.in	30 Mar 2007 18:17:21 -0000	1.6
+++ Makefile.in	30 Mar 2007 20:41:27 -0000	1.7
@@ -30,6 +30,7 @@
 	sec.c \
 	signal_i386.c \
 	signal_sparc.c \
+	slist.c \
 	sync.c \
 	time.c \
 	wcstring.c

Index: ntdll.spec
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/ntdll/ntdll.spec,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- ntdll.spec	30 Mar 2007 19:01:48 -0000	1.47
+++ ntdll.spec	30 Mar 2007 20:41:27 -0000	1.48
@@ -440,9 +440,13 @@
 @ stub RtlInitializeRXact
 @ stdcall RtlInitializeResource(ptr) RtlInitializeResource
 @ stdcall RtlInitializeSid(ptr ptr long) RtlInitializeSid
+@ stdcall RtlInitializeSListHead(ptr)
 @ stub RtlInsertElementGenericTable
 @ stdcall RtlIntegerToChar(long long long long) RtlIntegerToChar
 @ stub RtlIntegerToUnicodeString
+@ stdcall RtlInterlockedFlushSList(ptr)
+@ stdcall RtlInterlockedPopEntrySList(ptr)
+@ stdcall RtlInterlockedPushEntrySList(ptr ptr)
 @ stub RtlIsDosDeviceName_U
 @ stub RtlIsGenericTableEmpty
 @ stub RtlIsNameLegalDOS8Dot3
@@ -483,6 +487,7 @@
 @ stdcall RtlPrefixString(ptr ptr long) RtlPrefixString
 @ stdcall RtlPrefixUnicodeString(ptr ptr long) RtlPrefixUnicodeString
 @ stub RtlProtectHeap
+@ stdcall RtlQueryDepthSList(ptr)
 @ stdcall RtlQueryEnvironmentVariable_U(long long long) RtlQueryEnvironmentVariable_U
 @ stub RtlQueryInformationAcl
 @ stub RtlQueryProcessBackTraceInformation

--- NEW FILE: slist.c ---
/*
 * SList implementaiton
 *
 * Copyright 2007 Tim Beckmann
 */

#include "config.h"

#include <string.h>
#include <stdio.h>

#include "winbase.h"
#include "wine/debug.h"

WINE_DEFAULT_DEBUG_CHANNEL(ntdll);


/***********************************************************************
 *           RtlInitializeSListHead    (NTDLL.@)
 */
VOID WINAPI RtlInitializeSListHead( PSLIST_HEADER ListHead )
{
    TRACE("for %p\n", ListHead);

    ListHead->s.Next.Next = NULL;
    ListHead->s.Depth = 0;
    ListHead->s.Sequence = 0;
}


/***********************************************************************
 *           RtlQueryDepthSList    (NTDLL.@)
 */
WORD WINAPI RtlQueryDepthSList( PSLIST_HEADER ListHead )
{
    TRACE("for %p\n", ListHead);

    return ListHead->s.Depth;
}


/***********************************************************************
 *           RtlInterlockedPushEntrySList    (NTDLL.@)
 */
PSLIST_ENTRY WINAPI RtlInterlockedPushEntrySList( PSLIST_HEADER ListHead,
                    PSLIST_ENTRY ListEntry )
{
    PSLIST_ENTRY oldHead;

    TRACE("push %p onto %p\n", ListEntry, ListHead);

    /* put the new entry at the head of the list */
    do {
        oldHead = ListHead->s.Next.Next;
        ListEntry->Next = oldHead;
    } while (InterlockedCompareExchangePointer((PVOID*)&ListHead->s.Next.Next,
             ListEntry, ListEntry->Next) != oldHead);

    /* increment the depth and sequence */
    InterlockedExchangeAdd((PLONG)&ListHead->s.Depth, (1<<16) + 1);

    return oldHead;
}


/***********************************************************************
 *           RtlInterlockedPopEntrySList    (NTDLL.@)
 */
PSLIST_ENTRY WINAPI RtlInterlockedPopEntrySList( PSLIST_HEADER ListHead )
{
    PSLIST_ENTRY item;

    TRACE("for %p\n", ListHead);

    /* pop the first item from the list */
    do {
        item = ListHead->s.Next.Next;
        if (item == NULL)
            return NULL;
    } while (InterlockedCompareExchangePointer((PVOID*)&ListHead->s.Next.Next,
             item->Next, item) != item);

    /* decrement the depth (but not the sequence since testing shows that only
       gets incremented for a push) */
    InterlockedExchangeAdd((PLONG)&ListHead->s.Depth, -1);

    return item;
}


/***********************************************************************
 *           RtlInterlockedFlushSList    (NTDLL.@)
 */
PSLIST_ENTRY WINAPI RtlInterlockedFlushSList( PSLIST_HEADER ListHead )
{
    PSLIST_ENTRY head;
    PSLIST_ENTRY item;
    WORD depth = 0;

    TRACE("for %p\n", ListHead);

    /* get the list head and set it to NULL */
    do {
      head = ListHead->s.Next.Next;
      if (head == NULL)
        return NULL;
    } while (InterlockedCompareExchangePointer((PVOID*)&ListHead->s.Next.Next,
             NULL, head) != head);

    /* count the entries that were flushed from the list */
    item = head;
    while(item)
    {
        depth++;
        item = item->Next;
    }

    /* decrement the depth to zero */
    InterlockedExchangeAdd((PLONG)&ListHead->s.Depth, -depth);

    return head;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.