[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Linux / mprobe.cpp
blob7633eb4762292aecd8ea543de7591a8cd96995b2
1 // RUN: %clangxx %s -o %t && %run %t 2>&1 | FileCheck %s
2 // UNSUPPORTED: android, hwasan, ubsan
4 #include <stdio.h>
5 #include <stdlib.h>
6 #if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 2)
7 #include <mcheck.h>
8 #else
9 #define MCHECK_OK 0
10 extern "C" int mcheck(void (*abortfunc)(int mstatus));
11 extern "C" int mcheck_pedantic(void (*abortfunc)(int mstatus));
12 extern "C" int mprobe(void *ptr);
13 #endif
15 void check_heap() {
16 void *p = malloc(1000);
17 int res = mprobe(p);
18 if (res == MCHECK_OK)
19 printf("Success!\n");
20 free(p);
23 int main(int argc, char *argv[]) {
24 void *p;
25 if (mcheck(NULL) != 0) {
26 fprintf(stderr, "mcheck() failed\n");
27 exit(EXIT_FAILURE);
30 check_heap();
31 // CHECK: Success!
33 if (mcheck_pedantic(NULL) != 0) {
34 fprintf(stderr, "mcheck_pedantic() failed\n");
35 exit(EXIT_FAILURE);
38 check_heap();
39 // CHECK: Success!
41 return 0;