+#include <mono/utils/mono-threads.h>
+
+
+#define BEGIN_CRITICAL_SECTION do { \
+ MonoThreadInfo *__info = mono_thread_info_current_unchecked (); \
+ if (__info) __info->inside_critical_region = TRUE; \
+
+#define END_CRITICAL_SECTION \
+ if (__info) __info->inside_critical_region = FALSE; \
+} while (0) \