Windows: implement InterlockedAnd/Or for X86 Debug
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 9 Aug 2011 21:25:50 +0000 (17:25 -0400)
committerJeffrey Altman <jaltman@openafs.org>
Thu, 11 Aug 2011 06:12:38 +0000 (23:12 -0700)
Change-Id: I56b3f9534daf0cd152eeea293b1a357d062b9166
Reviewed-on: http://gerrit.openafs.org/5191
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>

src/WINNT/afsd/cm_utils.h

index a7fafba..8a3440c 100644 (file)
@@ -110,4 +110,41 @@ extern void cm_utilsInit(void);
 
 extern void cm_utilsCleanup(void);
 
+__inline void
+cm_InterlockedAnd(LONG * pdest, LONG value)
+{
+    LONG orig, current, new;
+
+    current = *pdest;
+
+    do
+    {
+        orig = current;
+        new = orig & value;
+        current = _InterlockedCompareExchange(pdest, new, orig);
+    } while (orig != current);
+}
+
+__inline void
+cm_InterlockedOr(LONG * pdest, LONG value)
+{
+    LONG orig, current, new;
+
+    current = *pdest;
+
+    do
+    {
+        orig = current;
+        new = orig | value;
+        current = _InterlockedCompareExchange(pdest, new, orig);
+    } while (orig != current);
+}
+
+#ifdef DEBUG
+#ifdef _M_IX86
+#define _InterlockedOr   cm_InterlockedOr
+#define _InterlockedAnd  cm_InterlockedAnd
+#endif
+#endif
+
 #endif /*  OPENAFS_WINNT_AFSD_CM_UTILS_H */