20__declspec(dllimport)
unsigned long __stdcall Exi386InterlockedExchangeUlong(
unsigned long *,
unsigned long);
43#elif defined(_M_AMD64)
46 unsigned long long rsi, rdi, rbx, rbp, rsp, r12, r13, r14, r15;
50typedef int PROCESSOR_STATE;
55#if defined(_MSC_VER) && defined(_M_IX86)
56#define SaveState(State) do \
58 __asm lea ecx, [State] \
59 __asm mov [ecx], esi \
60 __asm mov [ecx+4], edi \
61 __asm mov [ecx+8], ebx \
62 __asm mov [ecx+12], ebp \
63 __asm mov [ecx+16], esp \
66#define CheckState(OldState, NewState) do \
70 ok_eq_hex((OldState)->edi, (NewState)->edi); \
71 ok_eq_hex((OldState)->ebx, (NewState)->ebx); \
72 ok_eq_hex((OldState)->ebp, (NewState)->ebp); \
73 ok_eq_hex((OldState)->esp, (NewState)->esp); \
76#elif defined(__GNUC__) && defined(_M_IX86)
77#define SaveState(State) \
79 "movl\t%%esi, (%%ecx)\n\t" \
80 "movl\t%%edi, 4(%%ecx)\n\t" \
81 "movl\t%%ebx, 8(%%ecx)\n\t" \
82 "movl\t%%ebp, 12(%%ecx)\n\t" \
83 "movl\t%%esp, 16(%%ecx)" \
84 : : "c" (&State) : "memory" \
87#define CheckState(OldState, NewState) do \
91 ok_eq_hex((OldState)->edi, (NewState)->edi); \
94 ok_eq_hex((OldState)->ebp, (NewState)->ebp); \
95 ok_eq_hex((OldState)->esp, (NewState)->esp); \
97#elif defined(__GNUC__) && defined(_M_AMD64)
98#define SaveState(State) \
100 "mov\t%%rsi, (%%rcx)\n\t" \
101 "mov\t%%rdi, 8(%%rcx)\n\t" \
102 "mov\t%%rbx, 16(%%rcx)\n\t" \
103 "mov\t%%rbp, 24(%%rcx)\n\t" \
104 "mov\t%%rsp, 32(%%rcx)\n\t" \
105 "mov\t%%r12, 40(%%rcx)\n\t" \
106 "mov\t%%r13, 48(%%rcx)\n\t" \
107 "mov\t%%r14, 56(%%rcx)\n\t" \
108 "mov\t%%r15, 64(%%rcx)" \
109 : : "c" (&State) : "memory" \
112#define CheckState(OldState, NewState) do \
114 ok_eq_hex((OldState)->rsi, (NewState)->rsi); \
115 ok_eq_hex((OldState)->rdi, (NewState)->rdi); \
116 ok_eq_hex((OldState)->rbx, (NewState)->rbx); \
117 ok_eq_hex((OldState)->rbp, (NewState)->rbp); \
118 ok_eq_hex((OldState)->rsp, (NewState)->rsp); \
119 ok_eq_hex((OldState)->r12, (NewState)->r12); \
120 ok_eq_hex((OldState)->r13, (NewState)->r13); \
121 ok_eq_hex((OldState)->r14, (NewState)->r14); \
122 ok_eq_hex((OldState)->r15, (NewState)->r15); \
125#define SaveState(State)
126#define CheckState(OldState, NewState) do \
143#define CheckInterlockedCmpXchg(Function, Type, Print, Val, Cmp, Xchg, \
144 ExpectedValue, ExpectedRet) do \
146 Type Ret##Type = 0; \
147 Type Value##Type = Val; \
148 Status = STATUS_SUCCESS; \
150 SaveState(OldState); \
151 Ret##Type = Function(&Value##Type, Xchg, Cmp); \
152 SaveState(NewState); \
153 CheckState(&OldState, &NewState); \
154 } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { \
155 Status = _SEH2_GetExceptionCode(); \
157 ok_eq_hex(Status, STATUS_SUCCESS); \
158 ok_eq_print(Ret##Type, ExpectedRet, Print); \
159 ok_eq_print(Value##Type, ExpectedValue, Print); \
162#define CheckInterlockedCmpXchgI(Function, Type, Print, Val, Cmp, Xchg, \
163 ExpectedValue, ExpectedRet, ...) do \
165 Type Ret##Type = 0; \
166 Type Value##Type = Val; \
167 Type Compare##Type = Cmp; \
168 Type Exchange##Type = Xchg; \
169 Status = STATUS_SUCCESS; \
171 SaveState(OldState); \
172 Ret##Type = Function(&Value##Type, &Exchange##Type, \
173 &Compare##Type, ##__VA_ARGS__); \
174 SaveState(NewState); \
175 CheckState(&OldState, &NewState); \
176 } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { \
177 Status = _SEH2_GetExceptionCode(); \
179 ok_eq_hex(Status, STATUS_SUCCESS); \
180 ok_eq_print(Ret##Type, ExpectedRet, Print); \
181 ok_eq_print(Value##Type, ExpectedValue, Print); \
182 ok_eq_print(Exchange##Type, Xchg, Print); \
183 ok_eq_print(Compare##Type, Cmp, Print); \
186#define CheckInterlockedOp(Function, Type, Print, Val, Op, \
187 ExpectedValue, ExpectedRet, ...) do \
189 Type Ret##Type = 0; \
190 Type Value##Type = Val; \
191 Status = STATUS_SUCCESS; \
193 SaveState(OldState); \
194 Ret##Type = Function(&Value##Type, Op, ##__VA_ARGS__); \
195 SaveState(NewState); \
196 CheckState(&OldState, &NewState); \
197 } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { \
198 Status = _SEH2_GetExceptionCode(); \
200 ok_eq_hex(Status, STATUS_SUCCESS); \
201 ok_eq_print(Ret##Type, ExpectedRet, Print); \
202 ok_eq_print(Value##Type, ExpectedValue, Print); \
205#define CheckInterlockedOpNoArg(Function, Type, Print, Val, \
206 ExpectedValue, ExpectedRet, ...) do \
208 Type Ret##Type = 0; \
209 Type Value##Type = Val; \
210 Status = STATUS_SUCCESS; \
212 SaveState(OldState); \
213 Ret##Type = Function(&Value##Type, ##__VA_ARGS__); \
214 SaveState(NewState); \
215 CheckState(&OldState, &NewState); \
216 } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { \
217 Status = _SEH2_GetExceptionCode(); \
219 ok_eq_hex(Status, STATUS_SUCCESS); \
220 ok_eq_print(Ret##Type, ExpectedRet, Print); \
221 ok_eq_print(Value##Type, ExpectedValue, Print); \
224#define CheckInterlockedOpLarge(Function, Type, Print, Val, Op, \
225 ExpectedValue, ExpectedRet, ...) do \
227 Type Ret##Type = Large(0); \
228 Type Value##Type = Val; \
229 Status = STATUS_SUCCESS; \
231 SaveState(OldState); \
232 Ret##Type = Function(&Value##Type, Op, ##__VA_ARGS__); \
233 SaveState(NewState); \
234 CheckState(&OldState, &NewState); \
235 } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { \
236 Status = _SEH2_GetExceptionCode(); \
238 ok_eq_hex(Status, STATUS_SUCCESS); \
239 ok_eq_print(Ret##Type.QuadPart, ExpectedRet, Print); \
240 ok_eq_print(Value##Type.QuadPart, ExpectedValue, Print); \
243#define CheckInterlockedOpLargeNoRet(Function, Type, Print, Val, Op, \
246 Type Value##Type = Val; \
247 Status = STATUS_SUCCESS; \
249 SaveState(OldState); \
250 Function(&Value##Type, Op); \
251 SaveState(NewState); \
252 CheckState(&OldState, &NewState); \
253 } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { \
254 Status = _SEH2_GetExceptionCode(); \
256 ok_eq_hex(Status, STATUS_SUCCESS); \
257 ok_eq_print(Value##Type.QuadPart, ExpectedValue, Print); \
266 PROCESSOR_STATE OldState, NewState;
269#if defined _M_IX86 || defined _M_AMD64
283#undef InterlockedCompareExchange
306#undef InterlockedExchange
318#undef InterlockedExchangeAdd
328#undef ExInterlockedAddUlong
336#undef InterlockedIncrement
359#undef InterlockedDecrement
#define CheckInterlockedOp(Function, Type, Print, Val, Op, ExpectedValue, ExpectedRet,...)
#define CheckInterlockedOpLarge(Function, Type, Print, Val, Op, ExpectedValue, ExpectedRet,...)
static VOID TestInterlockedFunctional(VOID)
#define CheckInterlockedOpNoArg(Function, Type, Print, Val, ExpectedValue, ExpectedRet,...)
#define CheckInterlockedCmpXchg(Function, Type, Print, Val, Cmp, Xchg, ExpectedValue, ExpectedRet)
#define CheckInterlockedOpLargeNoRet(Function, Type, Print, Val, Op, ExpectedValue)
#define CheckInterlockedCmpXchgI(Function, Type, Print, Val, Cmp, Xchg, ExpectedValue, ExpectedRet,...)
#define InterlockedIncrement
#define InterlockedExchange
#define InterlockedDecrement
#define InterlockedExchangePointer(Target, Value)
#define KeRaiseIrql(irql, oldIrql)
#define KeLowerIrql(oldIrql)
#define KeInitializeSpinLock(sl)
ULONG NTAPI ExInterlockedAddUlong(IN OUT PULONG Addend, IN ULONG Increment, IN OUT PKSPIN_LOCK Lock)
LARGE_INTEGER NTAPI ExInterlockedAddLargeInteger(IN OUT PLARGE_INTEGER Addend, IN LARGE_INTEGER Increment, IN OUT PKSPIN_LOCK Lock)
#define InterlockedCompareExchangeAcquire
#define InterlockedIncrementRelease
#define InterlockedExchangeAdd
#define InterlockedCompareExchangePointer
#define InterlockedDecrementAcquire
#define InterlockedCompareExchange
#define InterlockedIncrementAcquire
#define InterlockedCompareExchangeRelease
#define InterlockedDecrementRelease
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl ebx
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx movl TEMP incl eax andl eax ecx incl ebx testl eax jnz xchgl ecx incl TEMP esp ecx subl ebx pushl ecx ecx edx ecx shrl ecx mm0 mm4 mm0 mm4 mm1 mm5 mm1 mm5 mm2 mm6 mm2 mm6 mm3 mm7 mm3 mm7 paddd mm0 paddd mm4 paddd mm0 paddd mm4 paddd mm0 paddd mm4 movq mm1 movq mm5 psrlq mm1 psrlq mm5 paddd mm0 paddd mm4 psrad mm0 psrad mm4 packssdw mm0 packssdw mm4 mm1 punpckldq mm0 pand mm1 pand mm0 por mm1 movq edi esi edx edi decl ecx jnz popl ecx andl ecx jecxz mm0 mm0 mm1 mm1 mm2 mm2 mm3 mm3 paddd mm0 paddd mm0 paddd mm0 movq mm1 psrlq mm1 paddd mm0 psrad mm0 packssdw mm0 movd eax movw edi esi edx edi
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx movl TEMP incl eax andl eax ecx incl ebx testl eax jnz xchgl ecx incl TEMP esi
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx movl TEMP incl eax andl eax ecx incl ebx testl eax jnz xchgl ecx incl TEMP esp ecx subl ebx pushl ecx ecx edx ecx shrl ecx mm0 mm4 mm0 mm4 mm1 mm5 mm1 mm5 mm2 mm6 mm2 mm6 mm3 mm7 mm3 mm7 paddd mm0 paddd mm4 paddd mm0 paddd mm4 paddd mm0 paddd mm4 movq mm1 movq mm5 psrlq mm1 psrlq mm5 paddd mm0 paddd mm4 psrad mm0 psrad mm4 packssdw mm0 packssdw mm4 mm1 punpckldq mm0 pand mm1 pand mm0 por mm1 movq edi esi edx edi decl ecx jnz popl ecx andl ecx jecxz mm0 mm0 mm1 mm1 mm2 mm2 mm3 mm3 paddd mm0 paddd mm0 paddd mm0 movq mm1 psrlq mm1 paddd mm0 psrad mm0 packssdw mm0 movd eax movw edi esi edx esi movl ecx mm0 mm4 mm0 mm4 mm1 mm5 mm1 mm5 mm2 mm6 mm2 mm6 mm3 mm7 mm3 mm7 paddd mm0 paddd mm4 paddd mm0 paddd mm4 paddd mm0 paddd mm4 movq mm1 movq mm5 psrlq mm1 psrlq mm5 paddd mm1 paddd mm5 psrad mm1 psrad mm5 packssdw mm1 packssdw mm5 psubd mm0 psubd mm4 psubsw mm0 psubsw mm4 mm1 punpckldq mm0 pand mm1 pand mm0 por mm1 movq edi subl esi addl edx edi decl ecx jnz mm0 mm0 mm1 mm1 mm2 mm2 mm3 mm3 paddd mm0 paddd mm0 paddd mm0 movq mm1 psrlq mm1 paddd mm1 psrad mm1 packssdw mm1 psubd mm0 psubsw mm0 movd eax movw edi emms popl ebx popl esi popl edi mov ebp
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
#define ExInterlockedAddLargeStatistic(Addend, Increment)
#define ExInterlockedExchangeUlong(Target, Value, Lock)
#define ExInterlockedDecrementLong(Addend, Lock)
#define ExInterlockedIncrementLong(Addend, Lock)
#define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock)