[mono/mono] 80f7e1f1: Add InterlockedExchange64 () based on GCC intrinsics for MinGW.

"alexrp ([email protected])" <[email protected]>
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <00000141e56d5bfd-bbf7d76c-7c60-47aa-93d4-647ba00ac738-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/f9bbb7c58bed...80f7e1f15b33

   Commit: 80f7e1f15b33826a6145899497954297633cee92
   Author: Alex Rønne Petersen <[email protected]> 
     Date: 2013-10-23 13:06:09 GMT
      URL: https://github.com/mono/mono/commit/80f7e1f15b33826a6145899497954297633cee92

Add InterlockedExchange64 () based on GCC intrinsics for MinGW.

As with InterlockedCompareExchange64, MinGW appears to lack this
one from its Windows headers.

Changed paths:
  M configure.in
  M mono/utils/atomic.h

Modified: configure.in
===================================================================
@@ -2131,6 +2131,7 @@ else
 		])
 	])
 	AC_CHECK_FUNCS(GetProcessId)
+	AC_CHECK_DECLS(InterlockedExchange64, [], [], [[#include <windows.h>]])
 	AC_CHECK_DECLS(InterlockedCompareExchange64, [], [], [[#include <windows.h>]])
 fi
 

Modified: mono/utils/atomic.h
===================================================================
@@ -31,6 +31,18 @@ static inline gint64 InterlockedCompareExchange64(volatile gint64 *dest, gint64
 }
 #endif
 
+/* mingw is missing InterlockedExchange64 () from winbase.h */
+#if HAVE_DECL_INTERLOCKEDEXCHANGE64==0
+static inline gint64 InterlockedExchange64(volatile gint64 *val, gint64 new_val)
+{
+	gint64 old_val;
+	do {
+		old_val = *val;
+	} while (InterlockedCompareExchange64 (val, new_val, old_val) != old_val);
+	return old_val;
+}
+#endif
+
 /* And now for some dirty hacks... The Windows API doesn't
  * provide any useful primitives for this (other than getting
  * into architecture-specific madness), so use CAS. */
_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.