generalise strerror_r preprocessor switch (#1026)

same approach as in https://reviews.llvm.org/D25071
This commit is contained in:
Maik Riechert 2019-05-14 21:11:32 +01:00 committed by Changming Sun
parent d32d2fbfb7
commit f5dfde33d0
2 changed files with 2 additions and 4 deletions

View file

@ -236,10 +236,9 @@ void LoopDir(const std::string& dir_name, T func) {
auto e = errno;
char buf[1024];
char* msg;
#if defined(_GNU_SOURCE) && !defined(__APPLE__)
#if defined(__GLIBC__) && defined(_GNU_SOURCE)
msg = strerror_r(e, buf, sizeof(buf));
#else
// for Mac OS X
if (strerror_r(e, buf, sizeof(buf)) != 0) {
buf[0] = '\0';
}

View file

@ -180,10 +180,9 @@ class PosixEnv : public Env {
char buf[1024];
const char* msg = "";
if (e > 0) {
#if defined(_GNU_SOURCE) && !defined(__APPLE__)
#if defined(__GLIBC__) && defined(_GNU_SOURCE)
msg = strerror_r(e, buf, sizeof(buf));
#else
// for Mac OS X
if (strerror_r(e, buf, sizeof(buf)) != 0) {
buf[0] = '\0';
}