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

Side by Side Diff: include/v8config.h

Issue 22979004: Revert "Add V8_ALIGNOF() and use that in lazy-instance.h." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/lazy-instance.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 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 # define V8_OS_POSIX 1 79 # define V8_OS_POSIX 1
80 #elif defined(__OpenBSD__) 80 #elif defined(__OpenBSD__)
81 # define V8_OS_BSD 1 81 # define V8_OS_BSD 1
82 # define V8_OS_OPENBSD 1 82 # define V8_OS_OPENBSD 1
83 # define V8_OS_POSIX 1 83 # define V8_OS_POSIX 1
84 #elif defined(_WIN32) 84 #elif defined(_WIN32)
85 # define V8_OS_WIN 1 85 # define V8_OS_WIN 1
86 #endif 86 #endif
87 87
88 88
89 // This macro checks for a required GCC version. It also works with compilers
90 // that pretend to be GCC, i.e. Clang, ICC or the ARM compiler with the --gnu
91 // flag.
92 // Use like this if you want to check for a GCC compatible version:
93 // #if V8_GNUC_PREREQ(x, y, z)
94 // ...
95 // #endif
96 //
97 // Use like ths if you want to check for a specific GCC version:
98 // #if V8_CC_GNU && V8_GNUC_PREREQ(x, y, z)
99 // ...
100 // #endif
101 #if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
102 # define V8_GNUC_PREREQ(major, minor, patchlevel) \
103 ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \
104 ((major) * 10000 + (minor) * 100 + (patchlevel)))
105 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
106 # define V8_GNUC_PREREQ(major, minor, patchlevel) \
107 ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= \
108 ((major) * 10000 + (minor) * 100 + (patchlevel)))
109 #else
110 # define V8_GNUC_PREREQ(major, minor, patchlevel) 0
111 #endif
112
113
114 // ----------------------------------------------------------------------------- 89 // -----------------------------------------------------------------------------
115 // Compiler detection 90 // Compiler detection
116 // 91 //
117 // V8_CC_CLANG - Clang 92 // V8_CC_CLANG - Clang
118 // V8_CC_GNU - GNU C++ 93 // V8_CC_GNU - GNU C++
119 // V8_CC_MINGW - Minimalist GNU for Windows 94 // V8_CC_MINGW - Minimalist GNU for Windows
120 // V8_CC_MSVC - Microsoft Visual C/C++ 95 // V8_CC_MSVC - Microsoft Visual C/C++
121 // 96 //
122 // C++11 feature detection 97 // C++11 feature detection
123 // 98 //
124 // V8_HAS_CXX11_ALIGNAS - alignas specifier supported 99 // V8_HAS_CXX11_ALIGNAS - alignas specifier supported
125 // V8_HAS_CXX11_ALIGNOF - alignas operator supported
126 // V8_HAS_CXX11_STATIC_ASSERT - static_assert() supported 100 // V8_HAS_CXX11_STATIC_ASSERT - static_assert() supported
127 // V8_HAS_CXX11_DELETE - deleted functions supported 101 // V8_HAS_CXX11_DELETE - deleted functions supported
128 // V8_HAS_CXX11_FINAL - final marker supported 102 // V8_HAS_CXX11_FINAL - final marker supported
129 // V8_HAS_CXX11_OVERRIDE - override marker supported 103 // V8_HAS_CXX11_OVERRIDE - override marker supported
130 // 104 //
131 // Compiler-specific feature detection 105 // Compiler-specific feature detection
132 // 106 //
133 // V8_HAS___ALIGNOF - __alignof(t) operator supported 107 // V8_HAS_ATTRIBUTE___ALIGNED__ - __attribute__((__aligned__(n))) supported
134 // V8_HAS___ALIGNOF__ - __alignof__(t) operator supported
135 // V8_HAS_ATTRIBUTE_ALIGNED - __attribute__((aligned(n))) supported
136 // V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline)) supported 108 // V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline)) supported
137 // V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported 109 // V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported
138 // V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported 110 // V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported
139 // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported 111 // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported
140 // V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported 112 // V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported
141 // V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported 113 // V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported
142 // V8_HAS___FINAL - __final supported in non-C++11 mode 114 // V8_HAS___FINAL - __final supported in non-C++11 mode
143 // V8_HAS___FORCEINLINE - __forceinline supported 115 // V8_HAS___FORCEINLINE - __forceinline supported
144 // V8_HAS_SEALED - MSVC style sealed marker supported 116 // V8_HAS_SEALED - MSVC style sealed marker supported
145 117
146 #if defined(__clang__) 118 #if defined(__clang__)
147 119
120 // Don't treat clang as GCC.
121 # define V8_GNUC_PREREQ(major, minor, patchlevel) 0
122
148 # define V8_CC_CLANG 1 123 # define V8_CC_CLANG 1
149 124
150 # define V8_HAS___ALIGNOF__ (V8_GNUC_PREREQ(2, 95, 0)) 125 # define V8_HAS_ATTRIBUTE___ALIGNED__ (__has_attribute(__aligned__))
151
152 # define V8_HAS_ATTRIBUTE_ALIGNED (__has_attribute(aligned))
153 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) 126 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline))
154 # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated)) 127 # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated))
155 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility)) 128 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility))
156 129
157 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) 130 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect))
158 131
159 # define V8_HAS_CXX11_ALIGNAS (__has_feature(cxx_alignas)) 132 # define V8_HAS_CXX11_ALIGNAS (__has_feature(cxx_alignas))
160 # define V8_HAS_CXX11_STATIC_ASSERT (__has_feature(cxx_static_assert)) 133 # define V8_HAS_CXX11_STATIC_ASSERT (__has_feature(cxx_static_assert))
161 # define V8_HAS_CXX11_DELETE (__has_feature(cxx_deleted_functions)) 134 # define V8_HAS_CXX11_DELETE (__has_feature(cxx_deleted_functions))
162 # define V8_HAS_CXX11_FINAL (__has_feature(cxx_override_control)) 135 # define V8_HAS_CXX11_FINAL (__has_feature(cxx_override_control))
163 # define V8_HAS_CXX11_OVERRIDE (__has_feature(cxx_override_control)) 136 # define V8_HAS_CXX11_OVERRIDE (__has_feature(cxx_override_control))
164 137
165 #elif defined(__GNUC__) 138 #elif defined(__GNUC__)
166 139
140 # define V8_GNUC_PREREQ(major, minor, patchlevel) \
141 ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \
142 ((major) * 10000 + (minor) * 100 + (patchlevel)))
143
167 # define V8_CC_GNU 1 144 # define V8_CC_GNU 1
168 # if defined(__MINGW32__) 145 # if defined(__MINGW32__)
169 # define V8_CC_MINGW 1 146 # define V8_CC_MINGW 1
170 # endif 147 # endif
171 148
172 # define V8_HAS___ALIGNOF__ (V8_GNUC_PREREQ(2, 95, 0)) 149 # define V8_HAS_ATTRIBUTE___ALIGNED__ (V8_GNUC_PREREQ(2, 95, 0))
173
174 # define V8_HAS_ATTRIBUTE_ALIGNED (V8_GNUC_PREREQ(2, 95, 0))
175 // always_inline is available in gcc 4.0 but not very reliable until 4.4. 150 // always_inline is available in gcc 4.0 but not very reliable until 4.4.
176 // Works around "sorry, unimplemented: inlining failed" build errors with 151 // Works around "sorry, unimplemented: inlining failed" build errors with
177 // older compilers. 152 // older compilers.
178 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0)) 153 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0))
179 # define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0)) 154 # define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0))
180 # define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0)) 155 # define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0))
181 156
182 # define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0)) 157 # define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0))
183 158
184 // g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality 159 // g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality
185 // without warnings (functionality used by the macros below). These modes 160 // without warnings (functionality used by the macros below). These modes
186 // are detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, 161 // are detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or,
187 // more standardly, by checking whether __cplusplus has a C++11 or greater 162 // more standardly, by checking whether __cplusplus has a C++11 or greater
188 // value. Current versions of g++ do not correctly set __cplusplus, so we check 163 // value. Current versions of g++ do not correctly set __cplusplus, so we check
189 // both for forward compatibility. 164 // both for forward compatibility.
190 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L 165 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
191 # define V8_HAS_CXX11_ALIGNAS (V8_GNUC_PREREQ(4, 8, 0)) 166 # define V8_HAS_CXX11_ALIGNAS (V8_GNUC_PREREQ(4, 8, 0))
192 # define V8_HAS_CXX11_ALIGNOF (V8_GNUC_PREREQ(4, 5, 0))
193 # define V8_HAS_CXX11_STATIC_ASSERT (V8_GNUC_PREREQ(4, 3, 0)) 167 # define V8_HAS_CXX11_STATIC_ASSERT (V8_GNUC_PREREQ(4, 3, 0))
194 # define V8_HAS_CXX11_DELETE (V8_GNUC_PREREQ(4, 4, 0)) 168 # define V8_HAS_CXX11_DELETE (V8_GNUC_PREREQ(4, 4, 0))
195 # define V8_HAS_CXX11_OVERRIDE (V8_GNUC_PREREQ(4, 7, 0)) 169 # define V8_HAS_CXX11_OVERRIDE (V8_GNUC_PREREQ(4, 7, 0))
196 # define V8_HAS_CXX11_FINAL (V8_GNUC_PREREQ(4, 7, 0)) 170 # define V8_HAS_CXX11_FINAL (V8_GNUC_PREREQ(4, 7, 0))
197 # else 171 # else
198 // '__final' is a non-C++11 GCC synonym for 'final', per GCC r176655. 172 // '__final' is a non-C++11 GCC synonym for 'final', per GCC r176655.
199 # define V8_HAS___FINAL (V8_GNUC_PREREQ(4, 7, 0)) 173 # define V8_HAS___FINAL (V8_GNUC_PREREQ(4, 7, 0))
200 # endif 174 # endif
201 175
202 #elif defined(_MSC_VER) 176 #elif defined(_MSC_VER)
203 177
178 # define V8_GNUC_PREREQ(major, minor, patchlevel) 0
179
204 # define V8_CC_MSVC 1 180 # define V8_CC_MSVC 1
205 181
206 // Override control was added with Visual Studio 2005, but 182 // Override control was added with Visual Studio 2005, but
207 // Visual Studio 2010 and earlier spell "final" as "sealed". 183 // Visual Studio 2010 and earlier spell "final" as "sealed".
208 # define V8_HAS_CXX11_FINAL (_MSC_VER >= 1700) 184 # define V8_HAS_CXX11_FINAL (_MSC_VER >= 1700)
209 # define V8_HAS_CXX11_OVERRIDE (_MSC_VER >= 1400) 185 # define V8_HAS_CXX11_OVERRIDE (_MSC_VER >= 1400)
210 # define V8_HAS_SEALED (_MSC_VER >= 1400) 186 # define V8_HAS_SEALED (_MSC_VER >= 1400)
211 187
212 # define V8_HAS_DECLSPEC_ALIGN 1 188 # define V8_HAS_DECLSPEC_ALIGN 1
213 # define V8_HAS_DECLSPEC_DEPRECATED (_MSC_VER >= 1300) 189 # define V8_HAS_DECLSPEC_DEPRECATED (_MSC_VER >= 1300)
214 190
215 # define V8_HAS___ALIGNOF 1
216 # define V8_HAS___FORCEINLINE 1 191 # define V8_HAS___FORCEINLINE 1
217 192
218 #endif 193 #endif
219 194
220 195
221 // ----------------------------------------------------------------------------- 196 // -----------------------------------------------------------------------------
222 // Helper macros 197 // Helper macros
223 198
224 // A macro used to make better inlining. Don't bother for debug builds. 199 // A macro used to make better inlining. Don't bother for debug builds.
225 #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE 200 #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 # define V8_FINAL /* NOT SUPPORTED */ 272 # define V8_FINAL /* NOT SUPPORTED */
298 #endif 273 #endif
299 274
300 275
301 // This macro allows to specify memory alignment for structs, classes, etc. 276 // This macro allows to specify memory alignment for structs, classes, etc.
302 // Use like: 277 // Use like:
303 // class V8_ALIGNAS(16) MyClass { ... }; 278 // class V8_ALIGNAS(16) MyClass { ... };
304 // V8_ALIGNAS(32) int array[42]; 279 // V8_ALIGNAS(32) int array[42];
305 #if V8_HAS_CXX11_ALIGNAS 280 #if V8_HAS_CXX11_ALIGNAS
306 # define V8_ALIGNAS(n) alignas(n) 281 # define V8_ALIGNAS(n) alignas(n)
307 #elif V8_HAS_ATTRIBUTE_ALIGNED 282 #elif V8_HAS_ATTRIBUTE___ALIGNED__
308 # define V8_ALIGNAS(n) __attribute__((aligned(n))) 283 # define V8_ALIGNAS(n) __attribute__((__aligned__(n)))
309 #elif V8_HAS_DECLSPEC_ALIGN 284 #elif V8_HAS_DECLSPEC_ALIGN
310 # define V8_ALIGNAS(n) __declspec(align(n)) 285 # define V8_ALIGNAS(n) __declspec(align(n))
311 #else 286 #else
312 # define V8_ALIGNAS(n) /* NOT SUPPORTED */ 287 # define V8_ALIGNAS(n) /* NOT SUPPORTED */
313 #endif 288 #endif
314 289
315 // This macro takes a type and returns the power of 2 byte boundary on which
316 // the type instances must be allocated.
317 // Use like:
318 // size_t alignment = V8_ALIGNOF(double);
319 // V8_ALIGNAS(V8_ALIGNOF(void*)) int x;
320 #if V8_HAS_CXX11_ALIGNOF
321 # define V8_ALIGNOF(t) alignof(t)
322 #elif V8_HAS___ALIGNOF
323 # define V8_ALIGNOF(t) __alignof(t)
324 #elif V8_HAS___ALIGNOF__
325 # define V8_ALIGNOF(t) __alignof__(t)
326 #else
327 namespace v8 { template <typename T> struct AlignOfHelper { char x; T t; }; }
328 # define V8_ALIGNOF(t) (sizeof(::v8::AlignOfHelper<t>) - sizeof(t))
329 #endif
330
331 #endif // V8CONFIG_H_ 290 #endif // V8CONFIG_H_
OLDNEW
« no previous file with comments | « no previous file | src/lazy-instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698