summaryrefslogtreecommitdiff
path: root/test/sanitizer_common/TestCases/Linux/getrandom.cpp
blob: 08337f537d10f5876d54b732476aa24effe095f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// RUN: %clangxx -O2 %s -o %t && %run %t
// UNSUPPORTED: android
//

#include <sys/types.h>

#if !defined(__GLIBC_PREREQ)
#define __GLIBC_PREREQ(a, b) 0
#endif

#if __GLIBC_PREREQ(2, 25)
#include <sys/random.h>
#endif

int main() {
  char buf[16];
  ssize_t n = 1;
#if __GLIBC_PREREQ(2, 25)
  n = getrandom(buf, sizeof(buf), 0);
#endif
  return (int)(n <= 0);
}