Rename rand64() to _rand64()

This commit is contained in:
Justine Tunney 2022-10-10 04:12:06 -07:00
parent c424352a0a
commit 7ae556463a
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
52 changed files with 141 additions and 139 deletions

View file

@ -144,7 +144,7 @@ void MeatyReadWriteTest(void) {
char *mem, *buf;
n = 8 * 1024 * 1024;
buf = gc(malloc(n));
mem = rngset(gc(malloc(n)), n, rand64, -1);
mem = rngset(gc(malloc(n)), n, _rand64, -1);
ASSERT_NE(NULL, (f = fopen(PATH, "wb")));
setbuffer(f, gc(malloc(4 * 1000 * 1000)), 4 * 1000 * 1000);
EXPECT_EQ(n, fwrite(mem, 1, n, f));

View file

@ -180,7 +180,7 @@ uint64_t Rand64LowByte(void) {
uint64_t x;
for (x = i = 0; i < 8; ++i) {
x <<= 8;
x |= rand64() & 255;
x |= _rand64() & 255;
}
return x;
}
@ -203,7 +203,7 @@ static const struct RandomFunction {
{"SixthEditionLowByte", SixthEditionLowByte, false}, //
{"SeventhEditionLowByte", SeventhEditionLowByte, false}, //
{"KnuthLcg", KnuthLcg, false}, //
{"rand64", rand64, true}, //
{"rand64", _rand64, true}, //
{"Rand64LowByte", Rand64LowByte, true}, //
{"GetRandom", GetRandom, true}, //
};

View file

@ -16,14 +16,14 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/bits.h"
#include "libc/errno.h"
#include "libc/intrin/bits.h"
#include "libc/log/check.h"
#include "libc/macros.internal.h"
#include "libc/mem/mem.h"
#include "libc/stdio/rand.h"
#include "libc/mem/gc.internal.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/rand.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/grnd.h"
#include "libc/testlib/ezbench.h"
@ -157,14 +157,14 @@ TEST(mt19937, test) {
BENCH(mt19937, bench8) {
volatile uint64_t x;
EZBENCH2("lemur64", donothing, x = lemur64());
EZBENCH2("rand64", donothing, x = rand64());
EZBENCH2("_rand64", donothing, x = _rand64());
EZBENCH2("vigna", donothing, x = vigna());
EZBENCH2("vigna_r", donothing, vigna_r(&x));
EZBENCH2("xorshift", donothing, x = xorshift());
EZBENCH2("knuth", donothing, x = knuth());
EZBENCH2("random", donothing, x = urandom());
EZBENCH2("mt19937", donothing, x = _mt19937());
EZBENCH2("rand64char", donothing, x = rand64());
EZBENCH2("rand64char", donothing, x = _rand64());
size_t i = 0;
volatile uint8_t *p = gc(malloc(3 * 2048 * 2 * 8));
EZBENCH3("rdrand", 2048, donothing, p[i++] = rdrand());
@ -174,7 +174,7 @@ BENCH(mt19937, bench8) {
BENCH(mt19937, bench32k) {
volatile char *p = gc(malloc(32768));
EZBENCH_N("rngset(rand64,-1)", 32768, rngset(p, 32768, rand64, -1));
EZBENCH_N("rngset(_rand64,-1)", 32768, rngset(p, 32768, _rand64, -1));
EZBENCH_N("rngset(rdseed,512)", 32768, rngset(p, 32768, rdseed, 512));
EZBENCH_N("ctrdrbg+rdseed [blk]", 32768, ctrdrbg1(p, 32768));
EZBENCH_N("getrandom [block]", 32768, GetRandom(p, 32768));
@ -183,7 +183,7 @@ BENCH(mt19937, bench32k) {
EZBENCH_N("knuth [word]", 32768, knutha(p, 32768));
EZBENCH_N("random [word]", 32768, rngset(p, 32768, urandom, 0));
EZBENCH_N("mt19937 [word]", 32768, rngset(p, 32768, _mt19937, 0));
EZBENCH_N("rand64 [word]", 32768, rngset(p, 32768, rand64, 0));
EZBENCH_N("_rand64 [word]", 32768, rngset(p, 32768, _rand64, 0));
EZBENCH_N("rdrand [word]", 32768, rngset(p, 32768, rdrand, 0));
EZBENCH_N("rdseed [word]", 32768, rngset(p, 32768, rdseed, 0));
}

View file

@ -39,16 +39,16 @@ TEST(rand003, srandSmokeTest) {
}
TEST(rand005, rand64SmokeTest) {
ASSERT_TRUE(rand64() != rand64() || rand64() != rand64());
ASSERT_TRUE(_rand64() != _rand64() || _rand64() != _rand64());
}
TEST(rand64, test) {
TEST(_rand64, test) {
char *p;
size_t i;
uint64_t x;
p = memcpy(malloc(kHyperionSize), kHyperion, kHyperionSize);
for (i = 0; i < kHyperionSize / 8; ++i) {
x = rand64();
x = _rand64();
WRITE64LE(p + i * 8, x);
}
free(p);