[mono/mono] [2 commits] 93edc5e8: Add separate icall for System.Threading.VolatileRead (object&).

"alexrp ([email protected])" <[email protected]>
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <00000141e66fb6ef-836c6f92-ba2c-42e7-b3c2-bb41ea00ecdb-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/50d4232bbe8a...bc55637bd102

   Commit: 93edc5e860dfb3bf455514488cb15e5c5989de7d
   Author: Alex Rønne Petersen <[email protected]> 
     Date: 2013-10-23 17:47:19 GMT
      URL: https://github.com/mono/mono/commit/93edc5e860dfb3bf455514488cb15e5c5989de7d

Add separate icall for System.Threading.VolatileRead (object&).

Previously, the icall that was used for the IntPtr overload was
used for this overload as well. Having a separate icall is less
error-prone for future modification as the two types are no longer
conflated.

Changed paths:
  M mono/metadata/icall-def.h
  M mono/metadata/threads-types.h
  M mono/metadata/threads.c

Modified: mono/metadata/icall-def.h
===================================================================
@@ -890,7 +890,7 @@
 ICALL(THREAD_29, "VolatileRead(int16&)", ves_icall_System_Threading_Thread_VolatileRead2)
 ICALL(THREAD_30, "VolatileRead(intptr&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr)
 ICALL(THREAD_31, "VolatileRead(long&)", ves_icall_System_Threading_Thread_VolatileRead8)
-ICALL(THREAD_32, "VolatileRead(object&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr)
+ICALL(THREAD_32, "VolatileRead(object&)", ves_icall_System_Threading_Thread_VolatileReadObject)
 ICALL(THREAD_33, "VolatileRead(sbyte&)", ves_icall_System_Threading_Thread_VolatileRead1)
 ICALL(THREAD_34, "VolatileRead(single&)", ves_icall_System_Threading_Thread_VolatileReadFloat)
 ICALL(THREAD_35, "VolatileRead(uint&)", ves_icall_System_Threading_Thread_VolatileRead4)

Modified: mono/metadata/threads-types.h
===================================================================
@@ -140,6 +140,7 @@ gpointer mono_create_thread (WapiSecurityAttributes *security,
 gint32 ves_icall_System_Threading_Thread_VolatileRead4 (void *ptr) MONO_INTERNAL;
 gint64 ves_icall_System_Threading_Thread_VolatileRead8 (void *ptr) MONO_INTERNAL;
 void * ves_icall_System_Threading_Thread_VolatileReadIntPtr (void *ptr) MONO_INTERNAL;
+void * ves_icall_System_Threading_Thread_VolatileReadObject (void *ptr) MONO_INTERNAL;
 double ves_icall_System_Threading_Thread_VolatileReadDouble (void *ptr) MONO_INTERNAL;
 float ves_icall_System_Threading_Thread_VolatileReadFloat (void *ptr) MONO_INTERNAL;
 

Modified: mono/metadata/threads.c
===================================================================
@@ -2433,6 +2433,14 @@ void mono_thread_stop (MonoThread *thread)
 	return (void *) tmp;
 }
 
+void *
+ves_icall_System_Threading_Thread_VolatileReadObject (void *ptr)
+{
+	volatile MonoObject *tmp;
+	mono_atomic_load_acquire (tmp, volatile MonoObject *, (volatile MonoObject **) ptr);
+	return (MonoObject *) tmp;
+}
+
 double
 ves_icall_System_Threading_Thread_VolatileReadDouble (void *ptr)
 {
@@ -2488,7 +2496,7 @@ void mono_thread_stop (MonoThread *thread)
 }
 
 void
-ves_icall_System_Threading_Thread_VolatileWriteObject (void *ptr, void *value)
+ves_icall_System_Threading_Thread_VolatileWriteObject (void *ptr, MonoObject *value)
 {
 	mono_gc_wbarrier_generic_store_atomic (ptr, value);
 }

   Commit: bc55637bd1025556e2734988408e4791401db7b7
   Author: Alex Rønne Petersen <[email protected]> 
     Date: 2013-10-23 17:47:19 GMT
      URL: https://github.com/mono/mono/commit/bc55637bd1025556e2734988408e4791401db7b7

Add more missing atomic functions for MinGW.

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

Modified: configure.in
===================================================================
@@ -2133,6 +2133,9 @@ else
 	AC_CHECK_FUNCS(GetProcessId)
 	AC_CHECK_DECLS(InterlockedExchange64, [], [], [[#include <windows.h>]])
 	AC_CHECK_DECLS(InterlockedCompareExchange64, [], [], [[#include <windows.h>]])
+	AC_CHECK_DECLS(InterlockedIncrement64, [], [], [[#include <windows.h>]])
+	AC_CHECK_DECLS(InterlockedAdd, [], [], [[#include <windows.h>]])
+	AC_CHECK_DECLS(InterlockedAdd64, [], [], [[#include <windows.h>]])
 fi
 
 dnl socklen_t check

Modified: mono/utils/atomic.h
===================================================================
@@ -43,6 +43,38 @@ static inline gint64 InterlockedExchange64(volatile gint64 *val, gint64 new_val)
 }
 #endif
 
+/* mingw is missing InterlockedIncrement64 () from winbase.h */
+#if HAVE_DECL_INTERLOCKEDINCREMENT64==0
+static inline gint64 InterlockedIncrement64(volatile gint64 *val)
+{
+	return __sync_add_and_fetch (val, 1);
+}
+#endif
+
+/* mingw is missing InterlockedDecrement64 () from winbase.h */
+#if HAVE_DECL_INTERLOCKEDDECREMENT64==0
+static inline gint64 InterlockedDecrement64(volatile gint64 *val)
+{
+	return __sync_sub_and_fetch (val, 1);
+}
+#endif
+
+/* mingw is missing InterlockedAdd () from winbase.h */
+#if HAVE_DECL_INTERLOCKEDADD==0
+static inline gint32 InterlockedAdd(volatile gint32 *dest, gint32 add)
+{
+	return __sync_add_and_fetch (dest, add);
+}
+#endif
+
+/* mingw is missing InterlockedAdd64 () from winbase.h */
+#if HAVE_DECL_INTERLOCKEDADD64==0
+static inline gint64 InterlockedAdd64(volatile gint64 *dest, gint64 add)
+{
+	return __sync_add_and_fetch (dest, add);
+}
+#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.