Implemented the idea from D94571 to improve entropy on Linux.
Details
- Reviewers
ldionne - Group Reviewers
Restricted Project - Commits
- rGf3b979b65e9f: [libc++] Use ioctl when available to get random_device entropy.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxx/src/random.cpp | ||
---|---|---|
180 | This could be guarded even more if we wanted. E.g. defining _LIBCPP_USING_IOCTL/LINUX_RANDOM_H, but personally I think that just checking for RNDGETENTCNT is enough. |
@tcanens You may want to consider updating cppreference in light of this patch when it gets in.
This LGTM except for the test nitpick!
libcxx/test/std/numerics/rand/rand.device/entropy.pass.cpp | ||
---|---|---|
26–27 | I think we want to make those be LIBCPP_ASSERT(...) instead, since the entropy is technically not mandated by the standard. It's just that our implementation behaves that way. |
libcxx/src/random.cpp | ||
---|---|---|
33 | Should this be __has_include(<sys/ioctl.h>) instead? |
libcxx/src/random.cpp | ||
---|---|---|
33 | Oops, good catch. | |
libcxx/test/std/numerics/rand/rand.device/entropy.pass.cpp | ||
26–27 | The standard says this http://eel.is/c++draft/rand.device#5. So entropy should be between min and log2(max+1), where max is max of result_type. |
Should this be __has_include(<sys/ioctl.h>) instead?