Skip to content

Commit

Permalink
system_error: provide a thread safe stringification for Windows
Browse files Browse the repository at this point in the history
Provide a strerror_r replacement for Windows.  This is needed to build
libc++ for Windows with threading.

llvm-svn: 290851
  • Loading branch information
compnerd committed Jan 3, 2017
1 parent 790e10f commit edd09b3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libcxx/src/system_error.cpp
Expand Up @@ -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];
Expand Down

0 comments on commit edd09b3

Please sign in to comment.