Windows: X86 DEBUG Interlocked Or and And
authorJeffrey Altman <jaltman@your-file-system.com>
Fri, 6 Jul 2012 01:13:21 +0000 (21:13 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Fri, 6 Jul 2012 04:23:14 +0000 (21:23 -0700)
X86 DEBUG builds do not have a native InterlockedOr or
InterlockedAnd.  Therefore, we must provide our own.

Change-Id: I48f86feb58c96e327500e802340a213c0f70d5e4
Reviewed-on: http://gerrit.openafs.org/7726
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/client_osi/osibasel.c

index 8939324..eb00b15 100644 (file)
@@ -52,6 +52,43 @@ osi_SetLockOrderValidation(int on)
     lockOrderValidation = (BOOLEAN)on;
 }
 
+#ifdef DEBUG
+#ifdef _M_IX86
+static __inline void
+osi_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);
+}
+
+static __inline void
+osi_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);
+}
+
+#define _InterlockedOr   osi_InterlockedOr
+#define _InterlockedAnd  osi_InterlockedAnd
+#endif
+#endif
+
 static osi_lock_ref_t *
 lock_GetLockRef(void * lockp, char type)
 {