]> sourceware.org Git - newlib-cygwin.git/blobdiff - winsup/cygwin/winbase.h
* Merge in cygwin-64bit-branch.
[newlib-cygwin.git] / winsup / cygwin / winbase.h
index d9c53cfbaa5c5493391b6a390157d1ff27497f43..666f74a2d2f20e3ef8ac7dcb5abbe60f1a3d1af2 100644 (file)
@@ -11,7 +11,6 @@ details. */
 #ifndef _WINBASE2_H
 #define _WINBASE2_H
 
-#ifndef __x86_64__
 extern __inline__ LONG
 ilockcmpexch (volatile LONG *t, LONG v, LONG c)
 {
@@ -29,7 +28,30 @@ ilockcmpexch (volatile LONG *t, LONG v, LONG c)
 #undef InterlockedCompareExchange
 #define InterlockedCompareExchange ilockcmpexch
 #undef InterlockedCompareExchangePointer
+
+#ifdef __x86_64__
+extern __inline__ LONGLONG
+ilockcmpexch64 (volatile LONGLONG *t, LONGLONG v, LONGLONG c)
+{
+  return
+  ({
+    register LONGLONG ret __asm ("%rax");
+    __asm __volatile ("lock cmpxchgq %2, %1"
+       : "=a" (ret), "=m" (*t)
+       : "r" (v), "m" (*t), "0" (c)
+       : "memory");
+    ret;
+  });
+}
+
+#define InterlockedCompareExchange64 ilockcmpexch64
+#define InterlockedCompareExchangePointer(d,e,c) \
+    (PVOID)InterlockedCompareExchange64((LONGLONG volatile *)(d),(LONGLONG)(e),(LONGLONG)(c))
+
+#else
+
 #define InterlockedCompareExchangePointer(d,e,c) \
     (PVOID)InterlockedCompareExchange((LONG volatile *)(d),(LONG)(e),(LONG)(c))
+
 #endif /* !__x86_64 */
 #endif /*_WINBASE2_H*/
This page took 0.022608 seconds and 5 git commands to generate.