WPILibC++  unspecified
Compiler.h
1 //===-- llvm/Support/Compiler.h - Compiler abstraction support --*- 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 defines several macros, based on the current compiler. This allows
11 // use of compiler-specific features in a way that remains portable.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_SUPPORT_COMPILER_H
16 #define LLVM_SUPPORT_COMPILER_H
17 
18 #ifndef __has_feature
19 # define __has_feature(x) 0
20 #endif
21 
22 #ifndef __has_extension
23 # define __has_extension(x) 0
24 #endif
25 
26 #ifndef __has_attribute
27 # define __has_attribute(x) 0
28 #endif
29 
30 #ifndef __has_builtin
31 # define __has_builtin(x) 0
32 #endif
33 
37 #ifndef LLVM_GNUC_PREREQ
38 # if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
39 # define LLVM_GNUC_PREREQ(maj, min, patch) \
40  ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) + __GNUC_PATCHLEVEL__ >= \
41  ((maj) << 20) + ((min) << 10) + (patch))
42 # elif defined(__GNUC__) && defined(__GNUC_MINOR__)
43 # define LLVM_GNUC_PREREQ(maj, min, patch) \
44  ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) >= ((maj) << 20) + ((min) << 10))
45 # else
46 # define LLVM_GNUC_PREREQ(maj, min, patch) 0
47 # endif
48 #endif
49 
50 #ifndef LLVM_CONSTEXPR
51 # ifdef _MSC_VER
52 # if _MSC_VER >= 1900
53 # define LLVM_CONSTEXPR constexpr
54 # else
55 # define LLVM_CONSTEXPR
56 # endif
57 # elif defined(__has_feature)
58 # if __has_feature(cxx_constexpr)
59 # define LLVM_CONSTEXPR constexpr
60 # else
61 # define LLVM_CONSTEXPR
62 # endif
63 # elif defined(__GXX_EXPERIMENTAL_CXX0X__)
64 # define LLVM_CONSTEXPR constexpr
65 # elif defined(__has_constexpr)
66 # define LLVM_CONSTEXPR constexpr
67 # else
68 # define LLVM_CONSTEXPR
69 # endif
70 #endif
71 
72 #ifndef LLVM_ATTRIBUTE_UNUSED_RESULT
73 #if __has_attribute(warn_unused_result) || LLVM_GNUC_PREREQ(3, 4, 0)
74 #define LLVM_ATTRIBUTE_UNUSED_RESULT __attribute__((__warn_unused_result__))
75 #elif defined(_MSC_VER)
76 #define LLVM_ATTRIBUTE_UNUSED_RESULT _Check_return_
77 #else
78 #define LLVM_ATTRIBUTE_UNUSED_RESULT
79 #endif
80 #endif
81 
82 #ifndef LLVM_UNLIKELY
83 #if __has_builtin(__builtin_expect) || LLVM_GNUC_PREREQ(4, 0, 0)
84 #define LLVM_LIKELY(EXPR) __builtin_expect((bool)(EXPR), true)
85 #define LLVM_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false)
86 #else
87 #define LLVM_LIKELY(EXPR) (EXPR)
88 #define LLVM_UNLIKELY(EXPR) (EXPR)
89 #endif
90 #endif
91 
92 #endif