# HG changeset patch # User Josef 'Jeff' Sipek # Date 1445097060 14400 # Node ID 366635b72c326a2d41f218c75edd0fbc258600fa # Parent 2fcbd483c1c363529ffa94ababc381d5d1e651da# Parent 3aea54128fefc75f4f0092422e4bb9a3d2fcd319 Merge branch 'master' of https://github.com/jeffpc/nx01 diff -r 2fcbd483c1c3 -r 366635b72c32 README --- a/README Sat Oct 17 11:48:44 2015 -0400 +++ b/README Sat Oct 17 11:51:00 2015 -0400 @@ -19,7 +19,7 @@ $ make $ make install -This will build and install the binaries and libraries under the specficied +This will build and install the binaries and libraries under the specified prefix. diff -r 2fcbd483c1c3 -r 366635b72c32 src/common/rand.c --- a/src/common/rand.c Sat Oct 17 11:48:44 2015 -0400 +++ b/src/common/rand.c Sat Oct 17 11:51:00 2015 -0400 @@ -1,5 +1,6 @@ /* * Copyright (c) 2015 Josef 'Jeff' Sipek + * Copyright (c) 2015 Holly Sipek * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,16 +21,39 @@ * SOFTWARE. */ +#include +#include +#include + #include #include #include +#include uint32_t rand32(void) { #ifdef HAVE_ARC4RANDOM return arc4random(); #else -#error "Need a way to generate random uint32_t" + uint32_t ret; + int fd; + + fd = open("/dev/random", O_RDONLY); + if (fd == -1) { + fprintf(stderr, "Failed to get random number: %s", + strerror(errno)); + ASSERT(0); + } + + if (read(fd, &ret, sizeof(ret)) != sizeof(ret)) { + fprintf(stderr, "Failed to get random number: %s", + strerror(errno)); + ASSERT(0); + } + + close(fd); + + return ret; #endif }