| trandcounts.c: fix deterministic output on OpenBSD - numtools - perform numeric… | |
| git clone git://src.adamsgaard.dk/numtools | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| commit bc0de099a997dd7945d335a8eebd947d50d61f42 | |
| parent 5eb7b1d9e6225ae95a465c415705fc40f51f7523 | |
| Author: Anders Damsgaard <[email protected]> | |
| Date: Thu, 5 May 2022 13:26:53 +0200 | |
| randcounts.c: fix deterministic output on OpenBSD | |
| Diffstat: | |
| M randcounts.c | 6 ++++++ | |
| 1 file changed, 6 insertions(+), 0 deletions(-) | |
| --- | |
| diff --git a/randcounts.c b/randcounts.c | |
| t@@ -67,11 +67,17 @@ main(int argc, char *argv[]) | |
| errx(1, "weights do not sum to 1 (%g)", weightsum); | |
| if (s) | |
| +#ifdef __OpenBSD__ | |
| + srand48_deterministic(seed); | |
| +#else | |
| srand48(seed); | |
| +#endif | |
| +#ifndef __OpenBSD__ | |
| else { | |
| gettimeofday(&t1, NULL); | |
| srand48(t1.tv_sec * t1.tv_usec); /* Caveat: identical seed for… | |
| } | |
| +#endif | |
| for (j = 0; j < n; j++) { | |
| val = drand48(); |