Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.0 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. tlock.c
  5. Abstract:
  6. Test program for exinterlockedincrement/decrement routines
  7. Environment:
  8. This program can either be compiled into a kernel mode test,
  9. OR you can link intrloc2.obj or i386\intrlock.obj (or whatever)
  10. into it and run it in user mode.
  11. Author:
  12. Bryan Willman (bryanwi) 3-Aug-90
  13. Revision History:
  14. --*/
  15. #include "exp.h"
  16. main()
  17. {
  18. INTERLOCKED_RESULT RetVal;
  19. LONG SpinVar; // talk about a hack...
  20. LONG LongVar;
  21. SHORT ShortVar;
  22. KSPIN_LOCK Lock;
  23. Lock = &SpinVar;
  24. LongVar = 0;
  25. ShortVar = 0;
  26. RetVal = ExInterlockedDecrementLong(&LongVar, &Lock);
  27. if ((RetVal != ResultNegative) ||
  28. (LongVar != -1)) {
  29. DbgPrint("t&Lock failure #L1\n");
  30. }
  31. RetVal = ExInterlockedDecrementLong(&LongVar, &Lock);
  32. if ((RetVal != ResultNegative) ||
  33. (LongVar != -2)) {
  34. DbgPrint("t&Lock failure #L2\n");
  35. }
  36. RetVal = ExInterlockedIncrementLong(&LongVar, &Lock);
  37. if ((RetVal != ResultNegative) ||
  38. (LongVar != -1)) {
  39. DbgPrint("t&Lock failure #L3\n");
  40. }
  41. RetVal = ExInterlockedIncrementLong(&LongVar, &Lock);
  42. if ((RetVal != ResultZero) ||
  43. (LongVar != 0)) {
  44. DbgPrint("t&Lock failure #L4\n");
  45. }
  46. RetVal = ExInterlockedIncrementLong(&LongVar, &Lock);
  47. if ((RetVal != ResultPositive) ||
  48. (LongVar != 1)) {
  49. DbgPrint("t&Lock failure #L5\n");
  50. }
  51. RetVal = ExInterlockedIncrementLong(&LongVar, &Lock);
  52. if ((RetVal != ResultPositive) ||
  53. (LongVar != 2)) {
  54. DbgPrint("t&Lock failure #L6\n");
  55. }
  56. RetVal = ExInterlockedDecrementLong(&LongVar, &Lock);
  57. if ((RetVal != ResultPositive) ||
  58. (LongVar != 1)) {
  59. DbgPrint("t&Lock failure #L7\n");
  60. }
  61. RetVal = ExInterlockedDecrementLong(&LongVar, &Lock);
  62. if ((RetVal != ResultZero) ||
  63. (LongVar != 0)) {
  64. DbgPrint("t&Lock failure #L8\n");
  65. }
  66. }