[jit] Avoid licm for volatile variables, ssa ignores them so we can't detect whenever...
[mono.git] / mono / io-layer / critical-sections.h
index ae94cfcf0e90672d7300eddc0d7555bbf90beee5..aa7bad248be58a1c2d255d99a110cf80c4595370 100644 (file)
@@ -13,7 +13,7 @@
 #include <glib.h>
 #include <pthread.h>
 
-#include "mono-mutex.h"
+#include <mono/utils/mono-mutex.h>
 
 G_BEGIN_DECLS
 
@@ -30,8 +30,22 @@ extern gboolean InitializeCriticalSectionAndSpinCount(WapiCriticalSection *secti
 extern void DeleteCriticalSection(WapiCriticalSection *section);
 extern guint32 SetCriticalSectionSpinCount(WapiCriticalSection *section, guint32 spincount);
 extern gboolean TryEnterCriticalSection(WapiCriticalSection *section);
-extern void EnterCriticalSection(WapiCriticalSection *section);
-extern void LeaveCriticalSection(WapiCriticalSection *section);
+
+/* These two are perf critical so avoid the wrapper function */
+
+#define EnterCriticalSection(section) do { \
+       int ret = mono_mutex_lock(&(section)->mutex);    \
+       if (ret != 0) \
+               g_warning ("Bad call to mono_mutex_lock result %d", ret); \
+       g_assert (ret == 0);                             \
+} while (0)
+
+#define LeaveCriticalSection(section) do { \
+       int ret = mono_mutex_unlock(&(section)->mutex);      \
+       if (ret != 0) \
+               g_warning ("Bad call to mono_mutex_unlock result %d", ret); \
+       g_assert (ret == 0);    \
+} while (0)
 
 G_END_DECLS