libc++: add NaCl and PNaCl support for std::random_device

Summary:
The NaCl sandbox doesn't allow opening files under /dev, but it offers an API which provides the same capabilities. This is the same random device emulation that nacl_io performs for POSIX support, but nacl_io is an optional library so libc++ can't assume that device emulation will be performed. Note that NaCl only supports /dev/urandom, not /dev/random.

This patch also cleans up some of the preprocessor #endif, and fixes the test for Win32 (it accepts any token, and would therefore never throw regardless of the token provided).

Test Plan: ninja check-libcxx

Reviewers: dschuff, mclow.lists, danalbert

Subscribers: jfb, cfe-commits

Differential Revision: http://reviews.llvm.org/D6442

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@223068 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
JF Bastien
2014-12-01 19:19:55 +00:00
parent 6317e9b85a
commit 2bd5ffd330
4 changed files with 118 additions and 38 deletions

View File

@@ -3475,9 +3475,9 @@ typedef shuffle_order_engine<minstd_rand0, 256> knuth_b;
class _LIBCPP_TYPE_VIS random_device
{
#if !defined(_WIN32)
#if !(defined(_WIN32) || defined(_LIBCPP_USING_NACL_RANDOM))
int __f_;
#endif // defined(_WIN32)
#endif // !(defined(_WIN32) || defined(_LIBCPP_USING_NACL_RANDOM))
public:
// types
typedef unsigned result_type;