Skip to content

Commit

Permalink
Use /dev/urandom for generating uuid instead of /dev/random
Browse files Browse the repository at this point in the history
  • Loading branch information
kovpas committed Dec 16, 2015
1 parent c41d50d commit 234fa0a
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions uuid/uuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@
#include <net/if_dl.h>
#include <net/if_types.h>

static inline void read_random(void *buffer, u_int numBytes) {
int fd = open("/dev/random", O_RDONLY);
read(fd, buffer, numBytes);
close(fd);
}

static inline void nanotime(struct timespec *tv) {
uint64_t now = mach_absolute_time();
tv->tv_sec = now / 1000000000;
Expand All @@ -63,19 +57,18 @@ static inline void nanotime(struct timespec *tv) {
#elif TARGET_OS_LINUX
#include <time.h>


static inline void read_random(void *buffer, u_int numBytes) {
int fd = open("/dev/random", O_RDONLY);
read(fd, buffer, numBytes);
close(fd);
}

static inline void nanotime(struct timespec *tv) {
clock_gettime(CLOCK_MONOTONIC, tv);
}

#endif

static inline void read_random(void *buffer, u_int numBytes) {
int fd = open("/dev/urandom", O_RDONLY);
read(fd, buffer, numBytes);
close(fd);
}


UUID_DEFINE(UUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

Expand Down

0 comments on commit 234fa0a

Please sign in to comment.