1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-28 22:21:15 -07:00
This commit is contained in:
Frank Denis 2017-01-18 20:03:26 +01:00
parent f053b98b64
commit de3c0ff85e
2 changed files with 17 additions and 17 deletions

View File

@ -6,11 +6,11 @@
# include <sys/time.h> # include <sys/time.h>
#endif #endif
#ifdef __linux__ #ifdef __linux__
#ifdef __dietlibc__ # ifdef __dietlibc__
#define _LINUX_SOURCE # define _LINUX_SOURCE
#else # else
# include <sys/syscall.h> # include <sys/syscall.h>
#endif # endif
# include <poll.h> # include <poll.h>
#endif #endif
@ -219,11 +219,11 @@ _randombytes_linux_getrandom(void * const buf, const size_t size)
assert(size <= 256U); assert(size <= 256U);
do { do {
#ifdef __dietlibc__ # ifdef __dietlibc__
readnb = getrandom(buf, size, 0); readnb = getrandom(buf, size, 0);
#else # else
readnb = syscall(SYS_getrandom, buf, (int) size, 0); readnb = syscall(SYS_getrandom, buf, (int) size, 0);
#endif # endif
} while (readnb < 0 && (errno == EINTR || errno == EAGAIN)); } while (readnb < 0 && (errno == EINTR || errno == EAGAIN));
return (readnb == (int) size) - 1; return (readnb == (int) size) - 1;

View File

@ -6,11 +6,11 @@
# include <sys/time.h> # include <sys/time.h>
#endif #endif
#ifdef __linux__ #ifdef __linux__
#ifdef __dietlibc__ # ifdef __dietlibc__
#define _LINUX_SOURCE # define _LINUX_SOURCE
#else # else
# include <sys/syscall.h> # include <sys/syscall.h>
#endif # endif
# include <poll.h> # include <poll.h>
#endif #endif
@ -201,11 +201,11 @@ _randombytes_linux_getrandom(void * const buf, const size_t size)
assert(size <= 256U); assert(size <= 256U);
do { do {
#ifdef __dietlibc__ # ifdef __dietlibc__
readnb = getrandom( buf, size, 0); readnb = getrandom(buf, size, 0);
#else # else
readnb = syscall(SYS_getrandom, buf, (int) size, 0); readnb = syscall(SYS_getrandom, buf, (int) size, 0);
#endif # endif
} while (readnb < 0 && (errno == EINTR || errno == EAGAIN)); } while (readnb < 0 && (errno == EINTR || errno == EAGAIN));
return (readnb == (int) size) - 1; return (readnb == (int) size) - 1;