diff --git a/eglib/src/glib.h b/eglib/src/glib.h index 533c84116c3..d23e32a534c 100644 --- a/eglib/src/glib.h +++ b/eglib/src/glib.h @@ -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); diff --git a/mono/io-layer/handles.c b/mono/io-layer/handles.c index 5e706fb7280..31733990923 100644 --- a/mono/io-layer/handles.c +++ b/mono/io-layer/handles.c @@ -42,6 +42,7 @@ #include #include +#include #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 diff --git a/mono/metadata/console-unix.c b/mono/metadata/console-unix.c index dffba190e31..1de9a002e0a 100644 --- a/mono/metadata/console-unix.c +++ b/mono/metadata/console-unix.c @@ -35,6 +35,7 @@ #include #include #include +#include /* 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; diff --git a/mono/utils/mono-mmap.c b/mono/utils/mono-mmap.c index 6caf9628380..ed11c9f1b28 100644 --- a/mono/utils/mono-mmap.c +++ b/mono/utils/mono-mmap.c @@ -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; } diff --git a/mono/utils/mono-proclib.c b/mono/utils/mono-proclib.c index 1303b5b4d44..09de17850ed 100644 --- a/mono/utils/mono-proclib.c +++ b/mono/utils/mono-proclib.c @@ -664,3 +664,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 +} diff --git a/mono/utils/mono-proclib.h b/mono/utils/mono-proclib.h index e0d84ec0233..95783edc1dd 100644 --- a/mono/utils/mono-proclib.h +++ b/mono/utils/mono-proclib.h @@ -52,5 +52,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__ */