[compiler-rt] 0ad3cb8 - [sanitizer] Assume getrandom might not be supported by the kernel

Adhemerval Zanella via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 5 03:36:49 PST 2020


Author: Adhemerval Zanella
Date: 2020-11-05T08:32:53-03:00
New Revision: 0ad3cb8c267516b96f205d03b5284b7d3d507729

URL: https://github.com/llvm/llvm-project/commit/0ad3cb8c267516b96f205d03b5284b7d3d507729
DIFF: https://github.com/llvm/llvm-project/commit/0ad3cb8c267516b96f205d03b5284b7d3d507729.diff

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

It was added on kernel 3.17.

Added: 
    

Modified: 
    compiler-rt/test/sanitizer_common/TestCases/Posix/getrandom.c

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/getrandom.c b/compiler-rt/test/sanitizer_common/TestCases/Posix/getrandom.c
index ba615a720527..1d15b881ed11 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/getrandom.c
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/getrandom.c
@@ -3,6 +3,7 @@
 //
 
 #include <sys/types.h>
+#include <errno.h>
 
 #if !defined(__GLIBC_PREREQ)
 #define __GLIBC_PREREQ(a, b) 0
@@ -21,6 +22,8 @@ int main() {
   ssize_t n = 1;
 #if defined(HAS_GETRANDOM)
   n = getrandom(buf, sizeof(buf), 0);
+  if (n == -1 && errno == ENOSYS)
+    n = 1;
 #endif
   return (int)(n <= 0);
 }


        


More information about the llvm-commits mailing list