diff options
Diffstat (limited to 'src/sysdeps/trygetrandom.c')
-rw-r--r-- | src/sysdeps/trygetrandom.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/sysdeps/trygetrandom.c b/src/sysdeps/trygetrandom.c new file mode 100644 index 0000000..67a623d --- /dev/null +++ b/src/sysdeps/trygetrandom.c @@ -0,0 +1,22 @@ +/* ISC license. */ + +#undef _POSIX_C_SOURCE +#undef _XOPEN_SOURCE + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include <sys/types.h> +#include <sys/syscall.h> + +static int getrandom (void *buf, size_t buflen, unsigned int flags) +{ + return syscall(SYS_getrandom, buf, buflen, flags) ; +} + +int main (void) +{ + char buf[4] ; + return getrandom(buf, 4, 0) ; +} |