Author: janderwald Date: Fri Feb 2 01:10:21 2007 New Revision: 25672
URL: http://svn.reactos.org/svn/reactos?rev=25672&view=rev Log: - Use compiler intrinsics instead of hidden dependency of intrlck
Modified: trunk/reactos/lib/rtl/critical.c trunk/reactos/lib/rtl/rtl.h trunk/reactos/lib/rtl/srw.c trunk/reactos/lib/rtl/workitem.c
Modified: trunk/reactos/lib/rtl/critical.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/critical.c?rev=2567... ============================================================================== --- trunk/reactos/lib/rtl/critical.c (original) +++ trunk/reactos/lib/rtl/critical.c Fri Feb 2 01:10:21 2007 @@ -59,13 +59,13 @@
/* We failed, this is bad... */ DPRINT1("Failed to Create Event!\n"); - InterlockedDecrement(&CriticalSection->LockCount); + _InterlockedDecrement(&CriticalSection->LockCount); RtlRaiseStatus(Status); return; } DPRINT("Created Event: %p \n", hNewEvent);
- if ((hEvent = InterlockedCompareExchangePointer((PVOID*)&CriticalSection->LockSemaphore, + if ((hEvent = _InterlockedCompareExchangePointer((PVOID*)&CriticalSection->LockSemaphore, (PVOID)hNewEvent, 0))) {
@@ -427,7 +427,7 @@ HANDLE Thread = (HANDLE)NtCurrentTeb()->Cid.UniqueThread;
/* Try to Lock it */ - if (InterlockedIncrement(&CriticalSection->LockCount) != 0) { + if (_InterlockedIncrement(&CriticalSection->LockCount) != 0) {
/* * We've failed to lock it! Does this thread @@ -611,7 +611,7 @@ if (--CriticalSection->RecursionCount) {
/* Someone still owns us, but we are free. This needs to be done atomically. */ - InterlockedDecrement(&CriticalSection->LockCount); + _InterlockedDecrement(&CriticalSection->LockCount);
} else {
@@ -620,7 +620,7 @@ CriticalSection->OwningThread = 0;
/* Was someone wanting us? This needs to be done atomically. */ - if (-1 != InterlockedDecrement(&CriticalSection->LockCount)) { + if (-1 != _InterlockedDecrement(&CriticalSection->LockCount)) {
/* Let him have us */ RtlpUnWaitCriticalSection(CriticalSection); @@ -652,9 +652,9 @@ RtlTryEnterCriticalSection(PRTL_CRITICAL_SECTION CriticalSection) { /* Try to take control */ - if (InterlockedCompareExchange(&CriticalSection->LockCount, - 0, - -1) == -1) { + if (_InterlockedCompareExchange(&CriticalSection->LockCount, + 0, + -1) == -1) {
/* It's ours */ CriticalSection->OwningThread = NtCurrentTeb()->Cid.UniqueThread; @@ -664,7 +664,7 @@ } else if (CriticalSection->OwningThread == NtCurrentTeb()->Cid.UniqueThread) {
/* It's already ours */ - InterlockedIncrement(&CriticalSection->LockCount); + _InterlockedIncrement(&CriticalSection->LockCount); CriticalSection->RecursionCount++; return TRUE; }
Modified: trunk/reactos/lib/rtl/rtl.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/rtl.h?rev=25672&... ============================================================================== --- trunk/reactos/lib/rtl/rtl.h (original) +++ trunk/reactos/lib/rtl/rtl.h Fri Feb 2 01:10:21 2007 @@ -27,6 +27,7 @@ #include "rtlp.h"
#include <pseh/pseh.h> +#include <intrin.h>
#endif /* RTL_H */
Modified: trunk/reactos/lib/rtl/srw.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/srw.c?rev=25672&... ============================================================================== --- trunk/reactos/lib/rtl/srw.c (original) +++ trunk/reactos/lib/rtl/srw.c Fri Feb 2 01:10:21 2007 @@ -32,9 +32,9 @@ j = *Target; do { i = j; - j = InterlockedCompareExchange((PLONG)Target, - i & Set, - i); + j = _InterlockedCompareExchange((PLONG)Target, + i & Set, + i);
} while (i != j);
@@ -52,9 +52,9 @@ j = *Target; do { i = j; - j = InterlockedCompareExchange((PLONG)Target, - i | Set, - i); + j = _InterlockedCompareExchange((PLONG)Target, + i | Set, + i);
} while (i != j);
@@ -173,8 +173,8 @@ } }
- (void)InterlockedExchangePointer(&SRWLock->Ptr, - (PVOID)NewValue); + (void)_InterlockedExchangePointer(&SRWLock->Ptr, + (PVOID)NewValue);
if (FirstWaitBlock->Exclusive) { @@ -229,8 +229,8 @@ NewValue = RTL_SRWLOCK_OWNED; }
- (void)InterlockedExchangePointer(&SRWLock->Ptr, - (PVOID)NewValue); + (void)_InterlockedExchangePointer(&SRWLock->Ptr, + (PVOID)NewValue);
(void)InterlockedOr(&FirstWaitBlock->Wake, TRUE); @@ -464,9 +464,9 @@ NewValue = (CurrentValue >> RTL_SRWLOCK_BITS) + 1; NewValue = (NewValue << RTL_SRWLOCK_BITS) | (CurrentValue & RTL_SRWLOCK_MASK);
- if (InterlockedCompareExchangePointer(&SRWLock->Ptr, - (PVOID)NewValue, - (PVOID)CurrentValue) == (PVOID)CurrentValue) + if (_InterlockedCompareExchangePointer(&SRWLock->Ptr, + (PVOID)NewValue, + (PVOID)CurrentValue) == (PVOID)CurrentValue) { /* Successfully incremented the shared count, we acquired the lock */ break; @@ -543,9 +543,9 @@ ASSERT_SRW_WAITBLOCK(&StackWaitBlock);
NewValue = (ULONG_PTR)&StackWaitBlock | RTL_SRWLOCK_OWNED | RTL_SRWLOCK_CONTENDED; - if (InterlockedCompareExchangePointer(&SRWLock->Ptr, - (PVOID)NewValue, - (PVOID)CurrentValue) == (PVOID)CurrentValue) + if (_InterlockedCompareExchangePointer(&SRWLock->Ptr, + (PVOID)NewValue, + (PVOID)CurrentValue) == (PVOID)CurrentValue) { RtlpAcquireSRWLockSharedWait(SRWLock, &StackWaitBlock, @@ -565,9 +565,9 @@ RTL_SRWLOCK_SHARED nor the RTL_SRWLOCK_OWNED bit is set */ ASSERT(!(CurrentValue & RTL_SRWLOCK_CONTENDED));
- if (InterlockedCompareExchangePointer(&SRWLock->Ptr, - (PVOID)NewValue, - (PVOID)CurrentValue) == (PVOID)CurrentValue) + if (_InterlockedCompareExchangePointer(&SRWLock->Ptr, + (PVOID)NewValue, + (PVOID)CurrentValue) == (PVOID)CurrentValue) { /* Successfully set the shared count, we acquired the lock */ break; @@ -624,9 +624,9 @@ NewValue = (NewValue << RTL_SRWLOCK_BITS) | RTL_SRWLOCK_SHARED | RTL_SRWLOCK_OWNED; }
- if (InterlockedCompareExchangePointer(&SRWLock->Ptr, - (PVOID)NewValue, - (PVOID)CurrentValue) == (PVOID)CurrentValue) + if (_InterlockedCompareExchangePointer(&SRWLock->Ptr, + (PVOID)NewValue, + (PVOID)CurrentValue) == (PVOID)CurrentValue) { /* Successfully released the lock */ break; @@ -683,9 +683,9 @@
NewValue = (ULONG_PTR)&StackWaitBlock | RTL_SRWLOCK_SHARED | RTL_SRWLOCK_CONTENDED | RTL_SRWLOCK_OWNED;
- if (InterlockedCompareExchangePointer(&SRWLock->Ptr, - (PVOID)NewValue, - (PVOID)CurrentValue) == (PVOID)CurrentValue) + if (_InterlockedCompareExchangePointer(&SRWLock->Ptr, + (PVOID)NewValue, + (PVOID)CurrentValue) == (PVOID)CurrentValue) { RtlpAcquireSRWLockExclusiveWait(SRWLock, &StackWaitBlock); @@ -741,9 +741,9 @@ ASSERT_SRW_WAITBLOCK(&StackWaitBlock);
NewValue = (ULONG_PTR)&StackWaitBlock | RTL_SRWLOCK_OWNED | RTL_SRWLOCK_CONTENDED; - if (InterlockedCompareExchangePointer(&SRWLock->Ptr, - (PVOID)NewValue, - (PVOID)CurrentValue) == (PVOID)CurrentValue) + if (_InterlockedCompareExchangePointer(&SRWLock->Ptr, + (PVOID)NewValue, + (PVOID)CurrentValue) == (PVOID)CurrentValue) { RtlpAcquireSRWLockExclusiveWait(SRWLock, &StackWaitBlock); @@ -811,9 +811,9 @@ ASSERT(!(CurrentValue & ~RTL_SRWLOCK_OWNED));
NewValue = 0; - if (InterlockedCompareExchangePointer(&SRWLock->Ptr, - (PVOID)NewValue, - (PVOID)CurrentValue) == (PVOID)CurrentValue) + if (_InterlockedCompareExchangePointer(&SRWLock->Ptr, + (PVOID)NewValue, + (PVOID)CurrentValue) == (PVOID)CurrentValue) { /* We released the lock */ break;
Modified: trunk/reactos/lib/rtl/workitem.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/workitem.c?rev=2567... ============================================================================== --- trunk/reactos/lib/rtl/workitem.c (original) +++ trunk/reactos/lib/rtl/workitem.c Fri Feb 2 01:10:21 2007 @@ -55,9 +55,9 @@
do { - InitStatus = InterlockedCompareExchange(&ThreadPoolInitialized, - 2, - 0); + InitStatus = _InterlockedCompareExchange(&ThreadPoolInitialized, + 2, + 0); if (InitStatus == 0) { /* We're the first thread to initialize the thread pool */ @@ -91,8 +91,8 @@
Finish: /* Initialization done */ - InterlockedExchange(&ThreadPoolInitialized, - 1); + _InterlockedExchange(&ThreadPoolInitialized, + 1); break; } else if (InitStatus == 2) @@ -223,11 +223,11 @@ }
/* update the requests counter */ - InterlockedDecrement(&ThreadPoolWorkerThreadsRequests); + _InterlockedDecrement(&ThreadPoolWorkerThreadsRequests);
if (WorkItem.Flags & WT_EXECUTELONGFUNCTION) { - InterlockedDecrement(&ThreadPoolWorkerThreadsLongRequests); + _InterlockedDecrement(&ThreadPoolWorkerThreadsLongRequests); } }
@@ -237,11 +237,11 @@ { NTSTATUS Status = STATUS_SUCCESS;
- InterlockedIncrement(&ThreadPoolWorkerThreadsRequests); + _InterlockedIncrement(&ThreadPoolWorkerThreadsRequests);
if (WorkItem->Flags & WT_EXECUTELONGFUNCTION) { - InterlockedIncrement(&ThreadPoolWorkerThreadsLongRequests); + _InterlockedIncrement(&ThreadPoolWorkerThreadsLongRequests); }
if (WorkItem->Flags & WT_EXECUTEINPERSISTENTTHREAD) @@ -270,11 +270,11 @@
if (!NT_SUCCESS(Status)) { - InterlockedDecrement(&ThreadPoolWorkerThreadsRequests); + _InterlockedDecrement(&ThreadPoolWorkerThreadsRequests);
if (WorkItem->Flags & WT_EXECUTELONGFUNCTION) { - InterlockedDecrement(&ThreadPoolWorkerThreadsLongRequests); + _InterlockedDecrement(&ThreadPoolWorkerThreadsLongRequests); } }
@@ -351,11 +351,11 @@ }
/* update the requests counter */ - InterlockedDecrement(&ThreadPoolIOWorkerThreadsRequests); + _InterlockedDecrement(&ThreadPoolIOWorkerThreadsRequests);
if (WorkItem.Flags & WT_EXECUTELONGFUNCTION) { - InterlockedDecrement(&ThreadPoolIOWorkerThreadsLongRequests); + _InterlockedDecrement(&ThreadPoolIOWorkerThreadsLongRequests); } }
@@ -461,14 +461,14 @@
ASSERT(IoThread != NULL);
- InterlockedIncrement(&ThreadPoolIOWorkerThreadsRequests); + _InterlockedIncrement(&ThreadPoolIOWorkerThreadsRequests);
if (WorkItem->Flags & WT_EXECUTELONGFUNCTION) { /* We're about to queue a long function, mark the thread */ IoThread->Flags |= WT_EXECUTELONGFUNCTION;
- InterlockedIncrement(&ThreadPoolIOWorkerThreadsLongRequests); + _InterlockedIncrement(&ThreadPoolIOWorkerThreadsLongRequests); }
/* It's time to queue the work item */ @@ -480,11 +480,11 @@ if (!NT_SUCCESS(Status)) { DPRINT1("Failed to queue APC for work item 0x%p\n", WorkItem->Function); - InterlockedDecrement(&ThreadPoolIOWorkerThreadsRequests); + _InterlockedDecrement(&ThreadPoolIOWorkerThreadsRequests);
if (WorkItem->Flags & WT_EXECUTELONGFUNCTION) { - InterlockedDecrement(&ThreadPoolIOWorkerThreadsLongRequests); + _InterlockedDecrement(&ThreadPoolIOWorkerThreadsLongRequests); } }
@@ -543,7 +543,7 @@ BOOLEAN Terminate; NTSTATUS Status = STATUS_SUCCESS;
- if (InterlockedIncrement(&ThreadPoolIOWorkerThreads) > MAX_WORKERTHREADS) + if (_InterlockedIncrement(&ThreadPoolIOWorkerThreads) > MAX_WORKERTHREADS) { /* Oops, too many worker threads... */ goto InitFailed; @@ -562,10 +562,10 @@ DPRINT1("Failed to create handle to own thread! Status: 0x%x\n", Status);
InitFailed: - InterlockedDecrement(&ThreadPoolIOWorkerThreads); + _InterlockedDecrement(&ThreadPoolIOWorkerThreads);
/* Signal initialization completion */ - InterlockedExchange((PLONG)Parameter, + _InterlockedExchange((PLONG)Parameter, 1);
RtlExitUserThread(Status); @@ -579,8 +579,8 @@ (PLIST_ENTRY)&ThreadInfo.ListEntry);
/* Signal initialization completion */ - InterlockedExchange((PLONG)Parameter, - 1); + _InterlockedExchange((PLONG)Parameter, + 1);
for (;;) { @@ -626,7 +626,7 @@ if (Terminate) { /* Rundown the thread and unlink it from the list */ - InterlockedDecrement(&ThreadPoolIOWorkerThreads); + _InterlockedDecrement(&ThreadPoolIOWorkerThreads); RemoveEntryList((PLIST_ENTRY)&ThreadInfo.ListEntry); }
@@ -663,11 +663,11 @@ PKNORMAL_ROUTINE ApcRoutine; NTSTATUS Status = STATUS_SUCCESS;
- if (InterlockedIncrement(&ThreadPoolWorkerThreads) > MAX_WORKERTHREADS) + if (_InterlockedIncrement(&ThreadPoolWorkerThreads) > MAX_WORKERTHREADS) { /* Signal initialization completion */ - InterlockedExchange((PLONG)Parameter, - 1); + _InterlockedExchange((PLONG)Parameter, + 1);
/* Oops, too many worker threads... */ RtlExitUserThread(Status); @@ -675,8 +675,8 @@ }
/* Signal initialization completion */ - InterlockedExchange((PLONG)Parameter, - 1); + _InterlockedExchange((PLONG)Parameter, + 1);
for (;;) { @@ -736,7 +736,7 @@
if (Terminate) { - InterlockedDecrement(&ThreadPoolWorkerThreads); + _InterlockedDecrement(&ThreadPoolWorkerThreads); Status = STATUS_SUCCESS; break; }