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

Side by Side Diff: third_party/WebKit/Source/wtf/Compiler.h

Issue 1436153002: Apply clang-format with Chromium-style without column limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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_COMPILE R_##WTF_FEATURE)
31 31
32 /* COMPILER_SUPPORTS() - whether the compiler being used to build the project su pports the given feature. */ 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) 33 #define COMPILER_SUPPORTS(WTF_COMPILER_FEATURE) (defined WTF_COMPILER_SUPPORTS_# #WTF_COMPILER_FEATURE && WTF_COMPILER_SUPPORTS_##WTF_COMPILER_FEATURE)
34 34
35 /* COMPILER_QUIRK() - whether the compiler being used to build the project requi res a given quirk. */ 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) 36 #define COMPILER_QUIRK(WTF_COMPILER_QUIRK) (defined WTF_COMPILER_QUIRK_##WTF_COM PILER_QUIRK && WTF_COMPILER_QUIRK_##WTF_COMPILER_QUIRK)
37 37
38 /* ==== COMPILER() - the compiler being used to build the project ==== */ 38 /* ==== COMPILER() - the compiler being used to build the project ==== */
39 39
40 /* COMPILER(CLANG) - Clang */ 40 /* COMPILER(CLANG) - Clang */
41 #if defined(__clang__) 41 #if defined(__clang__)
42 #define WTF_COMPILER_CLANG 1 42 #define WTF_COMPILER_CLANG 1
43 #endif 43 #endif
44 44
45 /* COMPILER(MSVC) - Microsoft Visual C++ (and Clang when compiling for Windows). */ 45 /* COMPILER(MSVC) - Microsoft Visual C++ (and Clang when compiling for Windows). */
46 #if defined(_MSC_VER) 46 #if defined(_MSC_VER)
47 #define WTF_COMPILER_MSVC 1 47 #define WTF_COMPILER_MSVC 1
48 #endif 48 #endif
49 49
50 /* COMPILER(GCC) - GNU Compiler Collection (and Clang when compiling for platfor ms other than Windows). */ 50 /* COMPILER(GCC) - GNU Compiler Collection (and Clang when compiling for platfor ms other than Windows). */
51 #if defined(__GNUC__) 51 #if defined(__GNUC__)
52 #define WTF_COMPILER_GCC 1 52 #define WTF_COMPILER_GCC 1
53 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL __) 53 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL __)
54 #define GCC_VERSION_AT_LEAST(major, minor, patch) (GCC_VERSION >= (major * 10000 + minor * 100 + patch)) 54 #define GCC_VERSION_AT_LEAST(major, minor, patch) (GCC_VERSION >= (major * 10000 + minor * 100 + patch))
55 #else 55 #else
56 /* Define this for !GCC compilers, just so we can write things like GCC_VERSION_ AT_LEAST(4, 1, 0). */ 56 /* Define this for !GCC compilers, just so we can write things like GCC_VERSION_ AT_LEAST(4, 1, 0). */
57 #define GCC_VERSION_AT_LEAST(major, minor, patch) 0 57 #define GCC_VERSION_AT_LEAST(major, minor, patch) 0
58 #endif 58 #endif
59 59
60 /* ==== Compiler features ==== */ 60 /* ==== Compiler features ==== */
61 61
62
63 /* ALWAYS_INLINE */ 62 /* ALWAYS_INLINE */
64 63
65 #ifndef ALWAYS_INLINE 64 #ifndef ALWAYS_INLINE
66 #if COMPILER(GCC) && defined(NDEBUG) && !COMPILER(MINGW) 65 #if COMPILER(GCC) && defined(NDEBUG) && !COMPILER(MINGW)
67 #define ALWAYS_INLINE inline __attribute__((__always_inline__)) 66 #define ALWAYS_INLINE inline __attribute__((__always_inline__))
68 #elif COMPILER(MSVC) && defined(NDEBUG) 67 #elif COMPILER(MSVC) && defined(NDEBUG)
69 #define ALWAYS_INLINE __forceinline 68 #define ALWAYS_INLINE __forceinline
70 #else 69 #else
71 #define ALWAYS_INLINE inline 70 #define ALWAYS_INLINE inline
72 #endif 71 #endif
73 #endif 72 #endif
74 73
75
76 /* NEVER_INLINE */ 74 /* NEVER_INLINE */
77 75
78 #ifndef NEVER_INLINE 76 #ifndef NEVER_INLINE
79 #if COMPILER(GCC) 77 #if COMPILER(GCC)
80 #define NEVER_INLINE __attribute__((__noinline__)) 78 #define NEVER_INLINE __attribute__((__noinline__))
81 #elif COMPILER(MSVC) 79 #elif COMPILER(MSVC)
82 #define NEVER_INLINE __declspec(noinline) 80 #define NEVER_INLINE __declspec(noinline)
83 #else 81 #else
84 #define NEVER_INLINE 82 #define NEVER_INLINE
85 #endif 83 #endif
86 #endif 84 #endif
87 85
88
89 /* UNLIKELY */ 86 /* UNLIKELY */
90 87
91 #ifndef UNLIKELY 88 #ifndef UNLIKELY
92 #if COMPILER(GCC) 89 #if COMPILER(GCC)
93 #define UNLIKELY(x) __builtin_expect((x), 0) 90 #define UNLIKELY(x) __builtin_expect((x), 0)
94 #else 91 #else
95 #define UNLIKELY(x) (x) 92 #define UNLIKELY(x) (x)
96 #endif 93 #endif
97 #endif 94 #endif
98 95
99
100 /* LIKELY */ 96 /* LIKELY */
101 97
102 #ifndef LIKELY 98 #ifndef LIKELY
103 #if COMPILER(GCC) 99 #if COMPILER(GCC)
104 #define LIKELY(x) __builtin_expect((x), 1) 100 #define LIKELY(x) __builtin_expect((x), 1)
105 #else 101 #else
106 #define LIKELY(x) (x) 102 #define LIKELY(x) (x)
107 #endif 103 #endif
108 #endif 104 #endif
109 105
110
111 /* NO_RETURN */ 106 /* NO_RETURN */
112 107
113 #ifndef NO_RETURN 108 #ifndef NO_RETURN
114 #if COMPILER(GCC) 109 #if COMPILER(GCC)
115 #define NO_RETURN __attribute((__noreturn__)) 110 #define NO_RETURN __attribute((__noreturn__))
116 #elif COMPILER(MSVC) 111 #elif COMPILER(MSVC)
117 #define NO_RETURN __declspec(noreturn) 112 #define NO_RETURN __declspec(noreturn)
118 #else 113 #else
119 #define NO_RETURN 114 #define NO_RETURN
120 #endif 115 #endif
121 #endif 116 #endif
122 117
123
124 /* WARN_UNUSED_RETURN */ 118 /* WARN_UNUSED_RETURN */
125 119
126 #if COMPILER(GCC) 120 #if COMPILER(GCC)
127 #define WARN_UNUSED_RETURN __attribute__ ((warn_unused_result)) 121 #define WARN_UNUSED_RETURN __attribute__((warn_unused_result))
128 #else 122 #else
129 #define WARN_UNUSED_RETURN 123 #define WARN_UNUSED_RETURN
130 #endif 124 #endif
131 125
132
133 /* ALLOW_UNUSED_LOCAL */ 126 /* ALLOW_UNUSED_LOCAL */
134 127
135 #define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0 128 #define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0
136 129
137
138 /* OBJC_CLASS */ 130 /* OBJC_CLASS */
139 131
140 #ifndef OBJC_CLASS 132 #ifndef OBJC_CLASS
141 #ifdef __OBJC__ 133 #ifdef __OBJC__
142 #define OBJC_CLASS @class 134 #define OBJC_CLASS @class
143 #else 135 #else
144 #define OBJC_CLASS class 136 #define OBJC_CLASS class
145 #endif 137 #endif
146 #endif 138 #endif
147 139
148
149 /* WTF_PRETTY_FUNCTION */ 140 /* WTF_PRETTY_FUNCTION */
150 141
151 #if COMPILER(GCC) 142 #if COMPILER(GCC)
152 #define WTF_COMPILER_SUPPORTS_PRETTY_FUNCTION 1 143 #define WTF_COMPILER_SUPPORTS_PRETTY_FUNCTION 1
153 #define WTF_PRETTY_FUNCTION __PRETTY_FUNCTION__ 144 #define WTF_PRETTY_FUNCTION __PRETTY_FUNCTION__
154 #elif COMPILER(MSVC) 145 #elif COMPILER(MSVC)
155 #define WTF_COMPILER_SUPPORTS_PRETTY_FUNCTION 1 146 #define WTF_COMPILER_SUPPORTS_PRETTY_FUNCTION 1
156 #define WTF_PRETTY_FUNCTION __FUNCSIG__ 147 #define WTF_PRETTY_FUNCTION __FUNCSIG__
157 #else 148 #else
158 #define WTF_PRETTY_FUNCTION __FUNCTION__ 149 #define WTF_PRETTY_FUNCTION __FUNCTION__
159 #endif 150 #endif
160 151
161
162 /* NO_SANITIZE_UNRELATED_CAST - Disable runtime checks related to casts between 152 /* NO_SANITIZE_UNRELATED_CAST - Disable runtime checks related to casts between
163 * unrelated objects (-fsanitize=cfi-unrelated-cast or -fsanitize=vptr). */ 153 * unrelated objects (-fsanitize=cfi-unrelated-cast or -fsanitize=vptr). */
164 154
165 #if COMPILER(CLANG) 155 #if COMPILER(CLANG)
166 #define NO_SANITIZE_UNRELATED_CAST __attribute__((no_sanitize("cfi-unrelated-cas t", "vptr"))) 156 #define NO_SANITIZE_UNRELATED_CAST __attribute__((no_sanitize("cfi-unrelated-cas t", "vptr")))
167 #else 157 #else
168 #define NO_SANITIZE_UNRELATED_CAST 158 #define NO_SANITIZE_UNRELATED_CAST
169 #endif 159 #endif
170 160
171 #endif /* WTF_Compiler_h */ 161 #endif /* WTF_Compiler_h */
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/CheckedArithmeticTest.cpp ('k') | third_party/WebKit/Source/wtf/ConditionalDestructor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698