Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mono/eglib/gclock-nanosleep.c')
-rw-r--r--mono/eglib/gclock-nanosleep.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/mono/eglib/gclock-nanosleep.c b/mono/eglib/gclock-nanosleep.c
new file mode 100644
index 00000000000..f2ced8b2c07
--- /dev/null
+++ b/mono/eglib/gclock-nanosleep.c
@@ -0,0 +1,31 @@
+/*
+ * 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 <config.h>
+#include <glib.h>
+#include <errno.h>
+
+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
+
+#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;
+}