ReactOS  r76032
interlocked.c File Reference
#include <ntddk.h>
#include <winddk.h>
#include <string.h>
#include <intrin.h>
Include dependency graph for interlocked.c:

Go to the source code of this file.

Typedefs

typedef unsigned int size_t
 

Functions

NTKERNELAPI LONG FASTCALL InterlockedExchange (LONG volatile *Target, LONG Value)
 
NTKERNELAPI LONG FASTCALL InterlockedExchangeAdd (LONG volatile *Target, LONG Value)
 
NTKERNELAPI LONG WINAPI InterlockedCompareExchange (LONG volatile *Destination, LONG Exchange, LONG Comparand)
 
NTKERNELAPI LONG FASTCALL InterlockedIncrement (IN OUT LONG volatile *Addend)
 
NTKERNELAPI LONG FASTCALL InterlockedDecrement (IN OUT LONG volatile *Addend)
 
PSLIST_ENTRY WINAPI InterlockedPopEntrySList (PSLIST_HEADER ListHead)
 
NTKERNELAPI PSLIST_ENTRY FASTCALL InterlockedPushEntrySList (IN PSLIST_HEADER ListHead, IN PSLIST_ENTRY ListEntry)
 
NTKERNELAPI VOID FASTCALL ExInterlockedAddLargeStatistic (IN PLARGE_INTEGER Addend, IN ULONG Increment)
 
NTKERNELAPI LONGLONG FASTCALL ExInterlockedCompareExchange64 (IN OUT PLONGLONG Destination, IN PLONGLONG Exchange, IN PLONGLONG Comparand, IN PKSPIN_LOCK Lock)
 

Typedef Documentation

typedef unsigned int size_t

Definition at line 1 of file interlocked.c.

Function Documentation

NTKERNELAPI VOID FASTCALL ExInterlockedAddLargeStatistic ( IN PLARGE_INTEGER  Addend,
IN ULONG  Increment 
)

Definition at line 103 of file interlocked.c.

Referenced by IopUpdateOperationCount(), IopUpdateTransferCount(), RxCommonRead(), RxCommonWrite(), RxLowIoReadShell(), RxLowIoWriteShell(), and TestInterlockedFunctional().

106 {
108 }
IN OUT PLONG Addend
Definition: CrNtStubs.h:22
__INTRIN_INLINE long _InterlockedAddLargeStatistic(volatile long long *const Addend, const long Value)
Definition: intrin_arm.h:359
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:42
NTKERNELAPI LONGLONG FASTCALL ExInterlockedCompareExchange64 ( IN OUT PLONGLONG  Destination,
IN PLONGLONG  Exchange,
IN PLONGLONG  Comparand,
IN PKSPIN_LOCK  Lock 
)

Definition at line 113 of file interlocked.c.

Referenced by ExAllocateLocallyUniqueId(), KsGetDefaultClockTime(), KsSetDefaultClockTime(), and TestInterlockedFunctional().

118 {
119  KIRQL OldIrql;
121 
122  KeAcquireSpinLock(Lock, &OldIrql);
123  Result = *Destination;
124  if(*Destination == Result)
125  *Destination = *Exchange;
126  KeReleaseSpinLock(Lock, OldIrql);
127  return Result;
128 }
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
UCHAR KIRQL
Definition: env_spec_w32.h:591
int64_t LONGLONG
Definition: typedefs.h:66
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2875
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment IN PNDIS_RW_LOCK Lock
Definition: CrNtStubs.h:75
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
NTKERNELAPI LONG WINAPI InterlockedCompareExchange ( LONG volatile Destination,
LONG  Exchange,
LONG  Comparand 
)

Definition at line 28 of file interlocked.c.

31 {
32  return _InterlockedCompareExchange(Destination, Exchange, Comparand);
33 }
long __cdecl _InterlockedCompareExchange(_Interlocked_operand_ long volatile *_Destination, long _Exchange, long _Comparand)
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2875
NTKERNELAPI LONG FASTCALL InterlockedDecrement ( IN OUT LONG volatile Addend)

