[runtime] Add a wrapper around atexit () since it is missing on some android versions.
authorZoltan Varga <vargaz@gmail.com>
Sat, 22 Nov 2014 05:08:04 +0000 (00:08 -0500)
committerZoltan Varga <vargaz@gmail.com>
Sat, 22 Nov 2014 05:08:04 +0000 (00:08 -0500)
eglib/src/glib.h
mono/io-layer/handles.c
mono/metadata/console-unix.c
mono/utils/mono-mmap.c
mono/utils/mono-proclib.c
mono/utils/mono-proclib.h

index 533c84116c3a449c582103327a47e0b2b40fc3b6..d23e32a534c5428173f371e531ee61c8a4a82826 100644 (file)
@@ -176,7 +176,6 @@ typedef struct _GMemChunk GMemChunk;
 /*
  * Misc.
  */
-#define g_atexit(func) ((void) atexit (func))
 
 const gchar *    g_getenv(const gchar *variable);
 gboolean         g_setenv(const gchar *variable, const gchar *value, gboolean overwrite);
index 5e706fb7280252ca41d3d5c07e66274ad333a435..3173399092346a2b4fd30a5edf0fe72a898b34a8 100644 (file)
@@ -42,6 +42,7 @@
 #include <mono/io-layer/process-private.h>
 
 #include <mono/utils/mono-mutex.h>
+#include <mono/utils/mono-proclib.h>
 #undef DEBUG_REFS
 
 #if 0
@@ -286,12 +287,12 @@ wapi_init (void)
 
        wapi_processes_init ();
 
-       /* Using g_atexit here instead of an explicit function call in
+       /* Using atexit here instead of an explicit function call in
         * a cleanup routine lets us cope when a third-party library
         * calls exit (eg if an X client loses the connection to its
         * server.)
         */
-       g_atexit (handle_cleanup);
+       mono_atexit (handle_cleanup);
 }
 
 void
index dffba190e31ed5d3113c5705f6e8dcf8d4b8f670..1de9a002e0a9f9a76717d5e013b48248bd5b6ec6 100644 (file)
@@ -35,6 +35,7 @@
 #include <mono/metadata/metadata.h>
 #include <mono/metadata/threadpool.h>
 #include <mono/utils/mono-signal-handler.h>
+#include <mono/utils/mono-proclib.h>
 
 /* On solaris, curses.h must come before both termios.h and term.h */
 #ifdef HAVE_CURSES_H
@@ -502,7 +503,7 @@ ves_icall_System_ConsoleDriver_TtySetup (MonoString *keypad, MonoString *teardow
                if (teardown != NULL)
                        teardown_str = mono_string_to_utf8 (teardown);
 
-               atexit (tty_teardown);
+               mono_atexit (tty_teardown);
        }
 
        return TRUE;
index 6caf9628380f2f3ab8cab48c096dd5a913286e17..ed11c9f1b2874664035bc5d2b4a12be41499fafa 100644 (file)
@@ -645,7 +645,7 @@ mono_shared_area (void)
        header->stats_start = sizeof (SAreaHeader);
        header->stats_end = sizeof (SAreaHeader);
 
-       atexit (mono_shared_area_remove);
+       mono_atexit (mono_shared_area_remove);
        return res;
 }
 
index 2b6f58a668e4e7619ceaa539be756650e8d9b375..81399007ad6c3e4a664262318d8b1bbeca81173f 100644 (file)
@@ -666,3 +666,13 @@ mono_cpu_get_data (int cpu_id, MonoCpuData data, MonoProcessError *error)
        return value;
 }
 
+int
+mono_atexit (void (*func)(void))
+{
+#ifdef PLATFORM_ANDROID
+       /* Some versions of android libc doesn't define atexit () */
+       return 0;
+#else
+       return atexit (func);
+#endif
+}
index bb8a62728e9d652b0c4e38e4cd4f43a3c843a04f..6a8f6bf81f7630f8823e4cfd46d76ea857fc9643 100644 (file)
@@ -53,5 +53,7 @@ int       mono_process_current_pid (void) MONO_INTERNAL;
 int       mono_cpu_count    (void) MONO_INTERNAL;
 gint64    mono_cpu_get_data (int cpu_id, MonoCpuData data, MonoProcessError *error) MONO_INTERNAL;
 
+int       mono_atexit (void (*func)(void)) MONO_INTERNAL;
+
 #endif /* __MONO_PROC_LIB_H__ */