syscall do getrandom em C não encontrado
O problema foi resolvido com a atualização da biblioteca C.
Eu gostaria de usar o syscall getrandom (http://man7.org/linux/man-pages/man2/getrandom.2.html)
gcc-5 -std = c11 test.c
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#include <errno.h>
#include <string.h>
#include <signal.h>
#include <linux/random.h>
#include <sys/syscall.h>
int main(void)
{
void *buf = NULL;
size_t l = 5;
unsigned int o = 1;
int r = syscall(SYS_getrandom, buf, l, o);
return 0;
}
ou
int main(void)
{
void *buf = NULL;
size_t l = 5;
unsigned int o = 1;
int r = getrandom(buf, l, o);
return 0;
}
De qualquer forma, quando tento compilá-lo com o gcc-5:
test.c: In function ‘main’:
test.c:14:17: warning: implicit declaration of function ‘getrandom’ [-Wimplicit-function-declaration]
int r = getrandom(buf, l, o);
^
/tmp/ccqFdJAJ.o: In function `main':
test.c:(.text+0x36): undefined reference to `getrandom'
collect2: error: ld returned 1 exit status
Estou usando o Ubuntu 14.04, o que posso fazer para usar o getrandom? Como é um syscall "novo", como posso usá-lo?
editar:
uname -r
-> 4.0.3-040003-generic #201505131441 SMP Wed May 13 13:43:16 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
quando substituo r porint r = syscall(SYS_getrandom, buf, l, o);
ou r = getrandom (buf, l, o) é o mesmo ..