summaryrefslogtreecommitdiffstats
path: root/rand.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-04-28 06:37:55 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-04-28 06:37:55 -0700
commit2e0639abc56dcad0ce4b5933604d0c8657ac094b (patch)
treed9026314af4543560e9178061191e267dd612335 /rand.c
parente435700d50234e9cc1121858b194462110db9dba (diff)
downloadtxr-2e0639abc56dcad0ce4b5933604d0c8657ac094b.tar.gz
txr-2e0639abc56dcad0ce4b5933604d0c8657ac094b.tar.bz2
txr-2e0639abc56dcad0ce4b5933604d0c8657ac094b.zip
Only use getpid for rand seed if HAVE_UNISTD_H.
* rand.c (make_random_state): Don't use getpid if we aren't on something that looks like Unix.
Diffstat (limited to 'rand.c')
-rw-r--r--rand.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/rand.c b/rand.c
index 7bdc2a99..6cdd937d 100644
--- a/rand.c
+++ b/rand.c
@@ -140,7 +140,9 @@ val make_random_state(val seed)
val time = time_sec_usec();
r->state[0] = convert(rand32_t, c_num(car(time)));
r->state[1] = convert(rand32_t, c_num(cdr(time)));
+#if HAVE_UNISTD_H
r->state[2] = convert(rand32_t, getpid());
+#endif
memset(r->state + 3, 0xAA, sizeof r->state - 3 * sizeof r->state[0]);
} else if (random_state_p(seed)) {
struct rand_state *rseed = coerce(struct rand_state *,