ReactOS  0.4.14-dev-614-gbfd8a84
interlocked.c
Go to the documentation of this file.
1 typedef unsigned int size_t;
2 #include <ntddk.h>
3 #include <winddk.h>
4 #include <string.h>
5 #include <intrin.h>
6 
8 LONG
11  LONG volatile *Target, LONG Value)
12 {
14 }
15 
17 LONG
20  LONG volatile *Target, LONG Value)
21 {
23 }
24 
26 LONG
27 WINAPI
29  LONG volatile *Destination,
30  LONG Exchange, LONG Comparand)
31 {
32  return _InterlockedCompareExchange(Destination, Exchange, Comparand);
33 }
34 
36 LONG
39 (IN OUT LONG volatile *Addend)
40 {
42 }
43 
45 LONG
48  IN OUT LONG volatile *Addend)
49 {
51 }
52 
54 WINAPI
56  PSLIST_HEADER ListHead)
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 }
78 
83  IN PSLIST_HEADER ListHead,
84  IN PSLIST_ENTRY ListEntry)
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 }
99 
101 VOID
102 FASTCALL
106 {
108 }
109 
111 LONGLONG
112 FASTCALL
115  IN PLONGLONG Exchange,
116  IN PLONGLONG Comparand,
118 {
119  KIRQL OldIrql;
121 
123  Result = *Destination;
124  if(*Destination == Result)
125  *Destination = *Exchange;
127  return Result;
128 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
NTKERNELAPI LONG WINAPI InterlockedCompareExchange(LONG volatile *Destination, LONG Exchange, LONG Comparand)
Definition: interlocked.c:28
long __cdecl _InterlockedCompareExchange(_Interlocked_operand_ long volatile *_Destination, long _Exchange, long _Comparand)
NTKERNELAPI LONG FASTCALL InterlockedExchange(LONG volatile *Target, LONG Value)
Definition: interlocked.c:10
unsigned int size_t
Definition: interlocked.c:1
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
KSPIN_LOCK * PKSPIN_LOCK
Definition: env_spec_w32.h:73
NTKERNELAPI LONG FASTCALL InterlockedIncrement(IN OUT LONG volatile *Addend)
Definition: interlocked.c:39
NTKERNELAPI VOID FASTCALL ExInterlockedAddLargeStatistic(IN PLARGE_INTEGER Addend, IN ULONG Increment)
Definition: interlocked.c:103
#define FASTCALL
Definition: nt_native.h:50
IN OUT PLONG Addend
Definition: CrNtStubs.h:22
PSLIST_ENTRY WINAPI InterlockedPopEntrySList(PSLIST_HEADER ListHead)
Definition: interlocked.c:55
__GNU_EXTENSION typedef __int64 * PLONGLONG
Definition: ntbasedef.h:389
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTKERNELAPI LONGLONG FASTCALL ExInterlockedCompareExchange64(IN OUT PLONGLONG Destination, IN PLONGLONG Exchange, IN PLONGLONG Comparand, IN PKSPIN_LOCK Lock)
Definition: interlocked.c:113
NTKERNELAPI LONG FASTCALL InterlockedExchangeAdd(LONG volatile *Target, LONG Value)
Definition: interlocked.c:19
long __cdecl _InterlockedIncrement(_Interlocked_operand_ long volatile *_Addend)
long LONG
Definition: pedump.c:60
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
__INTRIN_INLINE long _InterlockedAddLargeStatistic(volatile long long *const Addend, const long Value)
Definition: intrin_arm.h:359
unsigned char BOOLEAN
long __cdecl _InterlockedDecrement(_Interlocked_operand_ long volatile *_Addend)
smooth NULL
Definition: ftsmooth.c:416
_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
#define NTKERNELAPI
int64_t LONGLONG
Definition: typedefs.h:66
SLIST_ENTRY Next
Definition: rtltypes.h:137
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define WINAPI
Definition: msvc.h:6
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2891
#define PSLIST_ENTRY
Definition: rtltypes.h:130
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1068
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
NTKERNELAPI LONG FASTCALL InterlockedDecrement(IN OUT LONG volatile *Addend)
Definition: interlocked.c:47
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
NTKERNELAPI PSLIST_ENTRY FASTCALL InterlockedPushEntrySList(IN PSLIST_HEADER ListHead, IN PSLIST_ENTRY ListEntry)
Definition: interlocked.c:82
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:42
long __cdecl _InterlockedExchangeAdd(_Interlocked_operand_ long volatile *_Addend, long _Value)