ReactOS  0.4.14-dev-297-g23e575c
KeSpinLock.c File Reference
#include <kmt_test.h>
#include <limits.h>
#include <debug.h>
Include dependency graph for KeSpinLock.c:

Go to the source code of this file.

Macros

#define WIN9X_COMPAT_SPINLOCK
 
#define DEFINE_ACQUIRE(LocalName, SetIsAcquired, DoCall)
 
#define DEFINE_RELEASE(LocalName, SetIsAcquired, DoCall)
 
#define CheckSpinLockLock(SpinLock, CheckData, Value)
 
#define CheckSpinLockQueue(SpinLock, CheckData, Value)
 
#define CheckSpinLockQueueHandle(SpinLock, CheckData, Value)
 
#define CheckSpinLock(SpinLock, CheckData, Value)
 

Functions

 __declspec (__declspec() void __stdcall KeAcquireSpinLockAtDpcLevel(unsigned long *) dllimport)
 
 DEFINE_ACQUIRE (AcquireExpNoRaise, DEFINE_RELEASE(FALSE,(KeAcquireSpinLockAtDpcLevel)(SpinLock))
 
BOOLEAN TryQueuedSynch (PKSPIN_LOCK SpinLock, PCHECK_DATA CheckData)
 
BOOLEAN TryNoRaise (PKSPIN_LOCK SpinLock, PCHECK_DATA CheckData)
 
static VOID TestSpinLock (PKSPIN_LOCK SpinLock, PCHECK_DATA CheckData)
 
 START_TEST (KeSpinLock)
 

Macro Definition Documentation

◆ CheckSpinLock

#define CheckSpinLock (   SpinLock,
  CheckData,
  Value 
)
Value:
do \
{ \
BOOLEAN Ret = SpinLock && pKeTestSpinLock ? pKeTestSpinLock(SpinLock) : TRUE; \
KIRQL ExpectedIrql = (CheckData)->OriginalIrql; \
switch ((CheckData)->Check) \
{ \
case CheckLock: \
CheckSpinLockLock(SpinLock, CheckData, Value); \
break; \
case CheckQueue: \
CheckSpinLockQueue(SpinLock, CheckData, Value); \
break; \
case CheckQueueHandle: \
CheckSpinLockQueueHandle(SpinLock, CheckData, Value); \
break; \
} \
if ((CheckData)->IsAcquired) \
ExpectedIrql = (CheckData)->IrqlWhenAcquired; \
ok_irql(ExpectedIrql); \
ok_bool_false(KeAreApcsDisabled(), "KeAreApcsDisabled returned"); \
ok_bool_true(KmtAreInterruptsEnabled(), "Interrupts enabled:"); \
} while (0)
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#define TRUE
Definition: types.h:120
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
int Check()
Definition: movefile.cpp:196
switch(r->id)
Definition: btrfs.c:2932
if(!(yy_init))
Definition: macro.lex.yy.c:714
BOOLEAN KmtAreInterruptsEnabled(VOID)
BOOLEAN NTAPI KeAreApcsDisabled(VOID)
Definition: apc.c:958

Definition at line 216 of file KeSpinLock.c.

◆ CheckSpinLockLock

#define CheckSpinLockLock (   SpinLock,
  CheckData,
  Value 
)
Value:
do \
{ \
PKTHREAD Thread = KeGetCurrentThread(); \
UNREFERENCED_LOCAL_VARIABLE(Thread); \
{ \
ok_eq_bool(Ret, (Value) == 0); \
if (SpinLock) \
ok_eq_ulongptr(*(SpinLock), \
(Value) ? (ULONG_PTR)Thread | 1 : 0); \
} \
else \
{ \
ok_bool_true(Ret, "KeTestSpinLock returned"); \
if (SpinLock) \
ok_eq_ulongptr(*(SpinLock), 0); \
} \
ok_eq_uint((CheckData)->Irql, (CheckData)->OriginalIrql); \
} while (0)
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
_Out_ PKIRQL Irql
Definition: csq.h:179
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
uint32_t ULONG_PTR
Definition: typedefs.h:63
BOOLEAN KmtIsMultiProcessorBuild
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define KeGetCurrentThread
Definition: hal.h:44

