diff options
author | David Carlier <devnexen@gmail.com> | 2019-10-10 11:31:37 +0000 |
---|---|---|
committer | David Carlier <devnexen@gmail.com> | 2019-10-10 11:31:37 +0000 |
commit | 90c8b59cfc6ea5c1b1f6e024c3a31b990b1b0e66 (patch) | |
tree | d313f758f2e26eaf12c1282ffbb9aa71083406d1 /compiler-rt/test | |
parent | d79c3be6187248b1a158911dc162f06a86d4c612 (diff) | |
download | bcm5719-llvm-90c8b59cfc6ea5c1b1f6e024c3a31b990b1b0e66.tar.gz bcm5719-llvm-90c8b59cfc6ea5c1b1f6e024c3a31b990b1b0e66.zip |
[Sanitizers] Porting getrandom/getentropy interceptors to FreeBSD
- Available from 12.x branch, by the time it lands next year in FreeBSD tree, the 11.x's might be EOL.
- Intentionally changed the getrandom test to C code as with 12.0 (might be fixed in CURRENT since), there is a linkage issue in C++ context.
Reviewers: emaste, dim, vitalybuka
Reviewed-By: vitalybuka
Differential Revision: https://reviews.llvm.org/D68451
llvm-svn: 374315
Diffstat (limited to 'compiler-rt/test')
-rw-r--r-- | compiler-rt/test/sanitizer_common/TestCases/Posix/getrandom.c (renamed from compiler-rt/test/sanitizer_common/TestCases/Linux/getrandom.cpp) | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/getrandom.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/getrandom.c index 08337f537d1..fdc08bc4e93 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Linux/getrandom.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/getrandom.c @@ -1,5 +1,5 @@ -// RUN: %clangxx -O2 %s -o %t && %run %t -// UNSUPPORTED: android +// RUN: %clang -O2 %s -o %t && %run %t +// UNSUPPORTED: android netbsd darwin solaris // #include <sys/types.h> @@ -8,14 +8,18 @@ #define __GLIBC_PREREQ(a, b) 0 #endif -#if __GLIBC_PREREQ(2, 25) +#if (defined(__linux__) && __GLIBC_PREREQ(2, 25)) || defined(__FreeBSD__) +#define HAS_GETRANDOM +#endif + +#if defined(HAS_GETRANDOM) #include <sys/random.h> #endif int main() { char buf[16]; ssize_t n = 1; -#if __GLIBC_PREREQ(2, 25) +#if defined(HAS_GETRANDOM) n = getrandom(buf, sizeof(buf), 0); #endif return (int)(n <= 0); |