HADOOP-19170. Fixes compilation issues on non-Linux systems (#6822)

Reviewed-by: Steve Loughran <stevel@apache.org>
Reviewed-by: Wei-Chiu Chuang <weichiu@apache.org>
This commit is contained in:
zhengchenyu 2024-05-14 11:04:01 +08:00 committed by GitHub
parent c9270600b7
commit 4cb4d5dd08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -110,9 +110,16 @@ jthrowable newIOException(JNIEnv* env, const char *fmt, ...)
const char* terror(int errnum) const char* terror(int errnum)
{ {
#if defined(__sun) || defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 32)
// MT-Safe under Solaris or glibc >= 2.32 not supporting sys_errlist/sys_nerr // MT-Safe under Solaris or glibc >= 2.32 not supporting sys_errlist/sys_nerr
#if defined(__sun)
#define USE_STR_ERROR
#elif defined(__GLIBC_PREREQ)
#if __GLIBC_PREREQ(2, 32)
#define USE_STR_ERROR
#endif
#endif
#if defined(USE_STR_ERROR)
return strerror(errnum); return strerror(errnum);
#else #else
if ((errnum < 0) || (errnum >= sys_nerr)) { if ((errnum < 0) || (errnum >= sys_nerr)) {
@ -121,4 +128,3 @@ const char* terror(int errnum)
return sys_errlist[errnum]; return sys_errlist[errnum];
#endif #endif
} }