Definition at line 166 of file KeSpinLock.c.

◆ CheckSpinLockQueue

#define CheckSpinLockQueue (   SpinLock,
  CheckData,
  Value 
)
Value:
do \
{ \
ok_eq_pointer((CheckData)->Queue->Next, NULL); \
ok_eq_pointer((CheckData)->Queue->Lock, NULL); \
ok_eq_uint((CheckData)->Irql, (CheckData)->OriginalIrql); \
} while (0)
_Out_ PKIRQL Irql
Definition: csq.h:179
smooth NULL
Definition: ftsmooth.c:416

Definition at line 186 of file KeSpinLock.c.

◆ CheckSpinLockQueueHandle

#define CheckSpinLockQueueHandle (   SpinLock,
  CheckData,
  Value 
)
Value:
do \
{ \
{ \
ok_eq_bool(Ret, (Value) == 0); \
if (SpinLock) \
ok_eq_ulongptr(*(SpinLock), \
(Value) ? &(CheckData)->QueueHandle : 0); \
ok_eq_pointer((CheckData)->QueueHandle.LockQueue.Next, NULL); \
ok_eq_pointer((CheckData)->QueueHandle.LockQueue.Lock, \
(PVOID)((ULONG_PTR)SpinLock | ((Value) ? 2 : 0))); \
} \
else \
{ \
ok_bool_true(Ret, "KeTestSpinLock returned"); \
if (SpinLock) \
ok_eq_ulongptr(*(SpinLock), 0); \
ok_eq_pointer((CheckData)->QueueHandle.LockQueue.Next, (CheckData)->UntouchedValue); \
ok_eq_pointer((CheckData)->QueueHandle.LockQueue.Lock, (CheckData)->UntouchedValue); \
} \
ok_eq_uint((CheckData)->QueueHandle.OldIrql, (CheckData)->OriginalIrql); \
} while (0)
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN KmtIsMultiProcessorBuild

Definition at line 193 of file KeSpinLock.c.

◆ DEFINE_ACQUIRE

#define DEFINE_ACQUIRE (   LocalName,
  SetIsAcquired,
  DoCall 
)
Value:
static VOID LocalName(PKSPIN_LOCK SpinLock, PCHECK_DATA CheckData) \
{ \
ASSERT(!CheckData->IsAcquired); \
DoCall; \
if (SetIsAcquired) CheckData->IsAcquired = TRUE; \
}
#define TRUE
Definition: types.h:120
KSPIN_LOCK * PKSPIN_LOCK
Definition: env_spec_w32.h:73
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798

Definition at line 91 of file KeSpinLock.c.

◆ DEFINE_RELEASE

#define DEFINE_RELEASE (   LocalName,
  SetIsAcquired,
  DoCall 
)
Value:
static VOID LocalName(PKSPIN_LOCK SpinLock, PCHECK_DATA CheckData) \
{ \
DoCall; \
if (SetIsAcquired) CheckData->IsAcquired = FALSE; \
}
KSPIN_LOCK * PKSPIN_LOCK
Definition: env_spec_w32.h:73
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798

Definition at line 99 of file KeSpinLock.c.

◆ WIN9X_COMPAT_SPINLOCK

#define WIN9X_COMPAT_SPINLOCK

Function Documentation

◆ __declspec()

__declspec ( __declspec() void __stdcall KeAcquireSpinLockAtDpcLevel(unsigned long *)  dllimport)

Definition at line 9 of file KeSpinLock.c.

