Change SPIN_LOCK_ACQUIRED to 1 and SPIN_LOCK_RELEASED to 2 according to MWG.
[mirror_edk2.git] / MdePkg / Library / BaseLib / Synchronization.c
index df39586..c04edfc 100644 (file)
@@ -14,8 +14,8 @@
 \r
 **/\r
 \r
-#define SPIN_LOCK_RELEASED          ((SPIN_LOCK)0)\r
-#define SPIN_LOCK_ACQUIRED          ((SPIN_LOCK)-1)\r
+#define SPIN_LOCK_RELEASED          ((SPIN_LOCK)1)\r
+#define SPIN_LOCK_ACQUIRED          ((SPIN_LOCK)2)\r
 \r
 UINT32\r
 EFIAPI\r
@@ -94,7 +94,7 @@ InitializeSpinLock (
   )\r
 {\r
   ASSERT (SpinLock != NULL);\r
-  *SpinLock = 0;\r
+  *SpinLock = SPIN_LOCK_RELEASED;\r
   return SpinLock;\r
 }\r
 \r
@@ -178,6 +178,7 @@ AcquireSpinLockOrFail (
   )\r
 {\r
   ASSERT (SpinLock != NULL);\r
+  ASSERT (*SpinLock == SPIN_LOCK_ACQUIRED || *SpinLock == SPIN_LOCK_RELEASED);\r
   return (BOOLEAN)(\r
            InterlockedCompareExchangePointer (\r
              (VOID**)SpinLock,\r
@@ -208,7 +209,8 @@ ReleaseSpinLock (
   )\r
 {\r
   ASSERT (SpinLock != NULL);\r
-  *SpinLock = 0;\r
+  ASSERT (*SpinLock == SPIN_LOCK_ACQUIRED || *SpinLock == SPIN_LOCK_RELEASED);\r
+  *SpinLock = SPIN_LOCK_RELEASED;\r
   return SpinLock;\r
 }\r
 \r