Definition at line 47 of file interlocked.c.

49 {
51 }
IN OUT PLONG Addend
Definition: CrNtStubs.h:22
long __cdecl _InterlockedDecrement(_Interlocked_operand_ long volatile *_Addend)
NTKERNELAPI LONG FASTCALL InterlockedExchange ( LONG volatile Target,
LONG  Value 
)

Definition at line 10 of file interlocked.c.

12 {
14 }
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1067
UINTN UINT8 Value
Definition: acefiex.h:751
NTKERNELAPI LONG FASTCALL InterlockedExchangeAdd ( LONG volatile Target,
LONG  Value 
)

Definition at line 19 of file interlocked.c.

21 {
23 }
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1067
UINTN UINT8 Value
Definition: acefiex.h:751
long __cdecl _InterlockedExchangeAdd(_Interlocked_operand_ long volatile *_Addend, long _Value)
NTKERNELAPI LONG FASTCALL InterlockedIncrement ( IN OUT LONG volatile Addend)

Definition at line 39 of file interlocked.c.

40 {
42 }
IN OUT PLONG Addend
Definition: CrNtStubs.h:22
long __cdecl _InterlockedIncrement(_Interlocked_operand_ long volatile *_Addend)
PSLIST_ENTRY WINAPI InterlockedPopEntrySList ( PSLIST_HEADER  ListHead)

Definition at line 55 of file interlocked.c.

Referenced by __drv_allocatesMem(), _IRQL_requires_max_(), DequeueFreeTransferPacket(), DeviceInstallThread(), ExAllocatePoolWithTag(), ExDeleteNPagedLookasideList(), ExDeletePagedLookasideList(), ExiAllocateFromPagedLookasideList(), IoAllocateIrp(), IoSetIoCompletion(), MiAllocatePoolPages(), MmCreateKernelStack(), and ObpAllocateObjectCreateInfoBuffer().

57 {
59  KIRQL OldIrql;
60  static BOOLEAN GLLInit = FALSE;
61  static KSPIN_LOCK GlobalListLock;
62 
63  if(!GLLInit)
64  {
65  KeInitializeSpinLock(&GlobalListLock);
66  GLLInit = TRUE;
67  }
68 
69  KeAcquireSpinLock(&GlobalListLock, &OldIrql);
70  if(ListHead->Next.Next)
71  {
72  Result = ListHead->Next.Next;
73  ListHead->Next.Next = Result->Next;
74  }
75  KeReleaseSpinLock(&GlobalListLock, OldIrql);
76  return Result;
77 }
#define TRUE
Definition: types.h:120
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
smooth NULL
Definition: ftsmooth.c:557
unsigned char BOOLEAN
SLIST_ENTRY Next
Definition: rtltypes.h:137
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define PSLIST_ENTRY
Definition: rtltypes.h:130
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
NTKERNELAPI PSLIST_ENTRY FASTCALL InterlockedPushEntrySList ( IN PSLIST_HEADER  ListHead,
IN PSLIST_ENTRY  ListEntry 
)

Definition at line 82 of file interlocked.c.

Referenced by __drv_freesMem(), EnqueueFreeTransferPacket(), ExFreePoolWithTag(), ExiFreeToPagedLookasideList(), IoFreeIrp(), IopFreeMiniPacket(), MiFreePoolPages(), MmDeleteKernelStack(), ObpFreeCapturedAttributes(), and PnpEventThread().

85 {
86  PVOID PrevValue;
87 
88  do
89  {
90  PrevValue = ListHead->Next.Next;
91  ListEntry->Next = PrevValue;
92  }
93  while (InterlockedCompareExchangePointer(&ListHead->Next.Next,
94  ListEntry,
95  PrevValue) != PrevValue);
96 
97  return (PSLIST_ENTRY)PrevValue;
98 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
#define PSLIST_ENTRY
Definition: rtltypes.h:130