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

@ -68,7 +68,7 @@ TEST(BLAKE2B256Test, ABC) {
BENCH(blake2, bench) {
char fun[256];
rngset(fun, 256, rand64, -1);
rngset(fun, 256, _rand64, -1);
EZBENCH_N("blake2b256", 0, EZBLAKE2B256(0, 0));
EZBENCH_N("blake2b256", 8, EZBLAKE2B256("helloooo", 8));
EZBENCH_N("blake2b256", 31, EZBLAKE2B256(fun, 31));

View file

@ -16,9 +16,9 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/mem/gc.internal.h"
#include "libc/mem/mem.h"
#include "libc/stdio/rand.h"
#include "libc/mem/gc.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/testlib/ezbench.h"
@ -30,7 +30,7 @@ TEST(bzero, test) {
a = gc(malloc(128));
b = gc(malloc(128));
for (n = 0; n < 128; ++n) {
rngset(a, 128, rand64, -1);
rngset(a, 128, _rand64, -1);
memcpy(b, a, 128);
bzero(a, n);
memset(b, 0, n);

View file

@ -96,7 +96,7 @@ TEST(highwayhash64, test) {
BENCH(highwayhash64, newbench) {
char fun[256];
rngset(fun, 256, rand64, -1);
rngset(fun, 256, _rand64, -1);
EZBENCH_N("highwayhash64", 0, HighwayHash64(0, 0, kTestKey1));
EZBENCH_N("highwayhash64", 8, HighwayHash64("helloooo", 8, kTestKey1));
EZBENCH_N("highwayhash64", 31, HighwayHash64(fun, 31, kTestKey1));

View file

@ -56,7 +56,7 @@ TEST(memccpy, memcpy) {
b1 = calloc(1, n);
b2 = calloc(1, n);
b3 = calloc(1, n);
rngset(b1, n, rand64, -1);
rngset(b1, n, _rand64, -1);
e1 = memccpy_pure(b2, b1, 31337, n);
e2 = memccpy(b3, b1, 31337, n);
n1 = e1 ? e1 - b2 : n;

View file

@ -30,8 +30,8 @@ TEST(memcpy, test) {
for (unsigned n = 0; n < 1026; ++n) {
b1 = malloc(n);
b2 = malloc(n);
rngset(b1, n, rand64, -1);
rngset(b2, n, rand64, -1);
rngset(b1, n, _rand64, -1);
rngset(b2, n, _rand64, -1);
ASSERT_EQ(b1, memcpy(b1, b2, n), "%ld\n\t%#.*s\n\t%#.*s", n, n, b1, n, b2);
ASSERT_EQ(0, memcmp(b1, b2, n));
free(b2);
@ -40,8 +40,8 @@ TEST(memcpy, test) {
for (unsigned n = kHalfCache3 - 1; n < kHalfCache3 + 2; ++n) {
b1 = malloc(n);
b2 = malloc(n);
rngset(b1, n, rand64, -1);
rngset(b2, n, rand64, -1);
rngset(b1, n, _rand64, -1);
rngset(b2, n, _rand64, -1);
ASSERT_EQ(b1, memcpy(b1, b2, n), "%ld\n\t%#.*s\n\t%#.*s", n, n, b1, n, b2);
ASSERT_EQ(0, memcmp(b1, b2, n));
free(b2);
@ -54,8 +54,8 @@ TEST(mempcpy, test) {
for (unsigned n = 0; n < 1026; ++n) {
b1 = malloc(n);
b2 = malloc(n);
rngset(b1, n, rand64, -1);
rngset(b2, n, rand64, -1);
rngset(b1, n, _rand64, -1);
rngset(b2, n, _rand64, -1);
ASSERT_EQ(b1 + n, mempcpy(b1, b2, n));
ASSERT_EQ(0, memcmp(b1, b2, n));
free(b2);
@ -64,8 +64,8 @@ TEST(mempcpy, test) {
for (unsigned n = kHalfCache3 - 1; n < kHalfCache3 + 2; ++n) {
b1 = malloc(n);
b2 = malloc(n);
rngset(b1, n, rand64, -1);
rngset(b2, n, rand64, -1);
rngset(b1, n, _rand64, -1);
rngset(b2, n, _rand64, -1);
ASSERT_EQ(b1 + n, mempcpy(b1, b2, n));
ASSERT_EQ(0, memcmp(b1, b2, n));
free(b2);
@ -78,8 +78,8 @@ TEST(memcpy, direct) {
for (unsigned n = 0; n < 1026; ++n) {
b1 = malloc(n);
b2 = malloc(n);
rngset(b1, n, rand64, -1);
rngset(b2, n, rand64, -1);
rngset(b1, n, _rand64, -1);
rngset(b2, n, _rand64, -1);
ASSERT_EQ(b1, (memcpy)(b1, b2, n), "%ld\n\t%#.*s\n\t%#.*s", n, n, b1, n,
b2);
ASSERT_EQ(0, memcmp(b1, b2, n));
@ -89,8 +89,8 @@ TEST(memcpy, direct) {
for (unsigned n = kHalfCache3 - 1; n < kHalfCache3 + 2; ++n) {
b1 = malloc(n);
b2 = malloc(n);
rngset(b1, n, rand64, -1);
rngset(b2, n, rand64, -1);
rngset(b1, n, _rand64, -1);
rngset(b2, n, _rand64, -1);
ASSERT_EQ(b1, (memcpy)(b1, b2, n), "%ld\n\t%#.*s\n\t%#.*s", n, n, b1, n,
b2);
ASSERT_EQ(0, memcmp(b1, b2, n));
@ -104,8 +104,8 @@ TEST(mempcpy, direct) {
for (unsigned n = 0; n < 1026; ++n) {
b1 = malloc(n);
b2 = malloc(n);
rngset(b1, n, rand64, -1);
rngset(b2, n, rand64, -1);
rngset(b1, n, _rand64, -1);
rngset(b2, n, _rand64, -1);
ASSERT_EQ(b1 + n, (mempcpy)(b1, b2, n));
ASSERT_EQ(0, memcmp(b1, b2, n));
free(b2);
@ -114,8 +114,8 @@ TEST(mempcpy, direct) {
for (unsigned n = kHalfCache3 - 1; n < kHalfCache3 + 2; ++n) {
b1 = malloc(n);
b2 = malloc(n);
rngset(b1, n, rand64, -1);
rngset(b2, n, rand64, -1);
rngset(b1, n, _rand64, -1);
rngset(b2, n, _rand64, -1);
ASSERT_EQ(b1 + n, (mempcpy)(b1, b2, n));
ASSERT_EQ(0, memcmp(b1, b2, n));
free(b2);
@ -162,8 +162,8 @@ TEST(memcpy, testBackwardsOverlap3) {
#define B(F, N) \
do { \
char *d = rngset(malloc(N), N, rand64, -1); \
char *s = rngset(malloc(N), N, rand64, -1); \
char *d = rngset(malloc(N), N, _rand64, -1); \
char *s = rngset(malloc(N), N, _rand64, -1); \
EZBENCH2(#F " " #N, donothing, \
EXPROPRIATE(F(VEIL("r", d), VEIL("r", s), N))); \
free(d); \

View file

@ -118,7 +118,7 @@ TEST(memchr, fuzz) {
p = malloc(64);
for (i = -2; i < 257; ++i) {
for (j = 0; j < 17; ++j) {
rngset(p, 64, rand64, -1);
rngset(p, 64, _rand64, -1);
ASSERT_EQ(memchr(p + j, i, 64 - j), memchr_pure(p + j, i, 64 - j));
}
}
@ -139,7 +139,7 @@ TEST(strchrnul, fuzz) {
p = calloc(1, 64);
for (i = -2; i < 257; ++i) {
for (j = 0; j < 17; ++j) {
rngset(p, 63, rand64, -1);
rngset(p, 63, _rand64, -1);
ASSERT_EQ(strchrnul(p + j, i), strchrnul_pure(p + j, i));
}
}
@ -159,7 +159,7 @@ TEST(rawmemchr, fuzz) {
p = malloc(64);
for (i = -2; i < 257; ++i) {
for (j = 0; j < 17; ++j) {
rngset(p, 63, rand64, -1);
rngset(p, 63, _rand64, -1);
p[63] = i;
ASSERT_EQ(rawmemchr(p + j, i), rawmemchr_pure(p + j, i));
}

View file

@ -20,10 +20,10 @@
#include "libc/dce.h"
#include "libc/intrin/bits.h"
#include "libc/macros.internal.h"
#include "libc/mem/gc.internal.h"
#include "libc/mem/mem.h"
#include "libc/nexgen32e/cachesize.h"
#include "libc/nexgen32e/x86feature.h"
#include "libc/mem/gc.internal.h"
#include "libc/stdio/rand.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
@ -506,7 +506,7 @@ dontinline int strcasecmp_pure(const char *a, const char *b) {
}
char *randomize_buf2str(size_t size, char data[size]) {
rngset(data, size, rand64, -1);
rngset(data, size, _rand64, -1);
data[size - 1] = '\0';
return data;
}