From 29c71c3b03b83ee696e3997e47eb86fa476721e2 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Fri, 28 Jan 2022 20:32:19 +0100 Subject: [PATCH 1/8] Account for incorrect implementation of clock_nanosleep in older Android libc --- src/mono/mono/eglib/gdate-unix.c | 10 ++++++++++ src/mono/mono/mini/mini-posix.c | 24 ++++++++++++++++++++++-- src/mono/mono/utils/mono-threads.c | 10 ++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/eglib/gdate-unix.c b/src/mono/mono/eglib/gdate-unix.c index 53f4bbb3d5adc..b3be476dd6ccf 100644 --- a/src/mono/mono/eglib/gdate-unix.c +++ b/src/mono/mono/eglib/gdate-unix.c @@ -65,6 +65,16 @@ g_usleep (gulong microseconds) do { ret = clock_nanosleep (CLOCK_MONOTONIC, TIMER_ABSTIME, &target, NULL); +#if HOST_ANDROID + /* + * Although clock_nanosleep should never return a negative value according + * to the POSIX specification, older versions of Android libc return -1 + * and set errno on failure instead of returning the errno directly. + * See https://github.com/xamarin/xamarin-android/issues/6600 + */ + if (ret == -1) + ret = errno; +#endif if (ret != 0 && ret != EINTR) g_error ("%s: clock_nanosleep () returned %d", __func__, ret); } while (ret == EINTR); diff --git a/src/mono/mono/mini/mini-posix.c b/src/mono/mono/mini/mini-posix.c index b706de969f5ce..b701e43325ebf 100644 --- a/src/mono/mono/mini/mini-posix.c +++ b/src/mono/mono/mini/mini-posix.c @@ -484,7 +484,18 @@ clock_init_for_profiler (MonoProfilerSampleMode mode) * CLOCK_PROCESS_CPUTIME_ID clock but don't actually support it. For * those systems, we fall back to CLOCK_MONOTONIC if we get EINVAL. */ - if (clock_nanosleep (CLOCK_PROCESS_CPUTIME_ID, TIMER_ABSTIME, &ts, NULL) != EINVAL) { + int ret = clock_nanosleep (CLOCK_PROCESS_CPUTIME_ID, TIMER_ABSTIME, &ts, NULL); +#if HOST_ANDROID + /* + * Although clock_nanosleep should never return a negative value according + * to the POSIX specification, older versions of Android libc return -1 + * and set errno on failure instead of returning the errno directly. + * See https://github.com/xamarin/xamarin-android/issues/6600 + */ + if (ret == -1) + ret = errno; +#endif + if (ret != EINVAL) { sampling_clock = CLOCK_PROCESS_CPUTIME_ID; break; } @@ -509,7 +520,16 @@ clock_sleep_ns_abs (guint64 ns_abs) do { ret = clock_nanosleep (sampling_clock, TIMER_ABSTIME, &then, NULL); - +#if HOST_ANDROID + /* + * Although clock_nanosleep should never return a negative value according + * to the POSIX specification, older versions of Android libc return -1 + * and set errno on failure instead of returning the errno directly. + * See https://github.com/xamarin/xamarin-android/issues/6600 + */ + if (ret == -1) + ret = errno; +#endif if (ret != 0 && ret != EINTR) g_error ("%s: clock_nanosleep () returned %d", __func__, ret); } while (ret == EINTR && mono_atomic_load_i32 (&sampling_thread_running)); diff --git a/src/mono/mono/utils/mono-threads.c b/src/mono/mono/utils/mono-threads.c index e3a936a1abc3c..89414de91571c 100644 --- a/src/mono/mono/utils/mono-threads.c +++ b/src/mono/mono/utils/mono-threads.c @@ -1749,6 +1749,16 @@ mono_thread_info_sleep (guint32 ms, gboolean *alerted) do { ret = clock_nanosleep (CLOCK_MONOTONIC, TIMER_ABSTIME, &target, NULL); +#if HOST_ANDROID + /* + * Although clock_nanosleep should never return a negative value according + * to the POSIX specification, older versions of Android libc return -1 + * and set errno on failure instead of returning the errno directly. + * See https://github.com/xamarin/xamarin-android/issues/6600 + */ + if (ret == -1) + ret = errno; +#endif } while (ret != 0); #elif HOST_WIN32 Sleep (ms); From 69ce197aac283a39b96ca833e4bb41c2e89aa873 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Wed, 2 Feb 2022 14:20:11 +0100 Subject: [PATCH 2/8] Shorten comments --- src/mono/mono/eglib/gdate-unix.c | 8 ++------ src/mono/mono/mini/mini-posix.c | 16 ++++------------ src/mono/mono/utils/mono-threads.c | 12 ++++-------- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/mono/mono/eglib/gdate-unix.c b/src/mono/mono/eglib/gdate-unix.c index b3be476dd6ccf..3bdb7d816cb23 100644 --- a/src/mono/mono/eglib/gdate-unix.c +++ b/src/mono/mono/eglib/gdate-unix.c @@ -66,12 +66,8 @@ g_usleep (gulong microseconds) do { ret = clock_nanosleep (CLOCK_MONOTONIC, TIMER_ABSTIME, &target, NULL); #if HOST_ANDROID - /* - * Although clock_nanosleep should never return a negative value according - * to the POSIX specification, older versions of Android libc return -1 - * and set errno on failure instead of returning the errno directly. - * See https://github.com/xamarin/xamarin-android/issues/6600 - */ + // Workaround for incorrect implementation of clock_nanosleep return value on old Android (<=5.1) + // See https://github.com/xamarin/xamarin-android/issues/6600 if (ret == -1) ret = errno; #endif diff --git a/src/mono/mono/mini/mini-posix.c b/src/mono/mono/mini/mini-posix.c index b701e43325ebf..26b9ee8eb7f0d 100644 --- a/src/mono/mono/mini/mini-posix.c +++ b/src/mono/mono/mini/mini-posix.c @@ -486,12 +486,8 @@ clock_init_for_profiler (MonoProfilerSampleMode mode) */ int ret = clock_nanosleep (CLOCK_PROCESS_CPUTIME_ID, TIMER_ABSTIME, &ts, NULL); #if HOST_ANDROID - /* - * Although clock_nanosleep should never return a negative value according - * to the POSIX specification, older versions of Android libc return -1 - * and set errno on failure instead of returning the errno directly. - * See https://github.com/xamarin/xamarin-android/issues/6600 - */ + // Workaround for incorrect implementation of clock_nanosleep return value on old Android (<=5.1) + // See https://github.com/xamarin/xamarin-android/issues/6600 if (ret == -1) ret = errno; #endif @@ -521,12 +517,8 @@ clock_sleep_ns_abs (guint64 ns_abs) do { ret = clock_nanosleep (sampling_clock, TIMER_ABSTIME, &then, NULL); #if HOST_ANDROID - /* - * Although clock_nanosleep should never return a negative value according - * to the POSIX specification, older versions of Android libc return -1 - * and set errno on failure instead of returning the errno directly. - * See https://github.com/xamarin/xamarin-android/issues/6600 - */ + // Workaround for incorrect implementation of clock_nanosleep return value on old Android (<=5.1) + // See https://github.com/xamarin/xamarin-android/issues/6600 if (ret == -1) ret = errno; #endif diff --git a/src/mono/mono/utils/mono-threads.c b/src/mono/mono/utils/mono-threads.c index 89414de91571c..f1ef041f26581 100644 --- a/src/mono/mono/utils/mono-threads.c +++ b/src/mono/mono/utils/mono-threads.c @@ -1750,14 +1750,10 @@ mono_thread_info_sleep (guint32 ms, gboolean *alerted) do { ret = clock_nanosleep (CLOCK_MONOTONIC, TIMER_ABSTIME, &target, NULL); #if HOST_ANDROID - /* - * Although clock_nanosleep should never return a negative value according - * to the POSIX specification, older versions of Android libc return -1 - * and set errno on failure instead of returning the errno directly. - * See https://github.com/xamarin/xamarin-android/issues/6600 - */ - if (ret == -1) - ret = errno; + // Workaround for incorrect implementation of clock_nanosleep return value on old Android (<=5.1) + // See https://github.com/xamarin/xamarin-android/issues/6600 + if (ret == -1) + ret = errno; #endif } while (ret != 0); #elif HOST_WIN32 From 49d42c36305f7104c1ad3ee68bb8a8055bb612c8 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Mon, 7 Feb 2022 13:18:56 +0100 Subject: [PATCH 3/8] Add g_clock_nanosleep function --- src/mono/mono/eglib/CMakeLists.txt | 1 + src/mono/mono/eglib/gclock_nanosleep.c | 28 ++++++++++++++++++++++++++ src/mono/mono/eglib/gdate-unix.c | 8 +------- src/mono/mono/eglib/glib.h | 8 ++++++++ src/mono/mono/mini/mini-posix.c | 16 ++------------- src/mono/mono/utils/mono-threads.c | 9 ++------- 6 files changed, 42 insertions(+), 28 deletions(-) create mode 100644 src/mono/mono/eglib/gclock_nanosleep.c diff --git a/src/mono/mono/eglib/CMakeLists.txt b/src/mono/mono/eglib/CMakeLists.txt index 1325ee6c1126c..cec114bbb17b1 100644 --- a/src/mono/mono/eglib/CMakeLists.txt +++ b/src/mono/mono/eglib/CMakeLists.txt @@ -41,6 +41,7 @@ set(eglib_common_sources gmarkup.c gutf8.c gunicode.c + gclock_nanosleep.c unicode-data.h) addprefix(eglib_sources ../eglib/ "${eglib_platform_sources};${eglib_common_sources}") diff --git a/src/mono/mono/eglib/gclock_nanosleep.c b/src/mono/mono/eglib/gclock_nanosleep.c new file mode 100644 index 0000000000000..454d5bfffc41c --- /dev/null +++ b/src/mono/mono/eglib/gclock_nanosleep.c @@ -0,0 +1,28 @@ +/* + * gclock_nanosleep-android.c: Clock nanosleep. + * + * Copyright 2022 Microsoft + * Licensed under the MIT license. See LICENSE file in the project root for full license information. +*/ + +#include +#include + +gint +g_clock_nanosleep (clockid_t clockid, gint flags, const struct timespec *request, struct timespec *remain) +{ + gint ret = 0; + +#if defined(HAVE_CLOCK_NANOSLEEP) && !defined(__PASE__) + ret = clock_nanosleep(clockid, flags, request, remain); +#endif + +#ifdef HOST_ANDROID + // Workaround for incorrect implementation of clock_nanosleep return value on old Android (<=5.1) + // See https://github.com/xamarin/xamarin-android/issues/6600 + if (ret == -1) + ret = errno; +#endif + + return ret; +} diff --git a/src/mono/mono/eglib/gdate-unix.c b/src/mono/mono/eglib/gdate-unix.c index 3bdb7d816cb23..9a98e66304576 100644 --- a/src/mono/mono/eglib/gdate-unix.c +++ b/src/mono/mono/eglib/gdate-unix.c @@ -64,13 +64,7 @@ g_usleep (gulong microseconds) } do { - ret = clock_nanosleep (CLOCK_MONOTONIC, TIMER_ABSTIME, &target, NULL); -#if HOST_ANDROID - // Workaround for incorrect implementation of clock_nanosleep return value on old Android (<=5.1) - // See https://github.com/xamarin/xamarin-android/issues/6600 - if (ret == -1) - ret = errno; -#endif + ret = g_clock_nanosleep (CLOCK_MONOTONIC, TIMER_ABSTIME, &target, NULL); if (ret != 0 && ret != EINTR) g_error ("%s: clock_nanosleep () returned %d", __func__, ret); } while (ret == EINTR); diff --git a/src/mono/mono/eglib/glib.h b/src/mono/mono/eglib/glib.h index 14872b9814f48..edb0b9efaed0e 100644 --- a/src/mono/mono/eglib/glib.h +++ b/src/mono/mono/eglib/glib.h @@ -28,6 +28,7 @@ #include #include #include +#include // - Pointers should only be converted to or from pointer-sized integers. // - Any size integer can be converted to any other size integer. @@ -1506,4 +1507,11 @@ mono_qsort (void* base, size_t num, size_t size, int (*compare)(const void*, con #define g_try_realloc(obj, size) (g_cast (monoeg_try_realloc ((obj), (size)))) #define g_memdup(mem, size) (g_cast (monoeg_g_memdup ((mem), (size)))) +/* + * Clock Nanosleep + */ + +gint +g_clock_nanosleep (clockid_t clockid, gint flags, const struct timespec *request, struct timespec *remain); + #endif // __GLIB_H diff --git a/src/mono/mono/mini/mini-posix.c b/src/mono/mono/mini/mini-posix.c index 26b9ee8eb7f0d..7cba05319dfc6 100644 --- a/src/mono/mono/mini/mini-posix.c +++ b/src/mono/mono/mini/mini-posix.c @@ -78,6 +78,7 @@ #include #include "mini-runtime.h" #include "jit-icalls.h" +#include #ifdef HOST_DARWIN #include @@ -484,14 +485,7 @@ clock_init_for_profiler (MonoProfilerSampleMode mode) * CLOCK_PROCESS_CPUTIME_ID clock but don't actually support it. For * those systems, we fall back to CLOCK_MONOTONIC if we get EINVAL. */ - int ret = clock_nanosleep (CLOCK_PROCESS_CPUTIME_ID, TIMER_ABSTIME, &ts, NULL); -#if HOST_ANDROID - // Workaround for incorrect implementation of clock_nanosleep return value on old Android (<=5.1) - // See https://github.com/xamarin/xamarin-android/issues/6600 - if (ret == -1) - ret = errno; -#endif - if (ret != EINVAL) { + if (g_clock_nanosleep (CLOCK_PROCESS_CPUTIME_ID, TIMER_ABSTIME, &ts, NULL) != EINVAL) { sampling_clock = CLOCK_PROCESS_CPUTIME_ID; break; } @@ -516,12 +510,6 @@ clock_sleep_ns_abs (guint64 ns_abs) do { ret = clock_nanosleep (sampling_clock, TIMER_ABSTIME, &then, NULL); -#if HOST_ANDROID - // Workaround for incorrect implementation of clock_nanosleep return value on old Android (<=5.1) - // See https://github.com/xamarin/xamarin-android/issues/6600 - if (ret == -1) - ret = errno; -#endif if (ret != 0 && ret != EINTR) g_error ("%s: clock_nanosleep () returned %d", __func__, ret); } while (ret == EINTR && mono_atomic_load_i32 (&sampling_thread_running)); diff --git a/src/mono/mono/utils/mono-threads.c b/src/mono/mono/utils/mono-threads.c index f1ef041f26581..3dc89f291f5ef 100644 --- a/src/mono/mono/utils/mono-threads.c +++ b/src/mono/mono/utils/mono-threads.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -1748,13 +1749,7 @@ mono_thread_info_sleep (guint32 ms, gboolean *alerted) } do { - ret = clock_nanosleep (CLOCK_MONOTONIC, TIMER_ABSTIME, &target, NULL); -#if HOST_ANDROID - // Workaround for incorrect implementation of clock_nanosleep return value on old Android (<=5.1) - // See https://github.com/xamarin/xamarin-android/issues/6600 - if (ret == -1) - ret = errno; -#endif + ret = g_clock_nanosleep (CLOCK_MONOTONIC, TIMER_ABSTIME, &target, NULL); } while (ret != 0); #elif HOST_WIN32 Sleep (ms); From bcb469ac8efd4fa805ea11224015a117f7040024 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Mon, 7 Feb 2022 17:29:10 +0100 Subject: [PATCH 4/8] Add remap definition --- src/mono/mono/eglib/eglib-remap.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/mono/eglib/eglib-remap.h b/src/mono/mono/eglib/eglib-remap.h index c3e956842dea8..02bc3169e14ce 100644 --- a/src/mono/mono/eglib/eglib-remap.h +++ b/src/mono/mono/eglib/eglib-remap.h @@ -260,6 +260,7 @@ #define g_unichar_xdigit_value monoeg_g_unichar_xdigit_value #define g_unsetenv monoeg_g_unsetenv #define g_usleep monoeg_g_usleep +#define g_clock_nanosleep monoeg_clock_nanosleep #define g_utf16_to_ucs4 monoeg_g_utf16_to_ucs4 #define g_utf16_to_utf8 monoeg_g_utf16_to_utf8 #define g_utf16_to_utf8_custom_alloc monoeg_g_utf16_to_utf8_custom_alloc From 63e43239e9c2674f53228c08ebe31247500d7726 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Mon, 7 Feb 2022 19:28:41 +0100 Subject: [PATCH 5/8] Fix build --- src/mono/mono/eglib/CMakeLists.txt | 2 +- src/mono/mono/eglib/gclock-nanosleep.c | 29 ++++++++++++++++++++++++++ src/mono/mono/eglib/gclock_nanosleep.c | 28 ------------------------- src/mono/mono/mini/mini-posix.c | 2 +- src/mono/mono/utils/mono-threads.c | 2 +- 5 files changed, 32 insertions(+), 31 deletions(-) create mode 100644 src/mono/mono/eglib/gclock-nanosleep.c delete mode 100644 src/mono/mono/eglib/gclock_nanosleep.c diff --git a/src/mono/mono/eglib/CMakeLists.txt b/src/mono/mono/eglib/CMakeLists.txt index cec114bbb17b1..1e3bd2545a34a 100644 --- a/src/mono/mono/eglib/CMakeLists.txt +++ b/src/mono/mono/eglib/CMakeLists.txt @@ -41,7 +41,7 @@ set(eglib_common_sources gmarkup.c gutf8.c gunicode.c - gclock_nanosleep.c + gclock-nanosleep.c unicode-data.h) addprefix(eglib_sources ../eglib/ "${eglib_platform_sources};${eglib_common_sources}") diff --git a/src/mono/mono/eglib/gclock-nanosleep.c b/src/mono/mono/eglib/gclock-nanosleep.c new file mode 100644 index 0000000000000..03bd13fb41955 --- /dev/null +++ b/src/mono/mono/eglib/gclock-nanosleep.c @@ -0,0 +1,29 @@ +/* + * gclock_nanosleep.c: Clock nanosleep on platforms that have clock_nanosleep(). + * + * Copyright 2022 Microsoft + * Licensed under the MIT license. See LICENSE file in the project root for full license information. +*/ + +#include +#include +#include + +gint +g_clock_nanosleep (clockid_t clockid, gint flags, const struct timespec *request, struct timespec *remain) +{ + gint ret = 0; + +#if defined(HAVE_CLOCK_NANOSLEEP) && !defined(__PASE__) + ret = clock_nanosleep (clockid, flags, request, remain); +#else + g_assert_not_reached (); +#endif + + // Workaround for incorrect implementation of clock_nanosleep return value on old Android (<=5.1) + // See https://github.com/xamarin/xamarin-android/issues/6600 + if (ret == -1) + ret = errno; + + return ret; +} diff --git a/src/mono/mono/eglib/gclock_nanosleep.c b/src/mono/mono/eglib/gclock_nanosleep.c deleted file mode 100644 index 454d5bfffc41c..0000000000000 --- a/src/mono/mono/eglib/gclock_nanosleep.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * gclock_nanosleep-android.c: Clock nanosleep. - * - * Copyright 2022 Microsoft - * Licensed under the MIT license. See LICENSE file in the project root for full license information. -*/ - -#include -#include - -gint -g_clock_nanosleep (clockid_t clockid, gint flags, const struct timespec *request, struct timespec *remain) -{ - gint ret = 0; - -#if defined(HAVE_CLOCK_NANOSLEEP) && !defined(__PASE__) - ret = clock_nanosleep(clockid, flags, request, remain); -#endif - -#ifdef HOST_ANDROID - // Workaround for incorrect implementation of clock_nanosleep return value on old Android (<=5.1) - // See https://github.com/xamarin/xamarin-android/issues/6600 - if (ret == -1) - ret = errno; -#endif - - return ret; -} diff --git a/src/mono/mono/mini/mini-posix.c b/src/mono/mono/mini/mini-posix.c index 7cba05319dfc6..8bb41ee1cb9a3 100644 --- a/src/mono/mono/mini/mini-posix.c +++ b/src/mono/mono/mini/mini-posix.c @@ -78,7 +78,7 @@ #include #include "mini-runtime.h" #include "jit-icalls.h" -#include +#include #ifdef HOST_DARWIN #include diff --git a/src/mono/mono/utils/mono-threads.c b/src/mono/mono/utils/mono-threads.c index 3dc89f291f5ef..7697ac5002240 100644 --- a/src/mono/mono/utils/mono-threads.c +++ b/src/mono/mono/utils/mono-threads.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include From 4995631533695daccbda56b0fa64685ad6266358 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Mon, 7 Feb 2022 19:33:04 +0100 Subject: [PATCH 6/8] Make sure the extra check runs only on Android --- src/mono/mono/eglib/gclock-nanosleep.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mono/mono/eglib/gclock-nanosleep.c b/src/mono/mono/eglib/gclock-nanosleep.c index 03bd13fb41955..f2ced8b2c07d1 100644 --- a/src/mono/mono/eglib/gclock-nanosleep.c +++ b/src/mono/mono/eglib/gclock-nanosleep.c @@ -20,10 +20,12 @@ g_clock_nanosleep (clockid_t clockid, gint flags, const struct timespec *request g_assert_not_reached (); #endif +#ifdef HOST_ANDROID // Workaround for incorrect implementation of clock_nanosleep return value on old Android (<=5.1) // See https://github.com/xamarin/xamarin-android/issues/6600 if (ret == -1) ret = errno; +#endif return ret; } From aed9f5674e6d31d002909b5ac9a2f4f04c26ccd1 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Mon, 7 Feb 2022 21:04:03 +0100 Subject: [PATCH 7/8] Make Windows builds happy --- src/mono/mono/eglib/CMakeLists.txt | 3 +-- src/mono/mono/eglib/glib.h | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/eglib/CMakeLists.txt b/src/mono/mono/eglib/CMakeLists.txt index 1e3bd2545a34a..9a462d933a591 100644 --- a/src/mono/mono/eglib/CMakeLists.txt +++ b/src/mono/mono/eglib/CMakeLists.txt @@ -5,7 +5,7 @@ set(eglib_win32_sources set(eglib_unix_sources gdate-unix.c gdir-unix.c gfile-unix.c gmisc-unix.c - gmodule-unix.c gtimer-unix.c) + gmodule-unix.c gtimer-unix.c gclock-nanosleep.c) if(HOST_WIN32) set(eglib_platform_sources ${eglib_win32_sources}) @@ -41,7 +41,6 @@ set(eglib_common_sources gmarkup.c gutf8.c gunicode.c - gclock-nanosleep.c unicode-data.h) addprefix(eglib_sources ../eglib/ "${eglib_platform_sources};${eglib_common_sources}") diff --git a/src/mono/mono/eglib/glib.h b/src/mono/mono/eglib/glib.h index edb0b9efaed0e..5cc269957307e 100644 --- a/src/mono/mono/eglib/glib.h +++ b/src/mono/mono/eglib/glib.h @@ -1511,7 +1511,9 @@ mono_qsort (void* base, size_t num, size_t size, int (*compare)(const void*, con * Clock Nanosleep */ +#ifdef HAVE_CLOCK_NANOSLEEP gint g_clock_nanosleep (clockid_t clockid, gint flags, const struct timespec *request, struct timespec *remain); +#endif #endif // __GLIB_H From d420457d0ff7bdd5df57bd16098dec7bd8aec2ed Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Mon, 7 Feb 2022 22:34:47 +0100 Subject: [PATCH 8/8] Try making wasm builds happy --- src/mono/mono/eglib/CMakeLists.txt | 6 +++++- src/mono/mono/eglib/eglib-remap.h | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/eglib/CMakeLists.txt b/src/mono/mono/eglib/CMakeLists.txt index 9a462d933a591..69bf7e188696b 100644 --- a/src/mono/mono/eglib/CMakeLists.txt +++ b/src/mono/mono/eglib/CMakeLists.txt @@ -5,7 +5,7 @@ set(eglib_win32_sources set(eglib_unix_sources gdate-unix.c gdir-unix.c gfile-unix.c gmisc-unix.c - gmodule-unix.c gtimer-unix.c gclock-nanosleep.c) + gmodule-unix.c gtimer-unix.c) if(HOST_WIN32) set(eglib_platform_sources ${eglib_win32_sources}) @@ -43,6 +43,10 @@ set(eglib_common_sources gunicode.c unicode-data.h) +if(HAVE_CLOCK_NANOSLEEP) +list(APPEND eglib_common_sources gclock-nanosleep.c) +endif() + addprefix(eglib_sources ../eglib/ "${eglib_platform_sources};${eglib_common_sources}") add_library(eglib_objects OBJECT "${eglib_sources}") diff --git a/src/mono/mono/eglib/eglib-remap.h b/src/mono/mono/eglib/eglib-remap.h index 02bc3169e14ce..3af646a8e47b2 100644 --- a/src/mono/mono/eglib/eglib-remap.h +++ b/src/mono/mono/eglib/eglib-remap.h @@ -260,7 +260,6 @@ #define g_unichar_xdigit_value monoeg_g_unichar_xdigit_value #define g_unsetenv monoeg_g_unsetenv #define g_usleep monoeg_g_usleep -#define g_clock_nanosleep monoeg_clock_nanosleep #define g_utf16_to_ucs4 monoeg_g_utf16_to_ucs4 #define g_utf16_to_utf8 monoeg_g_utf16_to_utf8 #define g_utf16_to_utf8_custom_alloc monoeg_g_utf16_to_utf8_custom_alloc @@ -319,3 +318,7 @@ #define g_ascii_charcmp monoeg_ascii_charcmp #define g_ascii_charcasecmp monoeg_ascii_charcasecmp #define g_warning_d monoeg_warning_d + +#ifdef HAVE_CLOCK_NANOSLEEP +#define g_clock_nanosleep monoeg_clock_nanosleep +#endif