Fix issues with previous commit

This commit is contained in:
Justine Tunney 2024-09-10 01:59:46 -07:00
parent 2f48a02b44
commit a0a404a431
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
8 changed files with 122 additions and 57 deletions

View file

@ -16,10 +16,34 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/assert.h"
#include "libc/stdio/rand.h"
#include "libc/testlib/benchmark.h"
#include "libc/testlib/testlib.h"
uint64_t getrandom64(void) {
uint64_t x;
unassert(getrandom(&x, 8, 0) == 8);
return x;
}
uint64_t getentropy64(void) {
uint64_t x;
unassert(!getentropy(&x, 8));
return x;
}
TEST(lemur64, test) {
EXPECT_EQ(1819718037028923529, lemur64());
EXPECT_EQ(-3120132252617434764, lemur64());
}
BENCH(lemur64, bench) {
BENCHMARK(10000, 8, X(lemur64()));
BENCHMARK(10000, 4, X(rand()));
BENCHMARK(10000, 8, X(_rand64()));
BENCHMARK(10000, 8, X(rdrand()));
BENCHMARK(10000, 8, X(rdseed()));
BENCHMARK(10000, 8, X(getrandom64()));
BENCHMARK(10000, 8, X(getentropy64()));
}