diff --git a/random.h b/random.h index a817a1d..4e315a8 100644 --- a/random.h +++ b/random.h @@ -3,37 +3,13 @@ #include #include #ifdef __linux__ -#include -#endif -#ifndef SYS_getrandom -#include +#include #endif #include #include #include #include -// dirty hacks -#ifdef SYS_getrandom -inline int getrandom(void *buf, size_t buflen, unsigned int flags) -{ - return syscall(SYS_getrandom, buf, buflen, flags); -} -#else - -#if __linux__ -// ancient linux systems -#define GRND_NONBLOCK 0 -inline int getrandom(void *buf, size_t buflen, unsigned int flags) -{ - int result = RAND_bytes(buf, buflen); - if(result == 1) - { - return (int)buflen; - } - return -1; -} -#endif #if __OpenBSD__ inline int getrandom(void *buf, size_t buflen, unsigned int flags) { @@ -41,7 +17,6 @@ inline int getrandom(void *buf, size_t buflen, unsigned int flags) return 0; } #endif -#endif /* TODO: if the >=C++11 prngr are good enough, use them */ class Random {