Skip to content

Commit 7ae5564

Browse files
committed
Rename rand64() to _rand64()
1 parent c424352 commit 7ae5564

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+141
-139
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,15 @@ $(SRCS): \
402402
libc/integral/lp64arg.inc \
403403
libc/integral/lp64.inc
404404

405+
.PHONY: toolchain
406+
toolchain: o/cosmopolitan.h \
407+
o/$(MODE)/ape/public/ape.lds \
408+
o/$(MODE)/libc/crt/crt.o \
409+
o/$(MODE)/ape/ape.o \
410+
o/$(MODE)/ape/ape-copy-self.o \
411+
o/$(MODE)/ape/ape-no-modify-self.o \
412+
o/$(MODE)/cosmopolitan.a
413+
405414
# UNSPECIFIED PREREQUISITES TUTORIAL
406415
#
407416
# A build rule must exist for all files that make needs to consider in

examples/forkrand.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,12 @@
99
#endif
1010
#include "libc/calls/calls.h"
1111
#include "libc/log/check.h"
12-
#include "libc/log/log.h"
13-
#include "libc/nt/nt/process.h"
14-
#include "libc/mem/gc.h"
15-
#include "libc/runtime/memtrack.internal.h"
16-
#include "libc/runtime/runtime.h"
1712
#include "libc/stdio/rand.h"
1813
#include "libc/stdio/stdio.h"
19-
#include "libc/time/time.h"
20-
#include "libc/x/x.h"
2114

2215
dontinline void dostuff(const char *s) {
2316
int i, us;
24-
srand(rand64()); /* seeds rand() w/ intel rdrnd, auxv, etc. */
17+
srand(_rand64()); /* seeds rand() w/ intel rdrnd, auxv, etc. */
2518
for (i = 0; i < 5; ++i) {
2619
us = rand() % 500000;
2720
usleep(us);

examples/getrandom.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ uint64_t rngset64(void) {
102102
static unsigned i;
103103
static uint64_t s;
104104
if (!i) {
105-
s = rand64();
105+
s = _rand64();
106106
i = (s + 1) & (511);
107107
}
108108
return MarsagliaXorshift64(&s);
@@ -215,7 +215,7 @@ const struct Function {
215215
{"moby", moby}, //
216216
{"mt19937", _mt19937}, //
217217
{"python", pythonx2}, //
218-
{"rand64", rand64}, //
218+
{"rand64", _rand64}, //
219219
{"rdrand", rdrand}, //
220220
{"rdrnd", rdrand}, //
221221
{"rdseed", rdseed}, //

libc/calls/tmpfd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ int tmpfd(void) {
8686
*p++ = '.';
8787
}
8888
for (i = 0; i < 10; ++i) {
89-
x = rand64();
89+
x = _rand64();
9090
for (j = 0; j < 6; ++j) {
9191
p[j] = "0123456789abcdefghijklmnopqrstuvwxyz"[x % 36];
9292
x /= 36;

libc/dns/resolvedns.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int ResolveDns(const struct ResolvConf *resolvconf, int af, const char *name,
6363
if (!resolvconf->nameservers.i) return 0;
6464
bzero(&h, sizeof(h));
6565
rc = ebadmsg();
66-
h.id = rand64();
66+
h.id = _rand64();
6767
h.bf1 = 1; /* recursion desired */
6868
h.qdcount = 1;
6969
q.qname = name;

libc/dns/resolvednsreverse.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424
│ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR │
2525
│ OTHER DEALINGS IN THE SOFTWARE. │
2626
╚─────────────────────────────────────────────────────────────────────────────*/
27-
#include "libc/intrin/bits.h"
2827
#include "libc/calls/calls.h"
2928
#include "libc/dns/consts.h"
3029
#include "libc/dns/dns.h"
3130
#include "libc/dns/dnsheader.h"
3231
#include "libc/dns/dnsquestion.h"
3332
#include "libc/dns/resolvconf.h"
33+
#include "libc/intrin/bits.h"
3434
#include "libc/mem/mem.h"
35-
#include "libc/stdio/rand.h"
3635
#include "libc/runtime/runtime.h"
3736
#include "libc/sock/sock.h"
37+
#include "libc/stdio/rand.h"
3838
#include "libc/str/str.h"
3939
#include "libc/sysv/consts/af.h"
4040
#include "libc/sysv/consts/ipproto.h"
@@ -65,7 +65,7 @@ int ResolveDnsReverse(const struct ResolvConf *resolvconf, int af,
6565
if (!resolvconf->nameservers.i) return 0;
6666
bzero(&h, sizeof(h));
6767
rc = ebadmsg();
68-
h.id = rand64();
68+
h.id = _rand64();
6969
h.bf1 = 1; /* recursion desired */
7070
h.qdcount = 1;
7171
q.qname = name;

libc/intrin/getpid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* tracked by a global variable which is updated at fork(). The only
3030
* exception is when the process is vfork()'d in which case a system
3131
* call shall be issued. This optimization helps make functions like
32-
* rand64() fork-safe, however it could lead to race conditions in
32+
* _rand64() fork-safe, however it could lead to race conditions in
3333
* programs that mix fork() with threads. In that case, apps should
3434
* consider using `sys_getpid().ax` instead to force a system call.
3535
*

libc/intrin/rand64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static struct {
4646
* @threadsafe
4747
* @vforksafe
4848
*/
49-
uint64_t rand64(void) {
49+
uint64_t _rand64(void) {
5050
void *p;
5151
uint128_t s;
5252
if (__threaded) pthread_spin_lock(&g_rand64.lock);

libc/stdio/lemur64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
* double x = _real1(lemur64()); // make float on [0,1]-interval
3030
*
3131
* If you want a fast pseudorandom number generator that seeds itself
32-
* automatically on startup and fork() then consider rand64(). If you
32+
* automatically on startup and fork(), then consider _rand64. If you
3333
* want true random data then consider rdseed, rdrand, and getrandom.
3434
*
3535
* @return 64 bits of pseudorandom data
3636
* @note this is Lemire's Lehmer generator
3737
* @note this function takes at minimum 1 cycle
3838
* @note this function passes bigcrush and practrand
3939
* @note this function is not intended for cryptography
40-
* @see rand64(), rngset(), _real1(), _real2(), _real3()
40+
* @see _rand64(), rngset(), _real1(), _real2(), _real3()
4141
*/
4242
uint64_t lemur64(void) {
4343
static uint128_t s = 2131259787901769494;

libc/stdio/mkdtemp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ char *mkdtemp(char *template) {
4242
int i, j, n;
4343
if ((n = strlen(template)) >= 6 && !memcmp(template + n - 6, "XXXXXX", 6)) {
4444
for (i = 0; i < 10; ++i) {
45-
x = rand64();
45+
x = _rand64();
4646
for (j = 0; j < 6; ++j) {
4747
template[n - 6 + j] = "0123456789abcdefghijklmnopqrstuvwxyz"[x % 36];
4848
x /= 36;

0 commit comments

Comments
 (0)