aboutsummaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2018-12-26 21:12:37 +0100
committerToni Uhlig <matzeton@googlemail.com>2018-12-26 21:12:37 +0100
commit85f77e5953ce6a60235ea3d5af5799668183b497 (patch)
treec4237dc60c5d90c94abbb8126b81a05dd870dcd0 /src/utils.c
parent5236e631bb3c6f3a31c920709e3fe6c5cd579c14 (diff)
support BSD arc4random() if available
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c
index 6233753..10e8182 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -49,6 +49,9 @@
#include <string.h>
#include <time.h>
#include <assert.h>
+#ifdef HAVE_ARC4RANDOM
+#include <bsd/stdlib.h>
+#endif
#ifndef WIN32
#include <syslog.h>
@@ -148,6 +151,9 @@ void print_hexstr(unsigned char *buf, size_t siz) {
#endif
int pt_random(void) {
+#ifdef HAVE_ARC4RANDOM
+ return arc4random();
+#else
#ifdef HAVE_RANDOM
#ifndef TIME_UTC
#define TIME_UTC 1
@@ -161,4 +167,5 @@ int pt_random(void) {
srand(time(0));
return rand();
#endif
+#endif
}