$OpenBSD: patch-uuid_c,v 1.1.1.1 2012/10/10 10:45:05 sthen Exp $
--- uuid.c.orig	Thu Nov 11 23:48:13 2010
+++ uuid.c	Sat Sep 22 01:21:26 2012
@@ -28,6 +28,7 @@
 #include <time.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <sys/socket.h>
 #include <sys/syscall.h>
 #include <string.h>
 #include <net/if.h>
@@ -46,15 +47,6 @@ static u_int32_t clock_seq;
 static const u_int32_t clock_seq_max = 0x3fff; /* 14 bits */
 static int clock_seq_initialized;
 
-unsigned long long
-monotonic_us(void)
-{
-	struct timespec ts;
-
-	syscall(__NR_clock_gettime, CLOCK_MONOTONIC, &ts);
-	return ts.tv_sec * 1000000ULL + ts.tv_nsec / 1000;
-}
-
 int
 read_bootid_node(unsigned char *buf, size_t size)
 {
@@ -82,7 +74,6 @@ static void
 read_random_bytes(unsigned char *buf, size_t size)
 {
 	int i;
-	pid_t pid;
 
 	i = open("/dev/urandom", O_RDONLY);
 	if(i >= 0)
@@ -90,20 +81,6 @@ read_random_bytes(unsigned char *buf, size_t size)
 		read(i, buf, size);
 		close(i);
 	}
-	/* Paranoia. /dev/urandom may be missing.
-	 * rand() is guaranteed to generate at least [0, 2^15) range,
-	 * but lowest bits in some libc are not so "random".  */
-	srand(monotonic_us());
-	pid = getpid();
-	while(1)
-	{
-		for(i = 0; i < size; i++)
-			buf[i] ^= rand() >> 5;
-		if(pid == 0)
-			break;
-		srand(pid);
-		pid = 0;
-	}
 }
 
 void
@@ -162,7 +139,7 @@ generate_uuid(unsigned char uuid_out[16])
 	 * nanosecond intervals since 00:00:00.00, 15 October 1582 (the date of
 	 * Gregorian reform to the Christian calendar).
 	 */
-	syscall(__NR_clock_gettime, CLOCK_REALTIME, &ts);
+	clock_gettime(CLOCK_REALTIME, &ts);
 	time_all = ((u_int64_t)ts.tv_sec) * (NSEC_PER_SEC / 100);
 	time_all += ts.tv_nsec / 100;
 
