Fix build on Android NDK

where XSI-compliant version of strerror_r is used violating the docs at
http://linux.die.net/man/3/strerror_r
This commit is contained in:
Victor Zverovich 2015-02-05 07:04:22 -08:00
parent b4eef59100
commit bdeffc3fdc

View File

@ -134,7 +134,13 @@ int safe_strerror(
int error_code, char *&buffer, std::size_t buffer_size) FMT_NOEXCEPT(true) { int error_code, char *&buffer, std::size_t buffer_size) FMT_NOEXCEPT(true) {
assert(buffer != 0 && buffer_size != 0); assert(buffer != 0 && buffer_size != 0);
int result = 0; int result = 0;
#ifdef _GNU_SOURCE #if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE) || __ANDROID__
// XSI-compliant version of strerror_r.
result = strerror_r(error_code, buffer, buffer_size);
if (result != 0)
result = errno;
#elif _GNU_SOURCE
// GNU-specific version of strerror_r.
char *message = strerror_r(error_code, buffer, buffer_size); char *message = strerror_r(error_code, buffer, buffer_size);
// If the buffer is full then the message is probably truncated. // If the buffer is full then the message is probably truncated.
if (message == buffer && strlen(buffer) == buffer_size - 1) if (message == buffer && strlen(buffer) == buffer_size - 1)