Fix shutdown race between mono_thread_manage and mono_thread_detach_internal. (#5599)
[mono.git] / mono / utils / unlocked.h
index 19114ac61051812767258e9aee684f6fc99efe57..8a1e98bb2ee7068e6246e130b186c16abcca09d3 100644 (file)
@@ -20,6 +20,8 @@
 
 #if MONO_HAS_CLANG_THREAD_SANITIZER
 #define MONO_UNLOCKED_ATTRS MONO_NO_SANITIZE_THREAD MONO_NEVER_INLINE static
+#elif defined(_MSC_VER)
+#define MONO_UNLOCKED_ATTRS MONO_ALWAYS_INLINE static
 #else
 #define MONO_UNLOCKED_ATTRS MONO_ALWAYS_INLINE static inline
 #endif
@@ -31,6 +33,27 @@ UnlockedIncrement (gint32 *val)
        return ++*val;
 }
 
+MONO_UNLOCKED_ATTRS
+gint64
+UnlockedIncrement64 (gint64 *val)
+{
+       return ++*val;
+}
+
+MONO_UNLOCKED_ATTRS
+gint64
+UnlockedDecrement64 (gint64 *val)
+{
+       return --*val;
+}
+
+MONO_UNLOCKED_ATTRS
+gint32
+UnlockedDecrement (gint32 *val)
+{
+       return --*val;
+}
+
 MONO_UNLOCKED_ATTRS
 gint32
 UnlockedAdd (gint32 *dest, gint32 add)
@@ -45,6 +68,13 @@ UnlockedAdd64 (gint64 *dest, gint64 add)
        return *dest += add;
 }
 
+MONO_UNLOCKED_ATTRS
+gdouble
+UnlockedAddDouble (gdouble *dest, gdouble add)
+{
+       return *dest += add;
+}
+
 MONO_UNLOCKED_ATTRS
 gint64
 UnlockedSubtract64 (gint64 *dest, gint64 sub)
@@ -59,6 +89,20 @@ UnlockedWrite (gint32 *dest, gint32 val)
        *dest = val;
 }
 
+MONO_UNLOCKED_ATTRS
+void
+UnlockedWrite64 (gint64 *dest, gint64 val)
+{
+       *dest = val;
+}
+
+MONO_UNLOCKED_ATTRS
+void
+UnlockedWriteBool (gboolean *dest, gboolean val)
+{
+       *dest = val;
+}
+
 MONO_UNLOCKED_ATTRS
 gint32
 UnlockedRead (gint32 *src)
@@ -73,4 +117,18 @@ UnlockedRead64 (gint64 *src)
        return *src;
 }
 
+MONO_UNLOCKED_ATTRS
+gboolean
+UnlockedReadBool (gboolean *src)
+{
+       return *src;
+}
+
+MONO_UNLOCKED_ATTRS
+gpointer
+UnlockedReadPointer (volatile gpointer *src)
+{
+       return *src;
+}
+
 #endif /* _UNLOCKED_H_ */