blob: 4244b97a8c8e2e8107c3722910fece0337441f6c [file] [log] [blame]
Patrick Williamsddad1a12017-02-23 20:36:32 -06001From 45c855400842fd40f200ae9b7abf9debf4ab5436 Mon Sep 17 00:00:00 2001
2From: Christopher Kohlhoff <chris@kohlhoff.com>
3Date: Sun, 28 Aug 2016 09:21:53 +1000
4Subject: [PATCH] Automatically handle glibc variant of strerror_r without
5 #ifdefs.
6
7---
8Upstream-Status: Backport https://github.com/chriskohlhoff/asio/commit/443bc17d13eb5e37de780ea6e23157493cf7b3b9
9 include/asio/impl/error_code.ipp | 16 +++++++---------
10 1 file changed, 7 insertions(+), 9 deletions(-)
11
12diff --git a/include/asio/impl/error_code.ipp b/include/asio/impl/error_code.ipp
13index ccb70dd..a117658 100644
14--- a/include/asio/impl/error_code.ipp
15+++ b/include/asio/impl/error_code.ipp
16@@ -97,20 +97,18 @@ public:
17 #if defined(__sun) || defined(__QNX__) || defined(__SYMBIAN32__)
18 using namespace std;
19 return strerror(value);
20-#elif defined(__MACH__) && defined(__APPLE__) \
21- || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) \
22- || defined(_AIX) || defined(__hpux) || defined(__osf__) \
23- || defined(__ANDROID__)
24- char buf[256] = "";
25- using namespace std;
26- strerror_r(value, buf, sizeof(buf));
27- return buf;
28 #else
29 char buf[256] = "";
30- return strerror_r(value, buf, sizeof(buf));
31+ using namespace std;
32+ return strerror_result(strerror_r(value, buf, sizeof(buf)), buf);
33 #endif
34 #endif // defined(ASIO_WINDOWS)
35 }
36+
37+private:
38+ // Helper function to adapt the result from glibc's variant of strerror_r.
39+ static const char* strerror_result(int, const char* s) { return s; }
40+ static const char* strerror_result(const char* s, const char*) { return s; }
41 };
42
43 } // namespace detail
44--
452.9.3
46