[utils] Fix retiring of live block for the lock free allocator
[mono.git] / mono / utils / mono-io-portability.c
index 839b9b3d14ee1a0bf8444f92fc725944c0ce57a3..54c6320d2b6f6a08bc8fc2fe249f315bbde8cac8 100644 (file)
@@ -6,35 +6,13 @@
 #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/utils/mono-hash.h>
-#include <mono/metadata/gc-internal.h>
-#include <mono/metadata/profiler.h>
 #include <mono/metadata/profiler-private.h>
 
-#ifdef DISABLE_PORTABILITY
-int __mono_io_portability_helpers = PORTABILITY_NONE;
-
-void 
-mono_portability_helpers_init (void)
-{
-}
-
-gchar *
-mono_portability_find_file (const gchar *pathname, gboolean last_exists)
-{
-       g_assert_not_reached();
-       return NULL;
-}
-
-#else
+#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);
 
@@ -42,10 +20,10 @@ void mono_portability_helpers_init (void)
 {
         const 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) {
@@ -66,11 +44,11 @@ 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);
                        }
                 }
        }
@@ -115,7 +93,6 @@ static gchar *find_in_dir (DIR *current, const gchar *name)
 
 static inline void append_report (GString **report, const gchar *format, ...)
 {
-#if GLIB_CHECK_VERSION(2,14,0)
        va_list ap;
        if (!*report)
                *report = g_string_new ("");
@@ -123,9 +100,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)
@@ -148,7 +122,11 @@ static inline void do_mono_profiler_iomap (GString **report, const char *pathnam
 gchar *mono_portability_find_file (const gchar *pathname, gboolean last_exists)
 {
        GString *report = NULL;
-       gchar *ret = mono_portability_find_file_internal (&report, pathname, last_exists);
+       gchar *ret;
+       
+       if (!pathname || !pathname [0])
+               return NULL;
+       ret = mono_portability_find_file_internal (&report, pathname, last_exists);
 
        if (report)
                g_string_free (report, TRUE);