Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

tlock.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1989 Microsoft Corporation 00004 00005 Module Name: 00006 00007 tlock.c 00008 00009 Abstract: 00010 00011 Test program for exinterlockedincrement/decrement routines 00012 00013 Environment: 00014 00015 This program can either be compiled into a kernel mode test, 00016 OR you can link intrloc2.obj or i386\intrlock.obj (or whatever) 00017 into it and run it in user mode. 00018 00019 Author: 00020 00021 Bryan Willman (bryanwi) 3-Aug-90 00022 00023 Revision History: 00024 00025 00026 --*/ 00027 00028 #include "exp.h" 00029 00030 00031 main() 00032 { 00033 INTERLOCKED_RESULT RetVal; 00034 LONG SpinVar; // talk about a hack... 00035 LONG LongVar; 00036 SHORT ShortVar; 00037 KSPIN_LOCK Lock; 00038 00039 Lock = &SpinVar; 00040 00041 LongVar = 0; 00042 ShortVar = 0; 00043 00044 RetVal = ExInterlockedDecrementLong(&LongVar, &Lock); 00045 if ((RetVal != ResultNegative) || 00046 (LongVar != -1)) { 00047 DbgPrint("t&Lock failure #L1\n"); 00048 } 00049 00050 RetVal = ExInterlockedDecrementLong(&LongVar, &Lock); 00051 if ((RetVal != ResultNegative) || 00052 (LongVar != -2)) { 00053 DbgPrint("t&Lock failure #L2\n"); 00054 } 00055 00056 RetVal = ExInterlockedIncrementLong(&LongVar, &Lock); 00057 if ((RetVal != ResultNegative) || 00058 (LongVar != -1)) { 00059 DbgPrint("t&Lock failure #L3\n"); 00060 } 00061 00062 RetVal = ExInterlockedIncrementLong(&LongVar, &Lock); 00063 if ((RetVal != ResultZero) || 00064 (LongVar != 0)) { 00065 DbgPrint("t&Lock failure #L4\n"); 00066 } 00067 00068 RetVal = ExInterlockedIncrementLong(&LongVar, &Lock); 00069 if ((RetVal != ResultPositive) || 00070 (LongVar != 1)) { 00071 DbgPrint("t&Lock failure #L5\n"); 00072 } 00073 00074 RetVal = ExInterlockedIncrementLong(&LongVar, &Lock); 00075 if ((RetVal != ResultPositive) || 00076 (LongVar != 2)) { 00077 DbgPrint("t&Lock failure #L6\n"); 00078 } 00079 00080 RetVal = ExInterlockedDecrementLong(&LongVar, &Lock); 00081 if ((RetVal != ResultPositive) || 00082 (LongVar != 1)) { 00083 DbgPrint("t&Lock failure #L7\n"); 00084 } 00085 00086 RetVal = ExInterlockedDecrementLong(&LongVar, &Lock); 00087 if ((RetVal != ResultZero) || 00088 (LongVar != 0)) { 00089 DbgPrint("t&Lock failure #L8\n"); 00090 } 00091 }

Generated on Sat May 15 19:41:59 2004 for test by doxygen 1.3.7