Author: lupus
Date: 2007-02-16 13:20:07 -0500 (Fri, 16 Feb 2007)
New Revision: 73036
Modified:
trunk/mono/mono/metadata/ChangeLog
trunk/mono/mono/metadata/loader.c
trunk/mono/mono/metadata/metadata-internals.h
Log:
Fri Feb 16 19:17:30 CET 2007 Paolo Molaro <[EMAIL PROTECTED]>
* metadata-internals.h, loader.c: fix dllmap lookup order
for non-function maps, too, and prepare for fallback code.
Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog 2007-02-16 18:09:45 UTC (rev 73035)
+++ trunk/mono/mono/metadata/ChangeLog 2007-02-16 18:20:07 UTC (rev 73036)
@@ -1,3 +1,9 @@
+
+Fri Feb 16 19:17:30 CET 2007 Paolo Molaro <[EMAIL PROTECTED]>
+
+ * metadata-internals.h, loader.c: fix dllmap lookup order
+ for non-function maps, too, and prepare for fallback code.
+
2007-02-12 Robert Jordan <[EMAIL PROTECTED]>
* marshal.c, marshal.h, icall-def.h: rename mono_marshal_realloc
Modified: trunk/mono/mono/metadata/loader.c
===================================================================
--- trunk/mono/mono/metadata/loader.c 2007-02-16 18:09:45 UTC (rev 73035)
+++ trunk/mono/mono/metadata/loader.c 2007-02-16 18:20:07 UTC (rev 73036)
@@ -925,20 +925,19 @@
return inflated;
}
-typedef struct MonoDllMap MonoDllMap;
-
-struct MonoDllMap {
- char *name;
- char *target;
+struct _MonoDllMap {
char *dll;
+ char *target;
+ char *func;
+ char *target_func;
MonoDllMap *next;
};
-static GHashTable *global_dll_map;
+static MonoDllMap *global_dll_map;
static int
-mono_dllmap_lookup_hash (GHashTable *dll_map, const char *dll, const char*
func, const char **rdll, const char **rfunc) {
- MonoDllMap *map, *tmp;
+mono_dllmap_lookup_list (MonoDllMap *dll_map, const char *dll, const char*
func, const char **rdll, const char **rfunc) {
+ int found = 0;
*rdll = dll;
@@ -947,25 +946,29 @@
mono_loader_lock ();
- map = g_hash_table_lookup (dll_map, dll);
- if (!map) {
- mono_loader_unlock ();
- return 0;
- }
- *rdll = map->target? map->target: dll;
-
- for (tmp = map->next; tmp; tmp = tmp->next) {
- if (strcmp (func, tmp->name) == 0) {
- *rfunc = tmp->name;
- if (tmp->dll)
- *rdll = tmp->dll;
- mono_loader_unlock ();
- return 1;
+ /*
+ * we use the first entry we find that matches, since entries from
+ * the config file are prepended to the list and we document that the
+ * later entries win.
+ */
+ for (; dll_map; dll_map = dll_map->next) {
+ if (strcmp (dll_map->dll, dll))
+ continue;
+ if (!found && dll_map->target) {
+ *rdll = dll_map->target;
+ found = 1;
+ /* we don't quit here, because we could find a full
+ * entry that matches also function and that has
priority.
+ */
}
+ if (dll_map->func && strcmp (dll_map->func, func) == 0) {
+ *rfunc = dll_map->target_func;
+ break;
+ }
}
- *rfunc = func;
+
mono_loader_unlock ();
- return 1;
+ return found;
}
static int
@@ -973,49 +976,38 @@
{
int res;
if (assembly && assembly->dll_map) {
- res = mono_dllmap_lookup_hash (assembly->dll_map, dll, func,
rdll, rfunc);
+ res = mono_dllmap_lookup_list (assembly->dll_map, dll, func,
rdll, rfunc);
if (res)
return res;
}
- return mono_dllmap_lookup_hash (global_dll_map, dll, func, rdll, rfunc);
+ return mono_dllmap_lookup_list (global_dll_map, dll, func, rdll, rfunc);
}
void
mono_dllmap_insert (MonoImage *assembly, const char *dll, const char *func,
const char *tdll, const char *tfunc) {
- MonoDllMap *map, *entry;
- GHashTable *dll_map = NULL;
+ MonoDllMap *entry;
mono_loader_lock ();
if (!assembly) {
- if (!global_dll_map)
- global_dll_map = g_hash_table_new (g_str_hash,
g_str_equal);
- dll_map = global_dll_map;
+ entry = g_malloc0 (sizeof (MonoDllMap));
+ entry->dll = dll? g_strdup (dll): NULL;
+ entry->target = tdll? g_strdup (tdll): NULL;
+ entry->func = func? g_strdup (func): NULL;
+ entry->target_func = tfunc? g_strdup (tfunc): NULL;
+ entry->next = global_dll_map;
+ global_dll_map = entry;
} else {
- if (!assembly->dll_map)
- assembly->dll_map = g_hash_table_new (g_str_hash,
g_str_equal);
- dll_map = assembly->dll_map;
+ MonoMemPool *mpool = assembly->mempool;
+ entry = mono_mempool_alloc0 (mpool, sizeof (MonoDllMap));
+ entry->dll = dll? mono_mempool_strdup (mpool, dll): NULL;
+ entry->target = tdll? mono_mempool_strdup (mpool, tdll): NULL;
+ entry->func = func? mono_mempool_strdup (mpool, func): NULL;
+ entry->target_func = tfunc? mono_mempool_strdup (mpool, tfunc):
NULL;
+ entry->next = assembly->dll_map;
+ assembly->dll_map = entry;
}
- map = g_hash_table_lookup (dll_map, dll);
- if (!map) {
- map = g_new0 (MonoDllMap, 1);
- map->dll = g_strdup (dll);
- if (tdll)
- map->target = g_strdup (tdll);
- g_hash_table_insert (dll_map, map->dll, map);
- }
- if (func) {
- entry = g_new0 (MonoDllMap, 1);
- entry->name = g_strdup (func);
- if (tfunc)
- entry->target = g_strdup (tfunc);
- if (tdll && map->target && strcmp (map->target, tdll))
- entry->dll = g_strdup (tdll);
- entry->next = map->next;
- map->next = entry;
- }
-
mono_loader_unlock ();
}
Modified: trunk/mono/mono/metadata/metadata-internals.h
===================================================================
--- trunk/mono/mono/metadata/metadata-internals.h 2007-02-16 18:09:45 UTC
(rev 73035)
+++ trunk/mono/mono/metadata/metadata-internals.h 2007-02-16 18:20:07 UTC
(rev 73036)
@@ -62,6 +62,8 @@
#define REFERENCE_MISSING ((gpointer) -1)
+typedef struct _MonoDllMap MonoDllMap;
+
struct _MonoImage {
/*
* The number of assemblies which reference this MonoImage though their
'image'
@@ -202,7 +204,7 @@
void *user_info;
/* dll map entries */
- GHashTable *dll_map;
+ MonoDllMap *dll_map;
/* interfaces IDs from this image */
MonoBitSet *interface_bitset;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches