From 22ca1336dcfb663d86a6892dbe1e48eee20bb6db Mon Sep 17 00:00:00 2001 From: dim Date: Wed, 5 Mar 2014 19:30:36 +0000 Subject: MFC r261283: Import libc++ 3.4 release. This contains a lot of bugfixes, and some preliminary support for C++1y. MFC r261604: HEAD is not buildable for the past day. Commit a 'quick fix' in order to permit buildworld to complete. Reviewed by: theraven MFC r261608: Apply a cleaner solution for the sign warnings that can occur when compiling libc++'s header with -Wsystem-headers on. This has also been submitted upstream. Reported by: asomers MFC r261801: An ABI incompatibility crept into the libc++ 3.4 import in r261283. It was caused by upstream libc++ commit r194536, which aimed to make the headers more standards-compliant, by making std::pair's copy constructor trivial. Unfortunately, this could cause certain C++ applications using shared libraries built against the previous version of libc++ to crash. Fix the ABI incompatibility by making std::pair's copy constructor non-trivial again. Please note: Any C++ applications or shared libraries built with libc++ between r261283 and this revision should be recompiled. Reported by: stefanf --- contrib/libc++/src/random.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'contrib/libc++/src/random.cpp') diff --git a/contrib/libc++/src/random.cpp b/contrib/libc++/src/random.cpp index 97a40c5..bd24f2e 100644 --- a/contrib/libc++/src/random.cpp +++ b/contrib/libc++/src/random.cpp @@ -7,18 +7,45 @@ // //===----------------------------------------------------------------------===// +#if defined(_WIN32) +// Must be defined before including stdlib.h to enable rand_s(). +#define _CRT_RAND_S +#include +#endif + #include "random" #include "system_error" #ifdef __sun__ #define rename solaris_headers_are_broken #endif +#if !defined(_WIN32) #include #include +#endif // defined(_WIN32) #include _LIBCPP_BEGIN_NAMESPACE_STD +#if defined(_WIN32) +random_device::random_device(const string&) +{ +} + +random_device::~random_device() +{ +} + +unsigned +random_device::operator()() +{ + unsigned r; + errno_t err = rand_s(&r); + if (err) + __throw_system_error(err, "random_device rand_s failed."); + return r; +} +#else random_device::random_device(const string& __token) : __f_(open(__token.c_str(), O_RDONLY)) { @@ -38,6 +65,7 @@ random_device::operator()() read(__f_, &r, sizeof(r)); return r; } +#endif // defined(_WIN32) double random_device::entropy() const _NOEXCEPT -- cgit v1.1