mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-20 05:11:46 +03:00
Fix on Linux
This commit is contained in:
parent
30390fa180
commit
16451c769c
10
ent.c
10
ent.c
@ -3,29 +3,31 @@
|
||||
#if defined(ENT_URANDOM)
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
int
|
||||
ent_getentropy(void* buf, size_t len)
|
||||
{
|
||||
int fd;
|
||||
int fd;
|
||||
ssize_t ret;
|
||||
char* cuf;
|
||||
|
||||
assert(len <= 256);
|
||||
if (-1 == (fd = open("/dev/urandom", O_RDONLY))) {
|
||||
return -1;
|
||||
}
|
||||
while (len != 0 && (ret = read(fd, buf, len)) != 0) {
|
||||
while (len != 0 && (ret = read(fd, cuf, len)) != 0) {
|
||||
if (ret == -1) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
len -= ret;
|
||||
buf += ret;
|
||||
cuf += ret;
|
||||
}
|
||||
(void) close(fd);
|
||||
if (ret == 0) {
|
||||
|
@ -3,9 +3,10 @@
|
||||
|
||||
#include <ent/config.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(ENT_GETENTROPY)
|
||||
# if defined(ENT_GE_SYSRANDOM)
|
||||
# include <stddef.h>
|
||||
# include <inttypes.h> /* OSX sys/random.h needs Availability.h from this */
|
||||
# include <sys/random.h>
|
||||
# elif defined(ENT_GE_UNISTD)
|
||||
|
Loading…
Reference in New Issue
Block a user