Mercurial > repo
annotate src/ploki/random.c @ 7638:25b838ae35f6
<boily> le/rn wat/\xe1\x8a\xa2\xe1\x89\xb5\xe1\x8b\xae\xe1\x8c\xb5\xe1\x8b\xab \xe1\x8b\x8d\xe1\x88\xb5\xe1\x8c\xa5 \xe1\x8b\xa8\xe1\x88\x9a\xe1\x88\xb0\xe1\x88\xab \xe1\x8b\xa8\xe1\x88\x9d\xe1\x8c\x8d\xe1\x89\xa5 \xe1\x8a\xa0\xe1\x8b\xad\xe1\x8a\x90\xe1\x89\xb5 \xe1\x88\xb2\xe1\x88\x86\xe1\x8a\x95\xe1\x8d\xa3 \xe1\x8b\xa8\xe1\x88\x9a\xe1\x88\xb0\xe1\x88\xab\xe1\x8b\x8d\xe1\x88\x9d \xe1\x8a\xa8\xe1\x8c\xa4\xe1\x8d\x8d \xe1\x8a\x90\xe1\x8b\x8d\xe1\x8d\xa2
author | HackBot |
---|---|
date | Sun, 01 May 2016 22:44:03 +0000 |
parents | ac0403686959 |
children |
rev | line source |
---|---|
4223 | 1 #include "config.h" |
2 #include "random.h" | |
3 | |
4 #include <stdio.h> | |
5 #include <stdlib.h> | |
6 #include <time.h> | |
7 | |
8 void randseed(void) { | |
9 unsigned seed; | |
10 | |
11 seed = time(NULL); | |
12 #if HAVE_DEV_URANDOM_P | |
13 { | |
14 FILE *fp; | |
15 | |
16 if ((fp = fopen("/dev/urandom", "rb"))) { | |
17 fread(&seed, sizeof seed, 1, fp); | |
18 fclose(fp); | |
19 } | |
20 } | |
21 #endif | |
22 srand(seed); | |
23 } | |
24 | |
25 double randval(void) { | |
26 return rand() / (RAND_MAX + 1.0); | |
27 } |