[sanitizer] Assume getrandom might not be supported by the kernel

It was added on kernel 3.17.
This commit is contained in:
Adhemerval Zanella 2020-11-02 14:38:12 -03:00
parent 7b0ca32b62
commit 0ad3cb8c26
1 changed files with 3 additions and 0 deletions
compiler-rt/test/sanitizer_common/TestCases/Posix

View File

@ -3,6 +3,7 @@
// //
#include <sys/types.h> #include <sys/types.h>
#include <errno.h>
#if !defined(__GLIBC_PREREQ) #if !defined(__GLIBC_PREREQ)
#define __GLIBC_PREREQ(a, b) 0 #define __GLIBC_PREREQ(a, b) 0
@ -21,6 +22,8 @@ int main() {
ssize_t n = 1; ssize_t n = 1;
#if defined(HAS_GETRANDOM) #if defined(HAS_GETRANDOM)
n = getrandom(buf, sizeof(buf), 0); n = getrandom(buf, sizeof(buf), 0);
if (n == -1 && errno == ENOSYS)
n = 1;
#endif #endif
return (int)(n <= 0); return (int)(n <= 0);
} }