Author: lupus
Date: 2006-09-18 11:01:45 -0400 (Mon, 18 Sep 2006)
New Revision: 65582

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/mono-config.c
Log:


Mon Sep 18 16:59:54 CEST 2006 Paolo Molaro <[EMAIL PROTECTED]>

        * mono-config.c: allow both an os and cpu attribute for dllmap
        and dllentry elemnets to enable a single config file to be used
        for multiple architectures.



Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2006-09-18 14:37:33 UTC (rev 65581)
+++ trunk/mono/mono/metadata/ChangeLog  2006-09-18 15:01:45 UTC (rev 65582)
@@ -1,3 +1,10 @@
+
+Mon Sep 18 16:59:54 CEST 2006 Paolo Molaro <[EMAIL PROTECTED]>
+
+       * mono-config.c: allow both an os and cpu attribute for dllmap
+       and dllentry elemnets to enable a single config file to be used
+       for multiple architectures.
+
 2006-09-18  Gert Driesen  <[EMAIL PROTECTED]>
 
        * loader.c: MonoLoaderError was cleared too soon on load failure.

Modified: trunk/mono/mono/metadata/mono-config.c
===================================================================
--- trunk/mono/mono/metadata/mono-config.c      2006-09-18 14:37:33 UTC (rev 
65581)
+++ trunk/mono/mono/metadata/mono-config.c      2006-09-18 15:01:45 UTC (rev 
65582)
@@ -17,6 +17,56 @@
 #include "mono/metadata/metadata-internals.h"
 #include "mono/utils/mono-logger.h"
 
+#if defined(__linux__)
+#define CONFIG_OS "linux"
+#elif defined(__APPLE__)
+#define CONFIG_OS "osx"
+#elif defined(sun)
+#define CONFIG_OS "solaris"
+#elif defined(__FreeBSD__)
+#define CONFIG_OS "freebsd"
+#elif defined(__NetBSD__)
+#define CONFIG_OS "netbsd"
+#elif defined(__OpenBSD__)
+#define CONFIG_OS "openbsd"
+#elif defined(__WIN32__)
+#define CONFIG_OS "windows"
+#elif defined(_IBMR2)
+#define CONFIG_OS "aix"
+#elif defined(__hpux)
+#define CONFIG_OS "hpux"
+#else
+#warning Unknown operating system
+#define CONFIG_OS "unknownOS"
+#endif
+
+#if defined(__i386__)
+#define CONFIG_CPU "x86"
+#elif defined(__x86_64__)
+#define CONFIG_CPU "x86-64"
+#elif defined(sparc) || defined(__sparc__)
+#define CONFIG_CPU "sparc"
+#elif defined(__ppc__) || defined(__powerpc__)
+#define CONFIG_CPU "ppc"
+#elif defined(__s390x__)
+#define CONFIG_CPU "s390x"
+#elif defined(__s390__)
+#define CONFIG_CPU "s390"
+#elif defined(__arm__)
+#define CONFIG_CPU "arm"
+#elif defined(__ia64__)
+#define CONFIG_CPU "ia64"
+#elif defined(__alpha__)
+#define CONFIG_CPU "alpha"
+#elif defined(hppa) || defined(__hppa__)
+#define CONFIG_CPU "hppa"
+#elif defined(mips) || defined(__mips) || defined(_mips)
+#define CONFIG_CPU "mips"
+#else
+#warning Unknown CPU
+#define CONFIG_CPU "unknownCPU"
+#endif
+
 static void start_element (GMarkupParseContext *context, 
                            const gchar         *element_name,
                           const gchar        **attribute_names,
@@ -141,6 +191,7 @@
 typedef struct {
        char *dll;
        char *target;
+       int ignore;
        MonoImage *assembly;
 } DllInfo;
 
@@ -164,15 +215,22 @@
                g_free (info->dll);
                g_free (info->target);
                info->dll = info->target = NULL;
+               info->ignore = FALSE;
                for (i = 0; attribute_names [i]; ++i) {
                        if (strcmp (attribute_names [i], "dll") == 0)
                                info->dll = g_strdup (attribute_values [i]);
                        else if (strcmp (attribute_names [i], "target") == 0)
                                info->target = g_strdup (attribute_values [i]);
+                       else if (strcmp (attribute_names [i], "os") == 0 && 
strcmp (CONFIG_OS, attribute_values [i]))
+                               info->ignore = TRUE;
+                       else if (strcmp (attribute_names [i], "cpu") == 0 && 
strcmp (CONFIG_CPU, attribute_values [i]))
+                               info->ignore = TRUE;
                }
-               mono_dllmap_insert (info->assembly, info->dll, NULL, 
info->target, NULL);
+               if (!info->ignore)
+                       mono_dllmap_insert (info->assembly, info->dll, NULL, 
info->target, NULL);
        } else if (strcmp (element_name, "dllentry") == 0) {
                const char *name = NULL, *target = NULL, *dll = NULL;
+               int ignore = FALSE;
                for (i = 0; attribute_names [i]; ++i) {
                        if (strcmp (attribute_names [i], "dll") == 0)
                                dll = attribute_values [i];
@@ -180,10 +238,15 @@
                                target = attribute_values [i];
                        else if (strcmp (attribute_names [i], "name") == 0)
                                name = attribute_values [i];
+                       else if (strcmp (attribute_names [i], "os") == 0 && 
strcmp (CONFIG_OS, attribute_values [i]))
+                               ignore = TRUE;
+                       else if (strcmp (attribute_names [i], "cpu") == 0 && 
strcmp (CONFIG_CPU, attribute_values [i]))
+                               ignore = TRUE;
                }
                if (!dll)
                        dll = info->dll;
-               mono_dllmap_insert (info->assembly, info->dll, name, dll, 
target);
+               if (!info->ignore && !ignore)
+                       mono_dllmap_insert (info->assembly, info->dll, name, 
dll, target);
        }
 }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to