64 {
65  enum
66  {
67  CheckQueueHandle,
68  CheckQueue,
69  CheckLock
70  } Check;
71  KIRQL IrqlWhenAcquired;
72  PACQUIRE_FUNCTION Acquire;
73  PRELEASE_FUNCTION Release;
74  PTRY_FUNCTION TryAcquire;
75  PACQUIRE_FUNCTION AcquireNoRaise;
76  PRELEASE_FUNCTION ReleaseNoLower;
77  PTRY_FUNCTION TryAcquireNoRaise;
78  KSPIN_LOCK_QUEUE_NUMBER QueueNumber;
79  BOOLEAN TryRetOnFailure;
80  KIRQL OriginalIrql;
81  BOOLEAN IsAcquired;
82  _ANONYMOUS_UNION union
83  {
84  KLOCK_QUEUE_HANDLE QueueHandle;
85  PKSPIN_LOCK_QUEUE Queue;
86  KIRQL Irql;
88  PVOID UntouchedValue;
89 };
_In_ BOOLEAN Release
Definition: classpnp.h:929
#define _ANONYMOUS_UNION
Definition: ntbasedef.h:30
#define DUMMYUNIONNAME
Definition: ntbasedef.h:32
_Out_ PKIRQL Irql
Definition: csq.h:179
UCHAR KIRQL
Definition: env_spec_w32.h:591
int Check()
Definition: movefile.cpp:196
unsigned char BOOLEAN
BOOLEAN(NTAPI * PACQUIRE_FUNCTION)(PERESOURCE, BOOLEAN)
Definition: ExResource.c:263
enum _KSPIN_LOCK_QUEUE_NUMBER KSPIN_LOCK_QUEUE_NUMBER

◆ DEFINE_ACQUIRE()

DEFINE_ACQUIRE ( AcquireExpNoRaise  ,
DEFINE_RELEASE FALSE,
(KeAcquireSpinLockAtDpcLevel)(SpinLock  
)

Definition at line 127 of file KeSpinLock.c.

150  {
151  LOGICAL Ret = KeTryToAcquireQueuedSpinLock(CheckData->QueueNumber, &CheckData->Irql);
152  CheckData->IsAcquired = TRUE;
153  ASSERT(Ret == FALSE || Ret == TRUE);
154  return (BOOLEAN)Ret;
155 }
#define TRUE
Definition: types.h:120
LOGICAL FASTCALL KeTryToAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, OUT PKIRQL OldIrql)
Definition: spinlock.c:192
unsigned char BOOLEAN
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

◆ START_TEST()

START_TEST ( KeSpinLock  )

Definition at line 324 of file KeSpinLock.c.

325 {
326  KSPIN_LOCK SpinLock = (KSPIN_LOCK)0x5555555555555555LL;
327  PKSPIN_LOCK pSpinLock = &SpinLock;
329  KIRQL OriginalIrqls[] = { PASSIVE_LEVEL, APC_LEVEL, DISPATCH_LEVEL, HIGH_LEVEL };
330  CHECK_DATA TestData[] =
331  {
332  { CheckLock, DISPATCH_LEVEL, AcquireNormal, ReleaseNormal, NULL, AcquireNoRaise, ReleaseNoLower, TryNoRaise },
333  { CheckLock, DISPATCH_LEVEL, AcquireExp, ReleaseExp, NULL, AcquireExpNoRaise, ReleaseExpNoLower, NULL },
334  /* TODO: this one is just weird!
335  { CheckLock, DISPATCH_LEVEL, AcquireNormal, ReleaseNormal, NULL, AcquireForDpc, ReleaseForDpc, NULL },*/
336  { CheckLock, DISPATCH_LEVEL, AcquireNormal, ReleaseNormal, NULL, AcquireInt, ReleaseInt, NULL },
337  { CheckLock, SynchIrql, AcquireSynch, ReleaseNormal, NULL, NULL, NULL, NULL },
338  { CheckQueueHandle, DISPATCH_LEVEL, AcquireInStackQueued, ReleaseInStackQueued, NULL, AcquireInStackNoRaise, ReleaseInStackNoRaise, NULL },
339  { CheckQueueHandle, SynchIrql, AcquireInStackSynch, ReleaseInStackQueued, NULL, NULL, NULL, NULL },
340  { CheckQueueHandle, DISPATCH_LEVEL, AcquireInStackQueued, ReleaseInStackQueued, NULL, AcquireInStackForDpc, ReleaseInStackForDpc, NULL },
341  { CheckQueue, DISPATCH_LEVEL, AcquireQueued, ReleaseQueued, TryQueued, NULL, NULL, NULL, LockQueuePfnLock },
342  { CheckQueue, SynchIrql, AcquireQueuedSynch, ReleaseQueued, TryQueuedSynch, NULL, NULL, NULL, LockQueuePfnLock },
343  };
344  int i, iIrql;
345  PKPRCB Prcb;
346 
347  pKeTryToAcquireSpinLockAtDpcLevel = KmtGetSystemRoutineAddress(L"KeTryToAcquireSpinLockAtDpcLevel");
348  pKeAcquireInStackQueuedSpinLockForDpc = KmtGetSystemRoutineAddress(L"KeAcquireInStackQueuedSpinLockForDpc");
349  pKeReleaseInStackQueuedSpinLockForDpc = KmtGetSystemRoutineAddress(L"KeReleaseInStackQueuedSpinLockForDpc");
350  pKeTestSpinLock = KmtGetSystemRoutineAddress(L"KeTestSpinLock");
351 
352  Prcb = KeGetCurrentPrcb();
353 
354  /* KeInitializeSpinLock */
355  memset(&SpinLock, 0x55, sizeof SpinLock);
358 
359  /* KeTestSpinLock */
360  if (!skip(pKeTestSpinLock != NULL, "KeTestSpinLock unavailable\n"))
361  {
362  ok_bool_true(pKeTestSpinLock(&SpinLock), "KeTestSpinLock returned");
363  SpinLock = 1;
364  ok_bool_false(pKeTestSpinLock(&SpinLock), "KeTestSpinLock returned");
365  SpinLock = 2;
366  ok_bool_false(pKeTestSpinLock(&SpinLock), "KeTestSpinLock returned");
367  SpinLock = (ULONG_PTR)-1;
368  ok_bool_false(pKeTestSpinLock(&SpinLock), "KeTestSpinLock returned");
369  SpinLock = (ULONG_PTR)1 << (sizeof(ULONG_PTR) * CHAR_BIT - 1);
370  ok_bool_false(pKeTestSpinLock(&SpinLock), "KeTestSpinLock returned");
371  SpinLock = 0;
372  ok_bool_true(pKeTestSpinLock(&SpinLock), "KeTestSpinLock returned");
373  }
374 
375  /* on UP none of the following functions actually looks at the spinlock! */
377  pSpinLock = NULL;
378 
379  for (i = 0; i < sizeof TestData / sizeof TestData[0]; ++i)
380  {
381  memset(&SpinLock, 0x55, sizeof SpinLock);
383  if (TestData[i].Check == CheckQueueHandle)
384  memset(&TestData[i].QueueHandle, 0x55, sizeof TestData[i].QueueHandle);
385  if (TestData[i].Check == CheckQueue)
386  {
387  TestData[i].Queue = &Prcb->LockQueue[TestData[i].QueueNumber];
388  TestData[i].UntouchedValue = NULL;
389  }
390  else
391  TestData[i].UntouchedValue = (PVOID)0x5555555555555555LL;
392 
393  for (iIrql = 0; iIrql < sizeof OriginalIrqls / sizeof OriginalIrqls[0]; ++iIrql)
394  {
395  if (KmtIsCheckedBuild && OriginalIrqls[iIrql] > DISPATCH_LEVEL)
396  continue;
397  KeRaiseIrql(OriginalIrqls[iIrql], &Irql);
398  TestData[i].OriginalIrql = OriginalIrqls[iIrql];
399  TestData[i].IsAcquired = FALSE;
400  TestSpinLock(pSpinLock, &TestData[i]);
401  KeLowerIrql(Irql);
402  }
403  }
404 
406 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1062
#define ok_eq_ulongptr(value, expected)
Definition: kmt_test.h:249
#define CHAR_BIT
Definition: urlcache.c:57
KSPIN_LOCK * PKSPIN_LOCK
Definition: env_spec_w32.h:73
_Out_ PKIRQL Irql
Definition: csq.h:179
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define ok_bool_false(value, desc)
Definition: kmt_test.h:257
UCHAR KIRQL
Definition: env_spec_w32.h:591
BOOLEAN KmtIsCheckedBuild
#define ok_bool_true(value, desc)
Definition: kmt_test.h:256
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int Check()
Definition: movefile.cpp:196
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
smooth NULL
Definition: ftsmooth.c:416
VOID KmtSetIrql(IN KIRQL NewIrql)
BOOLEAN KmtIsMultiProcessorBuild
void * PVOID
Definition: retypes.h:9
#define IPI_LEVEL
Definition: env_spec_w32.h:701
BOOLEAN TryNoRaise(PKSPIN_LOCK SpinLock, PCHECK_DATA CheckData)
Definition: KeSpinLock.c:161
PVOID KmtGetSystemRoutineAddress(IN PCWSTR RoutineName)
static const WCHAR L[]
Definition: oid.c:1250
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define skip(...)
Definition: atltest.h:64
#define ULONG_PTR
Definition: config.h:101
KSPIN_LOCK_QUEUE LockQueue[LockQueueMaximumLock]
Definition: ketypes.h:623
BOOLEAN TryQueuedSynch(PKSPIN_LOCK SpinLock, PCHECK_DATA CheckData)
Definition: KeSpinLock.c:156
static VOID TestSpinLock(PKSPIN_LOCK SpinLock, PCHECK_DATA CheckData)
Definition: KeSpinLock.c:243
#define memset(x, y, z)
Definition: compat.h:39
#define APC_LEVEL
Definition: env_spec_w32.h:695

◆ TestSpinLock()

static VOID TestSpinLock ( PKSPIN_LOCK  SpinLock,
PCHECK_DATA  CheckData 
)
static

Definition at line 243 of file KeSpinLock.c.

246 {
247  static INT Run = 0;
248  trace("Test SpinLock run %d\n", Run++);
249 
250  ok_irql(CheckData->OriginalIrql);
251 
252  if (SpinLock)
254  CheckData->Acquire(SpinLock, CheckData);
255  CheckSpinLock(SpinLock, CheckData, 1);
256  CheckData->Release(SpinLock, CheckData);
257  CheckSpinLock(SpinLock, CheckData, 0);
258 
259  if (CheckData->TryAcquire)
260  {
261  CheckSpinLock(SpinLock, CheckData, 0);
262  ok_bool_true(CheckData->TryAcquire(SpinLock, CheckData), "TryAcquire returned");
263  CheckSpinLock(SpinLock, CheckData, 1);
264  if (!KmtIsCheckedBuild)
265  {
266  /* SPINLOCK_ALREADY_OWNED on checked build */
267  ok_bool_true(CheckData->TryAcquire(SpinLock, CheckData), "TryAcquire returned");
268  /* even a failing acquire sets irql */
269  ok_eq_uint(CheckData->Irql, CheckData->IrqlWhenAcquired);
270  CheckData->Irql = CheckData->OriginalIrql;
271  CheckSpinLock(SpinLock, CheckData, 1);
272  }
273  CheckData->Release(SpinLock, CheckData);
274  CheckSpinLock(SpinLock, CheckData, 0);
275  }
276 
277  if (CheckData->AcquireNoRaise &&
278  (CheckData->OriginalIrql >= DISPATCH_LEVEL || !KmtIsCheckedBuild) &&
279  (CheckData->AcquireNoRaise != AcquireInStackForDpc ||
280  !skip(pKeAcquireInStackQueuedSpinLockForDpc &&
281  pKeReleaseInStackQueuedSpinLockForDpc, "No DPC spinlock functions\n")))
282  {
283  /* acquire/release without irql change */
284  CheckData->AcquireNoRaise(SpinLock, CheckData);
285  CheckSpinLock(SpinLock, CheckData, 1);
286  CheckData->ReleaseNoLower(SpinLock, CheckData);
287  CheckSpinLock(SpinLock, CheckData, 0);
288 
289  /* acquire without raise, but normal release */
290  CheckData->AcquireNoRaise(SpinLock, CheckData);
291  CheckSpinLock(SpinLock, CheckData, 1);
292  CheckData->Release(SpinLock, CheckData);
293  CheckSpinLock(SpinLock, CheckData, 0);
294 
295  /* acquire normally but release without lower */
296  CheckData->Acquire(SpinLock, CheckData);
297  CheckSpinLock(SpinLock, CheckData, 1);
298  CheckData->ReleaseNoLower(SpinLock, CheckData);
299  CheckSpinLock(SpinLock, CheckData, 0);
300  CheckData->IsAcquired = FALSE;
301  KmtSetIrql(CheckData->OriginalIrql);
302 
303  if (CheckData->TryAcquireNoRaise &&
304  !skip(pKeTryToAcquireSpinLockAtDpcLevel != NULL, "KeTryToAcquireSpinLockAtDpcLevel unavailable\n"))
305  {
306  CheckSpinLock(SpinLock, CheckData, 0);
307  ok_bool_true(CheckData->TryAcquireNoRaise(SpinLock, CheckData), "TryAcquireNoRaise returned");
308  CheckSpinLock(SpinLock, CheckData, 1);
309  if (!KmtIsCheckedBuild)
310  {
311  ok_bool_true(CheckData->TryAcquireNoRaise(SpinLock, CheckData), "TryAcquireNoRaise returned");
312  CheckSpinLock(SpinLock, CheckData, 1);
313  }
314  CheckData->ReleaseNoLower(SpinLock, CheckData);
315  CheckSpinLock(SpinLock, CheckData, 0);
316  }
317  }
318 
319  ok_irql(CheckData->OriginalIrql);
320  /* make sure we survive this in case of error */
321  KmtSetIrql(CheckData->OriginalIrql);
322 }
Definition: bidi.c:477
#define ok_eq_ulongptr(value, expected)
Definition: kmt_test.h:249
#define CheckSpinLock(SpinLock, CheckData, Value)
Definition: KeSpinLock.c:216
int32_t INT
Definition: typedefs.h:56
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
BOOLEAN KmtIsCheckedBuild
#define ok_bool_true(value, desc)
Definition: kmt_test.h:256
smooth NULL
Definition: ftsmooth.c:416
VOID KmtSetIrql(IN KIRQL NewIrql)
#define trace
Definition: atltest.h:70
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define skip(...)
Definition: atltest.h:64
#define ok_eq_uint(value, expected)
Definition: kmt_test.h:239

Referenced by START_TEST().

◆ TryNoRaise()

BOOLEAN TryNoRaise ( PKSPIN_LOCK  SpinLock,
PCHECK_DATA  CheckData 
)

Definition at line 161 of file KeSpinLock.c.

161  {
162  BOOLEAN Ret = pKeTryToAcquireSpinLockAtDpcLevel(SpinLock);
163  return Ret;
164 }
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
unsigned char BOOLEAN

Referenced by START_TEST().

◆ TryQueuedSynch()

BOOLEAN TryQueuedSynch ( PKSPIN_LOCK  SpinLock,
PCHECK_DATA  CheckData 
)

Definition at line 156 of file KeSpinLock.c.

156  {
157  BOOLEAN Ret = KeTryToAcquireQueuedSpinLockRaiseToSynch(CheckData->QueueNumber, &CheckData->Irql);
158  CheckData->IsAcquired = TRUE;
159  return Ret;
160 }
BOOLEAN FASTCALL KeTryToAcquireQueuedSpinLockRaiseToSynch(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN PKIRQL OldIrql)
Definition: spinlock.c:177
#define TRUE
Definition: types.h:120
unsigned char BOOLEAN

Referenced by START_TEST().