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:
authorMarek Habersack <grendel@twistedcode.net>2015-08-03 17:48:25 +0300
committerMarek Habersack <grendel@twistedcode.net>2015-08-13 12:53:28 +0300
commit7fe7f931887baa2968b081725bb417ebc368dc01 (patch)
treebcd89e086a554a4798a4b249b07946a272ac7170 /support
parent5511b94946f756c3bcf8b6e51ab28ddf313a4111 (diff)
Posix RTS test fixes and Android compatibility
Android's libc (bionic) defines the _GNU_SOURCE macro but fails to adhere to the GNU sematics in (at least) one case - the strerror_r function. The function follows XSI semantics instead of the GNU one which caused our code to segfault on Android. This patch special-cases Android to use the XSI semantics for strerror_r. This un-breaks some POSX real-time singals tests. It also makes provisions for detecting whether the real-time signals are safe to use on the current platform. They are safe for all platforms desktop Mono runs on, but they're not safe on most Android platforms.
Diffstat (limited to 'support')
-rw-r--r--support/errno.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/support/errno.c b/support/errno.c
index 26ee7801691..384451da47c 100644
--- a/support/errno.c
+++ b/support/errno.c
@@ -35,7 +35,7 @@ Mono_Posix_Stdlib_SetLastError (int error_number)
* we assume that the XPG version is present.
*/
-#ifdef _GNU_SOURCE
+#ifdef _GNU_SOURCE && !PLATFORM_ANDROID
#define mph_min(x,y) ((x) <= (y) ? (x) : (y))
/* If you pass an invalid errno value to glibc 2.3.2's strerror_r, you get
@@ -80,7 +80,27 @@ Mono_Posix_Syscall_strerror_r (int errnum, char *buf, mph_size_t n)
mph_return_if_size_t_overflow (n);
/* first, check for valid errnum */
+#if PLATFORM_ANDROID
+ /* Android NDK defines _GNU_SOURCE but strerror_r follows the XSI semantics
+ * not the GNU one. XSI version returns an integer, as opposed to the GNU one
+ * which returns pointer to the buffer.
+ */
+ if (strerror_r (errnum, ebuf, sizeof(ebuf)) == -1) {
+ /* XSI strerror_r will return -1 if errno is set, but if we leave the value
+ * alone it breaks Mono.Posix StdioFileStream tests, so we'll ignore the value
+ * and set errno as below
+ */
+ errno = EINVAL;
+ return -1;
+ }
+ r = ebuf;
+#else
r = strerror_r (errnum, ebuf, sizeof(ebuf));
+#endif
+ if (!r) {
+ errno = EINVAL;
+ return -1;
+ }
len = strlen (r);
if (r == ebuf ||