Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: sky/engine/wtf/Compiler.h

Issue 719063002: Revert "Remove support for MSVC" (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/wtf/CPU.h ('k') | sky/engine/wtf/EnumClass.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 11 matching lines...) Expand all
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef WTF_Compiler_h 26 #ifndef WTF_Compiler_h
27 #define WTF_Compiler_h 27 #define WTF_Compiler_h
28 28
29 /* COMPILER() - the compiler being used to build the project */ 29 /* COMPILER() - the compiler being used to build the project */
30 #define COMPILER(WTF_FEATURE) (defined WTF_COMPILER_##WTF_FEATURE && WTF_COMPIL ER_##WTF_FEATURE) 30 #define COMPILER(WTF_FEATURE) (defined WTF_COMPILER_##WTF_FEATURE && WTF_COMPIL ER_##WTF_FEATURE)
31 31
32 /* COMPILER_SUPPORTS() - whether the compiler being used to build the project su pports the given feature. */
33 #define COMPILER_SUPPORTS(WTF_COMPILER_FEATURE) (defined WTF_COMPILER_SUPPORTS_# #WTF_COMPILER_FEATURE && WTF_COMPILER_SUPPORTS_##WTF_COMPILER_FEATURE)
34
35 /* COMPILER_QUIRK() - whether the compiler being used to build the project requi res a given quirk. */
36 #define COMPILER_QUIRK(WTF_COMPILER_QUIRK) (defined WTF_COMPILER_QUIRK_##WTF_COM PILER_QUIRK && WTF_COMPILER_QUIRK_##WTF_COMPILER_QUIRK)
37
32 /* ==== COMPILER() - the compiler being used to build the project ==== */ 38 /* ==== COMPILER() - the compiler being used to build the project ==== */
33 39
34 /* COMPILER(CLANG) - Clang */ 40 /* COMPILER(CLANG) - Clang */
35 #if defined(__clang__) 41 #if defined(__clang__)
36 #define WTF_COMPILER_CLANG 1 42 #define WTF_COMPILER_CLANG 1
37 43
38 #define CLANG_PRAGMA(PRAGMA) _Pragma(PRAGMA) 44 #define CLANG_PRAGMA(PRAGMA) _Pragma(PRAGMA)
45
46 /* Specific compiler features */
47 #define WTF_COMPILER_SUPPORTS_CXX_VARIADIC_TEMPLATES __has_extension(cxx_variadi c_templates)
48
49 /* There is a bug in clang that comes with Xcode 4.2 where AtomicStrings can't b e implicitly converted to Strings
50 in the presence of move constructors and/or move assignment operators. This b ug has been fixed in Xcode 4.3 clang, so we
51 check for both cxx_rvalue_references as well as the unrelated cxx_nonstatic_m ember_init feature which we know was added in 4.3 */
52 #define WTF_COMPILER_SUPPORTS_CXX_RVALUE_REFERENCES __has_extension(cxx_rvalue_r eferences) && __has_extension(cxx_nonstatic_member_init)
53
54 #define WTF_COMPILER_SUPPORTS_CXX_NULLPTR __has_feature(cxx_nullptr)
55 #define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS __has_feature(cxx_explici t_conversions)
56 #define WTF_COMPILER_SUPPORTS_BLOCKS __has_feature(blocks)
57 #define WTF_COMPILER_SUPPORTS_C_STATIC_ASSERT __has_extension(c_static_assert)
58 #define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT __has_extension(cxx_static_asser t)
59 #define WTF_COMPILER_SUPPORTS_HAS_TRIVIAL_DESTRUCTOR __has_extension(has_trivial _destructor)
60 #define WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS __has_extension(cxx_strong_enums)
61
39 #endif 62 #endif
40 63
41 #ifndef CLANG_PRAGMA 64 #ifndef CLANG_PRAGMA
42 #define CLANG_PRAGMA(PRAGMA) 65 #define CLANG_PRAGMA(PRAGMA)
43 #endif 66 #endif
44 67
68 /* COMPILER(MSVC) - Microsoft Visual C++ */
69 #if defined(_MSC_VER)
70 #define WTF_COMPILER_MSVC 1
71
72 /* Specific compiler features */
73 #if !COMPILER(CLANG) && _MSC_VER >= 1600
74 #define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1
75 #endif
76
77 #if COMPILER(CLANG)
78 /* Keep strong enums turned off when building with clang-cl: We cannot yet build all of Blink without fallback to cl.exe, and strong enums are exposed at ABI bo undaries. */
79 #undef WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS
80 #endif
81
82 #endif
83
45 /* COMPILER(GCC) - GNU Compiler Collection */ 84 /* COMPILER(GCC) - GNU Compiler Collection */
46 #if defined(__GNUC__) 85 #if defined(__GNUC__)
47 #define WTF_COMPILER_GCC 1 86 #define WTF_COMPILER_GCC 1
48 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL __) 87 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL __)
49 #define GCC_VERSION_AT_LEAST(major, minor, patch) (GCC_VERSION >= (major * 10000 + minor * 100 + patch)) 88 #define GCC_VERSION_AT_LEAST(major, minor, patch) (GCC_VERSION >= (major * 10000 + minor * 100 + patch))
50 #else 89 #else
51 /* Define this for !GCC compilers, just so we can write things like GCC_VERSION_ AT_LEAST(4, 1, 0). */ 90 /* Define this for !GCC compilers, just so we can write things like GCC_VERSION_ AT_LEAST(4, 1, 0). */
52 #define GCC_VERSION_AT_LEAST(major, minor, patch) 0 91 #define GCC_VERSION_AT_LEAST(major, minor, patch) 0
53 #endif 92 #endif
54 93
94 /* Specific compiler features */
95 #if COMPILER(GCC) && !COMPILER(CLANG)
96 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
97 /* C11 support */
98 #define WTF_COMPILER_SUPPORTS_C_STATIC_ASSERT 1
eseidel 2014/11/12 19:13:10 So this is the change which I removed which got us
99 #endif
100 #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && __cplusplus >= 201103L)
101 /* C++11 support */
102 #if GCC_VERSION_AT_LEAST(4, 3, 0)
103 #define WTF_COMPILER_SUPPORTS_CXX_RVALUE_REFERENCES 1
104 #define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT 1
105 #define WTF_COMPILER_SUPPORTS_CXX_VARIADIC_TEMPLATES 1
106 #endif
107 #if GCC_VERSION_AT_LEAST(4, 5, 0)
108 #define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS 1
109 #endif
110 #if GCC_VERSION_AT_LEAST(4, 6, 0)
111 #define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1
112 /* Strong enums should work from gcc 4.4, but doesn't seem to support some opera tors */
113 #define WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS 1
114 #endif
115 #endif /* defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && __cplu splus >= 201103L) */
116 #endif /* COMPILER(GCC) */
117
55 /* ==== Compiler features ==== */ 118 /* ==== Compiler features ==== */
56 119
57 120
58 /* ALWAYS_INLINE */ 121 /* ALWAYS_INLINE */
59 122
60 #ifndef ALWAYS_INLINE 123 #ifndef ALWAYS_INLINE
61 #if COMPILER(GCC) && defined(NDEBUG) 124 #if COMPILER(GCC) && defined(NDEBUG) && !COMPILER(MINGW)
62 #define ALWAYS_INLINE inline __attribute__((__always_inline__)) 125 #define ALWAYS_INLINE inline __attribute__((__always_inline__))
126 #elif COMPILER(MSVC) && defined(NDEBUG)
127 #define ALWAYS_INLINE __forceinline
63 #else 128 #else
64 #define ALWAYS_INLINE inline 129 #define ALWAYS_INLINE inline
65 #endif 130 #endif
66 #endif 131 #endif
67 132
68 133
69 /* NEVER_INLINE */ 134 /* NEVER_INLINE */
70 135
71 #ifndef NEVER_INLINE 136 #ifndef NEVER_INLINE
72 #if COMPILER(GCC) 137 #if COMPILER(GCC)
73 #define NEVER_INLINE __attribute__((__noinline__)) 138 #define NEVER_INLINE __attribute__((__noinline__))
139 #elif COMPILER(MSVC)
140 #define NEVER_INLINE __declspec(noinline)
74 #else 141 #else
75 #define NEVER_INLINE 142 #define NEVER_INLINE
76 #endif 143 #endif
77 #endif 144 #endif
78 145
79 146
80 /* UNLIKELY */ 147 /* UNLIKELY */
81 148
82 #ifndef UNLIKELY 149 #ifndef UNLIKELY
83 #if COMPILER(GCC) 150 #if COMPILER(GCC)
(...skipping 14 matching lines...) Expand all
98 #endif 165 #endif
99 #endif 166 #endif
100 167
101 168
102 /* NO_RETURN */ 169 /* NO_RETURN */
103 170
104 171
105 #ifndef NO_RETURN 172 #ifndef NO_RETURN
106 #if COMPILER(GCC) 173 #if COMPILER(GCC)
107 #define NO_RETURN __attribute((__noreturn__)) 174 #define NO_RETURN __attribute((__noreturn__))
175 #elif COMPILER(MSVC)
176 #define NO_RETURN __declspec(noreturn)
108 #else 177 #else
109 #define NO_RETURN 178 #define NO_RETURN
110 #endif 179 #endif
111 #endif 180 #endif
112 181
113 182
114 /* WARN_UNUSED_RETURN */ 183 /* WARN_UNUSED_RETURN */
115 184
116 #if COMPILER(GCC) 185 #if COMPILER(GCC)
117 #define WARN_UNUSED_RETURN __attribute__ ((warn_unused_result)) 186 #define WARN_UNUSED_RETURN __attribute__ ((warn_unused_result))
(...skipping 15 matching lines...) Expand all
133 /* REFERENCED_FROM_ASM */ 202 /* REFERENCED_FROM_ASM */
134 203
135 #ifndef REFERENCED_FROM_ASM 204 #ifndef REFERENCED_FROM_ASM
136 #if COMPILER(GCC) 205 #if COMPILER(GCC)
137 #define REFERENCED_FROM_ASM __attribute__((used)) 206 #define REFERENCED_FROM_ASM __attribute__((used))
138 #else 207 #else
139 #define REFERENCED_FROM_ASM 208 #define REFERENCED_FROM_ASM
140 #endif 209 #endif
141 #endif 210 #endif
142 211
212 /* OBJC_CLASS */
213
214 #ifndef OBJC_CLASS
215 #ifdef __OBJC__
216 #define OBJC_CLASS @class
217 #else
218 #define OBJC_CLASS class
219 #endif
220 #endif
221
143 /* WTF_PRETTY_FUNCTION */ 222 /* WTF_PRETTY_FUNCTION */
144 223
145 #if COMPILER(GCC) 224 #if COMPILER(GCC)
225 #define WTF_COMPILER_SUPPORTS_PRETTY_FUNCTION 1
146 #define WTF_PRETTY_FUNCTION __PRETTY_FUNCTION__ 226 #define WTF_PRETTY_FUNCTION __PRETTY_FUNCTION__
227 #elif COMPILER(MSVC)
228 #define WTF_COMPILER_SUPPORTS_PRETTY_FUNCTION 1
229 #define WTF_PRETTY_FUNCTION __FUNCSIG__
147 #else 230 #else
148 #define WTF_PRETTY_FUNCTION __FUNCTION__ 231 #define WTF_PRETTY_FUNCTION __FUNCTION__
149 #endif 232 #endif
150 233
151 #endif /* WTF_Compiler_h */ 234 #endif /* WTF_Compiler_h */
OLDNEW
« no previous file with comments | « sky/engine/wtf/CPU.h ('k') | sky/engine/wtf/EnumClass.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698