Merge pull request #5415 from kumpera/wasm-support
[mono.git] / mono / utils / atomic.h
index dca6170a1a1e72cfe2f03cc77a5ce9a2895e1d6d..a3dd65a4dc28570fdf8d34881643300c93b8b988 100755 (executable)
@@ -1,5 +1,6 @@
-/*
- * atomic.h:  Atomic operations
+/**
+ * \file
+ * Atomic operations
  *
  * Author:
  *     Dick Porter (dick@ximian.com)
@@ -457,4 +458,19 @@ extern void InterlockedWritePointer(volatile gpointer *dst, gpointer val);
 
 #endif
 
+#if SIZEOF_VOID_P == 4
+#define InterlockedAddP(p,add) InterlockedAdd ((volatile gint32*)p, (gint32)add)
+#else
+#define InterlockedAddP(p,add) InterlockedAdd64 ((volatile gint64*)p, (gint64)add)
+#endif
+
+/* The following functions cannot be found on any platform, and thus they can be declared without further existence checks */
+
+static inline void
+InterlockedWriteBool (volatile gboolean *dest, gboolean val)
+{
+       /* both, gboolean and gint32, are int32_t; the purpose of these casts is to make things explicit */
+       InterlockedWrite ((volatile gint32 *)dest, (gint32)val);
+}
+
 #endif /* _WAPI_ATOMIC_H_ */