[PATCH] libc++: add NaCl and PNaCl support for std::random_device

Marshall Clow mclow.lists at gmail.com
Mon Dec 1 08:57:12 PST 2014


Your changes look good; but now I'm wondering if you want to accept both `"/dev/random"` and `"/dev/urandom"` as valid tokens.

Now I'm wondering what bozo checked in the windows implementation w/o noticing that it broke this test on Windows. Oh - that was me.

Should the windows implementation also accept only `"/dev/random"` and `"/dev/urandom"` as valid tokens?

That would enable us to make the test portable; and help people to write cross-platform code.

================
Comment at: include/__config:118
@@ +117,3 @@
+  // std::random_device is instead exposed through a NaCl syscall.
+# define _LIBCPP_USING_NACL_RANDOM 1
+#endif // defined(__native_client__)
----------------
I don't think you need to actually set `_LIBCPP_USING_NACL_RANDOM` to a value.

    #define _LIBCPP_USING_NACL_RANDOM

is sufficient.

================
Comment at: test/numerics/rand/rand.device/ctor.pass.cpp:34
@@ +33,3 @@
+#endif // defined(_WIN32) || defined(_LIBCPP_USING_NACL_RANDOM)
+}
+
----------------
I don't really like this; it's leaking implementation information into the test framework.

http://reviews.llvm.org/D6442






More information about the cfe-commits mailing list