• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- asan_test_utils.h ------------*- 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 //
10 // This file is a part of AddressSanitizer, an address sanity checker.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef ASAN_TEST_UTILS_H
15 #define ASAN_TEST_UTILS_H
16 
17 #if defined(_WIN32)
18 typedef unsigned __int8  uint8_t;
19 typedef unsigned __int16 uint16_t;
20 typedef unsigned __int32 uint32_t;
21 typedef unsigned __int64 uint64_t;
22 typedef __int8           int8_t;
23 typedef __int16          int16_t;
24 typedef __int32          int32_t;
25 typedef __int64          int64_t;
26 # define NOINLINE __declspec(noinline)
27 #else  // defined(_WIN32)
28 # define NOINLINE __attribute__((noinline))
29 #endif  // defined(_WIN32)
30 
31 #if !defined(__has_feature)
32 #define __has_feature(x) 0
33 #endif
34 
35 #ifndef __WORDSIZE
36 #if __LP64__ || defined(_WIN64)
37 #define __WORDSIZE 64
38 #else
39 #define __WORDSIZE 32
40 #endif
41 #endif
42 
43 // Make the compiler think that something is going on there.
44 extern "C" void break_optimization(void *arg);
45 
46 // This function returns its parameter but in such a way that compiler
47 // can not prove it.
48 template<class T>
49 NOINLINE
Ident(T t)50 static T Ident(T t) {
51   T ret = t;
52   break_optimization(&ret);
53   return ret;
54 }
55 
56 #endif  // ASAN_TEST_UTILS_H
57