[libc-commits] [PATCH] D147981: [LIBC] Fix `getrandom` success return value
Michael Jones via Phabricator via libc-commits
libc-commits at lists.llvm.org
Wed Apr 12 11:42:41 PDT 2023
michaelrj added inline comments.
================
Comment at: libc/test/src/sys/random/linux/getrandom_test.cpp:35
+ uint8_t buf[SIZE];
+ for (size_t i = 0; i < SIZE; i += 1 + (i % 64)) {
+ // Without GRND_RANDOM set, this should never fail
----------------
goldstein.w.n wrote:
> michaelrj wrote:
> > I'm not sure why the mod operation is here, maybe add a comment explaining?
> > I'm not sure why the mod operation is here, maybe add a comment explaining?
>
> Its just meant to be a compromise between not doing every single value and getting a decent spread. Could also be `rand % 64` or something like that, but figured that might make test harder to reproduce.
>
> `64` should probably be a prime in retrospect.
Given that the range tested is only 8192 it's not a big deal to do the whole range. The pi estimation test below is performing 10,000,000 samples (with two calls each), and that's having a much greater effect on the runtime of this test.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147981/new/
https://reviews.llvm.org/D147981
More information about the libc-commits
mailing list