summaryrefslogtreecommitdiffstats
path: root/private/ntos/ex/tlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'private/ntos/ex/tlock.c')
-rw-r--r--private/ntos/ex/tlock.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/private/ntos/ex/tlock.c b/private/ntos/ex/tlock.c
new file mode 100644
index 000000000..f25bc0c29
--- /dev/null
+++ b/private/ntos/ex/tlock.c
@@ -0,0 +1,91 @@
+/*++
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ tlock.c
+
+Abstract:
+
+ Test program for exinterlockedincrement/decrement routines
+
+Environment:
+
+ This program can either be compiled into a kernel mode test,
+ OR you can link intrloc2.obj or i386\intrlock.obj (or whatever)
+ into it and run it in user mode.
+
+Author:
+
+ Bryan Willman (bryanwi) 3-Aug-90
+
+Revision History:
+
+
+--*/
+
+#include "exp.h"
+
+
+main()
+{
+ INTERLOCKED_RESULT RetVal;
+ LONG SpinVar; // talk about a hack...
+ LONG LongVar;
+ SHORT ShortVar;
+ KSPIN_LOCK Lock;
+
+ Lock = &SpinVar;
+
+ LongVar = 0;
+ ShortVar = 0;
+
+ RetVal = ExInterlockedDecrementLong(&LongVar, &Lock);
+ if ((RetVal != ResultNegative) ||
+ (LongVar != -1)) {
+ DbgPrint("t&Lock failure #L1\n");
+ }
+
+ RetVal = ExInterlockedDecrementLong(&LongVar, &Lock);
+ if ((RetVal != ResultNegative) ||
+ (LongVar != -2)) {
+ DbgPrint("t&Lock failure #L2\n");
+ }
+
+ RetVal = ExInterlockedIncrementLong(&LongVar, &Lock);
+ if ((RetVal != ResultNegative) ||
+ (LongVar != -1)) {
+ DbgPrint("t&Lock failure #L3\n");
+ }
+
+ RetVal = ExInterlockedIncrementLong(&LongVar, &Lock);
+ if ((RetVal != ResultZero) ||
+ (LongVar != 0)) {
+ DbgPrint("t&Lock failure #L4\n");
+ }
+
+ RetVal = ExInterlockedIncrementLong(&LongVar, &Lock);
+ if ((RetVal != ResultPositive) ||
+ (LongVar != 1)) {
+ DbgPrint("t&Lock failure #L5\n");
+ }
+
+ RetVal = ExInterlockedIncrementLong(&LongVar, &Lock);
+ if ((RetVal != ResultPositive) ||
+ (LongVar != 2)) {
+ DbgPrint("t&Lock failure #L6\n");
+ }
+
+ RetVal = ExInterlockedDecrementLong(&LongVar, &Lock);
+ if ((RetVal != ResultPositive) ||
+ (LongVar != 1)) {
+ DbgPrint("t&Lock failure #L7\n");
+ }
+
+ RetVal = ExInterlockedDecrementLong(&LongVar, &Lock);
+ if ((RetVal != ResultZero) ||
+ (LongVar != 0)) {
+ DbgPrint("t&Lock failure #L8\n");
+ }
+}