[mcs] Implements C# 7.2 readonly structs
[mono.git] / mono / utils / mono-io-portability.c
index 979bb6037fd21ba9be040c408eca9cba4a265fe2..d4763a569b9fd332efcd3318c1e0dc05fd162d12 100644 (file)
@@ -1,3 +1,7 @@
+/**
+ * \file
+ */
+
 #include "config.h"
 
 #include <string.h>
 #endif
 #include <errno.h>
 #include <mono/utils/mono-io-portability.h>
-#include <mono/metadata/metadata.h>
-#include <mono/metadata/class.h>
-#include <mono/metadata/class-internals.h>
-#include <mono/metadata/object.h>
-#include <mono/metadata/gc-internal.h>
-#include <mono/metadata/profiler.h>
 #include <mono/metadata/profiler-private.h>
+#include <mono/utils/mono-compiler.h>
 
 #ifndef DISABLE_PORTABILITY
 
 #include <dirent.h>
 
-int __mono_io_portability_helpers = PORTABILITY_UNKNOWN;
+int mono_io_portability_helpers = PORTABILITY_UNKNOWN;
 
 static inline gchar *mono_portability_find_file_internal (GString **report, const gchar *pathname, gboolean last_exists);
 
 void mono_portability_helpers_init (void)
 {
-        const gchar *env;
+        gchar *env;
 
-       if (__mono_io_portability_helpers != PORTABILITY_UNKNOWN)
+       if (mono_io_portability_helpers != PORTABILITY_UNKNOWN)
                return;
        
-        __mono_io_portability_helpers = PORTABILITY_NONE;
+        mono_io_portability_helpers = PORTABILITY_NONE;
        
         env = g_getenv ("MONO_IOMAP");
         if (env != NULL) {
@@ -50,13 +49,14 @@ void mono_portability_helpers_init (void)
                                    options[i]);
 #endif
                         if (!strncasecmp (options[i], "drive", 5)) {
-                                __mono_io_portability_helpers |= PORTABILITY_DRIVE;
+                                mono_io_portability_helpers |= PORTABILITY_DRIVE;
                         } else if (!strncasecmp (options[i], "case", 4)) {
-                                __mono_io_portability_helpers |= PORTABILITY_CASE;
+                                mono_io_portability_helpers |= PORTABILITY_CASE;
                         } else if (!strncasecmp (options[i], "all", 3)) {
-                                __mono_io_portability_helpers |= (PORTABILITY_DRIVE | PORTABILITY_CASE);
+                                mono_io_portability_helpers |= (PORTABILITY_DRIVE | PORTABILITY_CASE);
                        }
                 }
+               g_free (env);
        }
 }
 
@@ -99,7 +99,6 @@ static gchar *find_in_dir (DIR *current, const gchar *name)
 
 static inline void append_report (GString **report, const gchar *format, ...)
 {
-#if defined (_EGLIB_MAJOR) || GLIB_CHECK_VERSION(2,14,0)
        va_list ap;
        if (!*report)
                *report = g_string_new ("");
@@ -107,9 +106,6 @@ static inline void append_report (GString **report, const gchar *format, ...)
        va_start (ap, format);
        g_string_append_vprintf (*report, format, ap);
        va_end (ap);
-#else
-       g_assert_not_reached ();
-#endif
 }
 
 static inline void do_mono_profiler_iomap (GString **report, const char *pathname, const char *new_pathname)
@@ -125,7 +121,7 @@ static inline void do_mono_profiler_iomap (GString **report, const char *pathnam
                *report = NULL;
        }
 
-       mono_profiler_iomap (rep, pathname, new_pathname);
+       MONO_PROFILER_RAISE (iomap_report, (rep, pathname, new_pathname));
        g_free (rep);
 }
 
@@ -152,7 +148,7 @@ static inline gchar *mono_portability_find_file_internal (GString **report, cons
        DIR *scanning = NULL;
        size_t len;
        gboolean drive_stripped = FALSE;
-       gboolean do_report = (mono_profiler_get_events () & MONO_PROFILE_IOMAP_EVENTS) != 0;
+       gboolean do_report = MONO_PROFILER_ENABLED (iomap_report);
 
        if (IS_PORTABILITY_NONE) {
                return(NULL);
@@ -397,4 +393,9 @@ static inline gchar *mono_portability_find_file_internal (GString **report, cons
        g_free (new_pathname);
        return(NULL);
 }
-#endif
+
+#else /* DISABLE_PORTABILITY */
+
+MONO_EMPTY_SOURCE_FILE (mono_io_portability);
+
+#endif /* DISABLE_PORTABILITY */