[arm64] Allow v8..v15 in unwind info on arm64. Fixes part of #21615.
[mono.git] / mono / metadata / mono-config.c
index 50e2702acbd1f6bb13bf20a292ef6dc90bdff9a2..5d7d9429b1ddaa16f4a5c96ae3e5206d17e5d0f4 100644 (file)
 #define CONFIG_OS "netbsd"
 #elif defined(__OpenBSD__)
 #define CONFIG_OS "openbsd"
-#elif defined(__WIN32__)
+#elif defined(__WIN32__) || defined(TARGET_WIN32)
 #define CONFIG_OS "windows"
 #elif defined(_IBMR2)
 #define CONFIG_OS "aix"
 #elif defined(__hpux)
 #define CONFIG_OS "hpux"
+#elif defined(__HAIKU__)
+#define CONFIG_OS "haiku"
 #else
 #warning Unknown operating system
 #define CONFIG_OS "unknownOS"
 #endif
 
 #ifndef CONFIG_CPU
-#if defined(__i386__)
+#if defined(__i386__) || defined(TARGET_X86)
 #define CONFIG_CPU "x86"
 #define CONFIG_WORDSIZE "32"
-#elif defined(__x86_64__)
+#elif defined(__x86_64__) || defined(TARGET_AMD64)
 #define CONFIG_CPU "x86-64"
 #define CONFIG_WORDSIZE "64"
 #elif defined(sparc) || defined(__sparc__)
 #elif defined(__arm__)
 #define CONFIG_CPU "arm"
 #define CONFIG_WORDSIZE "32"
+#elif defined(__aarch64__)
+#define CONFIG_CPU "armv8"
+#define CONFIG_WORDSIZE "64"
 #elif defined(__ia64__)
 #define CONFIG_CPU "ia64"
 #define CONFIG_WORDSIZE "64"
-#elif defined(__alpha__)
-#define CONFIG_CPU "alpha"
-#define CONFIG_WORDSIZE "64"
-#elif defined(hppa) || defined(__hppa__)
-#define CONFIG_CPU "hppa"
-#define CONFIG_WORDSIZE "32"
 #elif defined(mips) || defined(__mips) || defined(_mips)
 #define CONFIG_CPU "mips"
 #define CONFIG_WORDSIZE "32"
@@ -130,6 +129,9 @@ mono_parser = {
 
 static GHashTable *config_handlers;
 
+static const char *mono_cfg_dir = NULL;
+static char *mono_cfg_dir_allocated = NULL;
+
 /* when this interface is stable, export it. */
 typedef struct MonoParseHandler MonoParseHandler;
 
@@ -366,6 +368,14 @@ mono_config_init (void)
        g_hash_table_insert (config_handlers, (gpointer) legacyUEP_handler.element_name, (gpointer) &legacyUEP_handler);
 }
 
+void
+mono_config_cleanup (void)
+{
+       if (config_handlers)
+               g_hash_table_destroy (config_handlers);
+       g_free (mono_cfg_dir_allocated);
+}
+
 /* FIXME: error handling */
 
 static void
@@ -557,7 +567,7 @@ mono_config_parse (const char *filename) {
        mono_config_parse_file (mono_cfg);
        g_free (mono_cfg);
 
-#ifndef TARGET_WIN32
+#if !defined(TARGET_WIN32) && !defined(__native_client__)
        home = g_get_home_dir ();
        user_cfg = g_strconcat (home, G_DIR_SEPARATOR_S, ".mono/config", NULL);
        mono_config_parse_file (user_cfg);
@@ -565,8 +575,6 @@ mono_config_parse (const char *filename) {
 #endif
 }
 
-static const char *mono_cfg_dir = NULL;
-
 /* Invoked during startup */
 void
 mono_set_config_dir (const char *dir)
@@ -574,7 +582,7 @@ mono_set_config_dir (const char *dir)
        /* If this variable is set, overrides the directory computed */
        mono_cfg_dir = g_getenv ("MONO_CFG_DIR");
        if (mono_cfg_dir == NULL)
-               mono_cfg_dir = g_strdup (dir);
+               mono_cfg_dir = mono_cfg_dir_allocated = g_strdup (dir);
 }
 
 const char* 
@@ -766,22 +774,36 @@ config_assemblybinding_parser = {
 void
 mono_config_parse_assembly_bindings (const char *filename, int amajor, int aminor, void *user_data, void (*infocb)(MonoAssemblyBindingInfo *info, void *user_data))
 {
-       MonoAssemblyBindingInfo info = {
-               .major = amajor,
-               .minor = aminor
-       };
-       ParserUserData pud = {
-               &info,
-               infocb,
-               user_data
-       };
-       ParseState state = {
-               &config_assemblybinding_parser, /* MonoParseHandler */
-               &pud, /* user_data */
-               NULL, /* MonoImage (we don't need it right now)*/
-               TRUE /* We are already inited */
-       };
+       MonoAssemblyBindingInfo info;
+       ParserUserData pud;
+       ParseState state;
+
+       info.major = amajor;
+       info.minor = aminor;
+
+       pud.info = &info;
+       pud.info_parsed = infocb;
+       pud.user_data = user_data;
+
+       state.current = &config_assemblybinding_parser;  /* MonoParseHandler */
+       state.user_data = &pud;
+       state.assembly = NULL; /* MonoImage (we don't need it right now)*/
+       state.inited = TRUE; /* We are already inited */
 
        mono_config_parse_file_with_context (&state, filename);
 }
 
+static mono_bool mono_server_mode = FALSE;
+
+void
+mono_config_set_server_mode (mono_bool server_mode)
+{
+       mono_server_mode = server_mode;
+}
+
+mono_bool
+mono_config_is_server_mode (void)
+{
+       return mono_server_mode;
+}
+