Stop trying to guess whether we're using glibc when we already know.
Necessary to fix the x86_64 build.
Change-Id: Idb7b793ba478feba4389e623529674ce64caecb7
diff --git a/JNIHelp.cpp b/JNIHelp.cpp
index 5d9cc56..9f444bb 100644
--- a/JNIHelp.cpp
+++ b/JNIHelp.cpp
@@ -288,24 +288,20 @@
}
const char* jniStrError(int errnum, char* buf, size_t buflen) {
+#if __GLIBC__
// Note: glibc has a nonstandard strerror_r that returns char* rather than POSIX's int.
// char *strerror_r(int errnum, char *buf, size_t n);
- char* ret = (char*) strerror_r(errnum, buf, buflen);
- if (((int)ret) == 0) {
- // POSIX strerror_r, success
- return buf;
- } else if (((int)ret) == -1) {
- // POSIX strerror_r, failure
- // (Strictly, POSIX only guarantees a value other than 0. The safest
+ return strerror_r(errnum, buf, buflen);
+#else
+ int rc = strerror_r(errnum, buf, buflen);
+ if (rc != 0) {
+ // (POSIX only guarantees a value other than 0. The safest
// way to implement this function is to use C++ and overload on the
- // type of strerror_r to accurately distinguish GNU from POSIX. But
- // realistic implementations will always return -1.)
+ // type of strerror_r to accurately distinguish GNU from POSIX.)
snprintf(buf, buflen, "errno %d", errnum);
- return buf;
- } else {
- // glibc strerror_r returning a string
- return ret;
}
+ return buf;
+#endif
}
jobject jniCreateFileDescriptor(C_JNIEnv* env, int fd) {