-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Android] Workaround for invalid return value from clock_nanosleep (#…
…64679) There used to be a bug in Android libc implementation of `clock_nanosleep`. The return value should be `errno` on errors but instead in it returns `-1` and sets `errno`. The libc (Bionic) bug [has been fixed](https://android-review.googlesource.com/c/platform/bionic/+/110652/) since Android 6 and newer but it causes problems to [customers who are unable to update Android on their devices](dotnet/android#6600 (comment)). Fixes dotnet/android#6600 * Account for incorrect implementation of clock_nanosleep in older Android libc * Shorten comments * Add g_clock_nanosleep function * Add remap definition * Fix build * Make sure the extra check runs only on Android * Make Windows builds happy * Try making wasm builds happy
- Loading branch information
1 parent
aaaa2a7
commit ac82c68
Showing
7 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters