aboutsummaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c
index 66ed4c0..12e7992 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -43,8 +43,12 @@
* Note that the source code is best viewed with tabs set to 4 spaces.
*/
+#include <stdio.h>
+#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
+#include <time.h>
+#include <assert.h>
#ifndef WIN32
#include <syslog.h>
@@ -142,3 +146,11 @@ void print_hexstr(unsigned char *buf, size_t siz) {
free(out);
}
#endif
+
+int pt_random(void) {
+ struct timespec ts;
+
+ assert(timespec_get(&ts, TIME_UTC));
+ srandom(ts.tv_nsec ^ ts.tv_sec);
+ return random();
+}