X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=support%2Ferrno.c;h=76b4b388e9862170e2647ed127d1bf71017f1fbd;hb=30cddad5fb4c3d290906a6e6c33ecd8b07d8b48c;hp=a28425e03b84ab8a34617a148ba96577d4e3d939;hpb=234225d112c4b018b8d1796f4c06a15812137500;p=mono.git diff --git a/support/errno.c b/support/errno.c index a28425e03b8..76b4b388e98 100644 --- a/support/errno.c +++ b/support/errno.c @@ -4,16 +4,16 @@ #include #include +#include "map.h" #include "mph.h" #include G_BEGIN_DECLS -/* DEPRECATED: Use the Stdlib version instead */ -void -Mono_Posix_Syscall_SetLastError (int error_number) +int +Mono_Posix_Stdlib_GetLastError (void) { - errno = error_number; + return errno; } void @@ -86,7 +86,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 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 r = strerror_r (errnum, ebuf, sizeof(ebuf)); +#endif + if (!r) { + errno = EINVAL; + return -1; + } len = strlen (r); if (r == ebuf ||