6398575e6955454f0f97ae5de891f95272c81c60
[oota-llvm.git] / lib / Fuzzer / FuzzerDFSan.h
1 //===- FuzzerDFSan.h - Internal header for the Fuzzer -----------*- C++ -* ===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 // DFSan interface.
10 //===----------------------------------------------------------------------===//
11
12 #ifndef LLVM_FUZZER_DFSAN_H
13 #define LLVM_FUZZER_DFSAN_H
14
15 #ifndef LLVM_FUZZER_SUPPORTS_DFSAN
16 # if defined(__linux__)
17 #  define LLVM_FUZZER_SUPPORTS_DFSAN 1
18 # else
19 #  define LLVM_FUZZER_SUPPORTS_DFSAN 0
20 # endif  // __linux__
21 #endif  // LLVM_FUZZER_SUPPORTS_DFSAN
22
23 #include <sanitizer/dfsan_interface.h>
24 #if LLVM_FUZZER_SUPPORTS_DFSAN
25
26 extern "C" {
27 __attribute__((weak))
28 dfsan_label dfsan_create_label(const char *desc, void *userdata);
29 __attribute__((weak))
30 void dfsan_set_label(dfsan_label label, void *addr, size_t size);
31 __attribute__((weak))
32 void dfsan_add_label(dfsan_label label, void *addr, size_t size);
33 __attribute__((weak))
34 const struct dfsan_label_info *dfsan_get_label_info(dfsan_label label);
35 __attribute__((weak))
36 dfsan_label dfsan_read_label(const void *addr, size_t size);
37 }  // extern "C"
38
39 namespace fuzzer {
40 static bool ReallyHaveDFSan() {
41   return &dfsan_create_label != nullptr;
42 }
43 }  // namespace fuzzer
44 #else
45 namespace fuzzer {
46 static bool ReallyHaveDFSan() { return false; }
47 }  // namespace fuzzer
48
49 #endif
50
51 #endif // LLVM_FUZZER_DFSAN_H