summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
Diffstat (limited to 'random.c')
-rw-r--r--random.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/random.c b/random.c
index 7a3b649..7165f3c 100644
--- a/random.c
+++ b/random.c
@@ -558,15 +558,24 @@ static void
fill_random_seed(uint32_t *seed, size_t cnt)
{
static int n = 0;
+#if defined HAVE_CLOCK_GETTIME
+ struct timespec tv;
+#elif defined HAVE_GETTIMEOFDAY
struct timeval tv;
+#endif
size_t len = cnt * sizeof(*seed);
memset(seed, 0, len);
fill_random_bytes(seed, len, FALSE);
+#if defined HAVE_CLOCK_GETTIME
+ clock_gettime(CLOCK_REALTIME, &tv);
+ seed[0] ^= tv.tv_nsec;
+#elif defined HAVE_GETTIMEOFDAY
gettimeofday(&tv, 0);
seed[0] ^= tv.tv_usec;
+#endif
seed[1] ^= (uint32_t)tv.tv_sec;
#if SIZEOF_TIME_T > SIZEOF_INT
seed[0] ^= (uint32_t)((time_t)tv.tv_sec >> SIZEOF_INT * CHAR_BIT);