aboutsummaryrefslogtreecommitdiffstats
path: root/openbsd-compat/res_randomid.c
diff options
context:
space:
mode:
Diffstat (limited to 'openbsd-compat/res_randomid.c')
-rw-r--r--openbsd-compat/res_randomid.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/openbsd-compat/res_randomid.c b/openbsd-compat/res_randomid.c
new file mode 100644
index 00000000..c848c41d
--- /dev/null
+++ b/openbsd-compat/res_randomid.c
@@ -0,0 +1,13 @@
+#include "includes.h"
+
+#include <time.h>
+
+unsigned int
+res_randomid(void)
+{
+ struct timespec ts;
+
+ /* This is from musl C library */
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return ts.tv_nsec + ts.tv_nsec / 65536UL & 0xffff;
+}