From f5dfde33d03605b1a18c4b6ba36e86d5cdffd4f3 Mon Sep 17 00:00:00 2001 From: Maik Riechert Date: Tue, 14 May 2019 21:11:32 +0100 Subject: [PATCH] generalise strerror_r preprocessor switch (#1026) same approach as in https://reviews.llvm.org/D25071 --- onnxruntime/core/framework/path_lib.h | 3 +-- onnxruntime/core/platform/posix/env.cc | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/onnxruntime/core/framework/path_lib.h b/onnxruntime/core/framework/path_lib.h index 7845bbf535..3832fd5522 100644 --- a/onnxruntime/core/framework/path_lib.h +++ b/onnxruntime/core/framework/path_lib.h @@ -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'; } diff --git a/onnxruntime/core/platform/posix/env.cc b/onnxruntime/core/platform/posix/env.cc index 7cabf71753..92375f6f31 100644 --- a/onnxruntime/core/platform/posix/env.cc +++ b/onnxruntime/core/platform/posix/env.cc @@ -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'; }