#include <mono/utils/mono-io-portability.h>
#include <mono/utils/mono-digest.h>
#include <mono/utils/bsearch.h>
+#include <mono/utils/mono-mutex.h>
#if defined (HOST_WIN32)
#include <windows.h>
#endif /* DISABLE_ICALL_TABLES */
+static mono_mutex_t icall_mutex;
static GHashTable *icall_hash = NULL;
static GHashTable *jit_icall_hash_name = NULL;
static GHashTable *jit_icall_hash_addr = NULL;
#endif
icall_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ mono_mutex_init (&icall_mutex);
+}
+
+static void
+mono_icall_lock (void)
+{
+ mono_locks_mutex_acquire (&icall_mutex, IcallLock);
+}
+
+static void
+mono_icall_unlock (void)
+{
+ mono_locks_mutex_release (&icall_mutex, IcallLock);
}
void
g_hash_table_destroy (icall_hash);
g_hash_table_destroy (jit_icall_hash_name);
g_hash_table_destroy (jit_icall_hash_addr);
+ mono_mutex_destroy (&icall_mutex);
}
void
mono_add_internal_call (const char *name, gconstpointer method)
{
- mono_loader_lock ();
+ mono_icall_lock ();
g_hash_table_insert (icall_hash, g_strdup (name), (gpointer) method);
- mono_loader_unlock ();
+ mono_icall_unlock ();
}
#ifndef DISABLE_ICALL_TABLES
sigstart [siglen + 2] = 0;
g_free (tmpsig);
- mono_loader_lock ();
+ mono_icall_lock ();
res = g_hash_table_lookup (icall_hash, mname);
if (res) {
- mono_loader_unlock ();
+ mono_icall_unlock ();;
return res;
}
/* try without signature */
*sigstart = 0;
res = g_hash_table_lookup (icall_hash, mname);
if (res) {
- mono_loader_unlock ();
+ mono_icall_unlock ();
return res;
}
#ifdef DISABLE_ICALL_TABLES
- mono_loader_unlock ();
+ mono_icall_unlock ();
/* Fail only when the result is actually used */
/* mono_marshal_get_native_wrapper () depends on this */
if (method->klass == mono_defaults.string_class && !strcmp (method->name, ".ctor"))
#else
/* it wasn't found in the static call tables */
if (!imap) {
- mono_loader_unlock ();
+ mono_icall_unlock ();
return NULL;
}
res = find_method_icall (imap, sigstart - mlen);
if (res) {
- mono_loader_unlock ();
+ mono_icall_unlock ();
return res;
}
/* try _with_ signature */
*sigstart = '(';
res = find_method_icall (imap, sigstart - mlen);
if (res) {
- mono_loader_unlock ();
+ mono_icall_unlock ();
return res;
}
g_print ("If you see other errors or faults after this message they are probably related\n");
g_print ("and you need to fix your mono install first.\n");
- mono_loader_unlock ();
+ mono_icall_unlock ();
return NULL;
#endif
MonoJitICallInfo *info;
g_assert (jit_icall_hash_name);
- mono_loader_lock ();
+ mono_icall_lock ();
info = g_hash_table_lookup (jit_icall_hash_name, name);
- mono_loader_unlock ();
+ mono_icall_unlock ();
return info;
}
MonoJitICallInfo *info;
g_assert (jit_icall_hash_addr);
- mono_loader_lock ();
+ mono_icall_lock ();
info = g_hash_table_lookup (jit_icall_hash_addr, (gpointer)addr);
- mono_loader_unlock ();
+ mono_icall_unlock ();
return info;
}
* mono_get_jit_icall_info:
*
* Return the hashtable mapping JIT icall names to MonoJitICallInfo structures. The
- * caller should access it while holding the loader lock.
+ * caller should access it while holding the icall lock.
*/
GHashTable*
mono_get_jit_icall_info (void)
MonoJitICallInfo *info;
const char *res = NULL;
- mono_loader_lock ();
+ mono_icall_lock ();
info = g_hash_table_lookup (jit_icall_hash_name, name);
if (info)
res = info->c_symbol;
- mono_loader_unlock ();
+ mono_icall_unlock ();
return res;
}
void
mono_register_jit_icall_wrapper (MonoJitICallInfo *info, gconstpointer wrapper)
{
- mono_loader_lock ();
+ mono_icall_lock ();
g_hash_table_insert (jit_icall_hash_addr, (gpointer)wrapper, info);
- mono_loader_unlock ();
+ mono_icall_unlock ();
}
MonoJitICallInfo *
g_assert (func);
g_assert (name);
- mono_loader_lock ();
+ mono_icall_lock ();
if (!jit_icall_hash_name) {
jit_icall_hash_name = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
g_hash_table_insert (jit_icall_hash_name, (gpointer)info->name, info);
g_hash_table_insert (jit_icall_hash_addr, (gpointer)func, info);
- mono_loader_unlock ();
+ mono_icall_unlock ();
return info;
}