summaryrefslogtreecommitdiffstats
path: root/libcxx/src/system_error.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/src/system_error.cpp')
-rw-r--r--libcxx/src/system_error.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/libcxx/src/system_error.cpp b/libcxx/src/system_error.cpp
index 4ecafeaa3b8..b00e461cc8f 100644
--- a/libcxx/src/system_error.cpp
+++ b/libcxx/src/system_error.cpp
@@ -65,8 +65,16 @@ constexpr size_t strerror_buff_size = 1024;
string do_strerror_r(int ev);
-#if defined(__linux__) && !defined(_LIBCPP_HAS_MUSL_LIBC) \
- && (!defined(__ANDROID__) || __ANDROID_API__ >= 23)
+#if defined(_WIN32)
+string do_strerror_r(int ev) {
+ char buffer[strerror_buff_size];
+ if (::strerror_s(buffer, strerror_buff_size, ev) == 0)
+ return string(buffer);
+ std::snprintf(buffer, strerror_buff_size, "unknown error %d", ev);
+ return string(buffer);
+}
+#elif defined(__linux__) && !defined(_LIBCPP_HAS_MUSL_LIBC) && \
+ (!defined(__ANDROID__) || __ANDROID_API__ >= 23)
// GNU Extended version
string do_strerror_r(int ev) {
char buffer[strerror_buff_size];
OpenPOWER on IntegriCloud