packages feed

splitmix 0.1.1 → 0.1.2

raw patch · 3 files changed

+16/−38 lines, 3 files

Files

Changelog.md view
@@ -1,3 +1,7 @@+# 0.1.2++- Use `getentropy` for initialisation on unix-like systems (i.e. not Windows).+ # 0.1.1  - Drop support for GHCs prior 8.6.5
cbits-unix/init.c view
@@ -1,39 +1,13 @@ #include <stdint.h>-#include <stdio.h>-#include <sys/time.h>-#include <sys/types.h>-#include <time.h> #include <unistd.h> -uint64_t splitmix_init() {--    /* if there is /dev/urandom, read from it */-    FILE *urandom = fopen("/dev/urandom", "r");-    if (urandom) {-        uint64_t result = 0;-        size_t r = fread(&result, sizeof(uint64_t), 1, urandom);-        fclose(urandom);--        if (r == 1) {-            return result;-        } else {-            return 0xfeed1000;-        }--    } else {-        /* time of day */-        struct timeval tp = {0, 0};-        gettimeofday(&tp, NULL);--        /* cputime */-        clock_t c = clock();--        /* process id */-        pid_t p = getpid();+/* for macos */+#ifdef __APPLE__+#include <sys/random.h>+#endif -        return ((uint64_t) tp.tv_sec)-            ^ ((uint64_t) tp.tv_usec)-            ^ ((uint64_t) c << 16)-            ^ ((uint64_t) p << 32);-    }+uint64_t splitmix_init() {+	uint64_t result;+	int r = getentropy(&result, sizeof(uint64_t));+	return r == 0 ? result : 0xfeed1000; }
splitmix.cabal view
@@ -1,6 +1,6 @@ cabal-version:      >=1.10 name:               splitmix-version:            0.1.1+version:            0.1.2 synopsis:           Fast Splittable PRNG description:   Pure Haskell implementation of SplitMix described in@@ -39,10 +39,10 @@      || ==9.0.2      || ==9.2.8      || ==9.4.8-     || ==9.6.6+     || ==9.6.7      || ==9.8.4-     || ==9.10.1-     || ==9.11.1+     || ==9.10.2+     || ==9.12.2  extra-source-files:   Changelog.md