+#if HOST_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