From 2fbf2718c4f6d4c79982f1b332fd67ec39a5bf42 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Mon, 18 Dec 2006 12:44:08 +0000 Subject: [PATCH] In errno_md, for Sun and HP, always use strerror because it is always available and always thread safe on those systems. Linux, provide macro since there is no way to tell if available at runtime. [SVN r36447] --- src/error_code.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/error_code.cpp b/src/error_code.cpp index 8d403c6..b9880c0 100644 --- a/src/error_code.cpp +++ b/src/error_code.cpp @@ -182,7 +182,15 @@ namespace std::string errno_md( const error_code & ec ) { -# if defined(BOOST_WINDOWS_API) || defined(__hpux) || (defined(__linux) && !defined(__USE_XOPEN2K)) + // strerror_r is preferred because it is always thread safe, + // however, we fallback to strerror in certain cases because: + // -- Windows doesn't provide strerror_r. + // -- HP and Sundo provide strerror_r on newer systems, but there is + // no way to tell if is available at runtime and in any case their + // versions of strerror are thread safe anyhow. + // -- Linux only sometimes provides strerror_r. +# if defined(BOOST_WINDOWS_API) || defined(__hpux) || defined(__sun)\ + || (defined(__linux) && (!defined(__USE_XOPEN2K) || defined(BOOST_SYSTEM_USE_STRERROR))) const char * c_str = std::strerror( ec.value() ); return std::string( c_str ? c_str : "EINVAL" ); # else