[PATCH] D41316: [libcxx] Allow random_device to be built optionally

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 16 07:04:14 PST 2017


Quuxplusone added a comment.

I keep seeing patches go by for other targets where they're just implementing `random_device` for their target. It doesn't *have* to be based on an actual /dev/urandom. You can see all the other options under #ifdefs in this file: getentropy, /dev/random, nacl_secure_random, arc4random, rand_s,... If you're on a target that doesn't have any of these, then IMO the appropriate patch would be one of

- #ifdef _LIBCPP_USING_YOURPLATFORM_RANDOM
- #ifdef _LIBCPP_USING_ALWAYSZERO_RANDOM

where the latter provides a "random_device" that yields nothing but zeroes. That would still be very slightly better than providing a non-conforming implementation. (And notice that the useless `double random_device::entropy()` method will for the first time return a *mathematically correct* value for the always-zero random_device! ;))


Repository:
  rCXX libc++

https://reviews.llvm.org/D41316





More information about the cfe-commits mailing list