Use this source use on Fuchsia where this is the officially way
to obtain randomness. This could be also used on other platforms
that already support getentropy such as *BSD or Linux.
Details
- Reviewers
EricWF mcgrathr mclow.lists - Commits
- rG5c704281767f: [libcxx] Support getentropy as a source of randomness for std::random_device
rCXX319523: [libcxx] Support getentropy as a source of randomness for std::random_device
rL319523: [libcxx] Support getentropy as a source of randomness for std::random_device
Diff Detail
- Repository
- rL LLVM
Event Timeline
libcxx/trunk/src/random.cpp | ||
---|---|---|
29 | musl only declares getentropy in <unistd.h> not <sys/random.h>. Glibc declares it in both. Should <unistd.h> also be included when _LIBCPP_USING_GETENTROPY is defined, so it can work more portably? |
libcxx/trunk/src/random.cpp | ||
---|---|---|
29 | I suppose it doesn't really matter, since _LIBCPP_USING_GETENTROPY is currently only defined for fuchsia and wasi, which both declare getentropy in <sys/random.h>. |
libcxx/trunk/src/random.cpp | ||
---|---|---|
29 | FWIW, if there is an emerging norm to declare getentropy in <unistd.h> then Fuchsia's libc can add it to our <unistd.h> and there's no real problem relying on that in libc++ sources within about a week of when we land that change in Fuchsia's trunk. |
libcxx/trunk/src/random.cpp | ||
---|---|---|
29 | @fweimer added it to glibc's unistd.h for compatibility with existing BSD code: Maybe @dalias can confirm whether musl did it for the same reason? Does it make sense to "standardize" on declaring getentropy in unistd.h? |
getentropy comes from OpenBSD (among others), and it's in <unistd.h> there: https://man.openbsd.org/getentropy.2
musl only declares getentropy in <unistd.h> not <sys/random.h>. Glibc declares it in both. Should <unistd.h> also be included when _LIBCPP_USING_GETENTROPY is defined, so it can work more portably?