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

Side by Side Diff: include/v8config.h

Issue 23717009: Improve feature detection. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Style fixes. 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 | no next file » | 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 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8CONFIG_H_ 28 #ifndef V8CONFIG_H_
29 #define V8CONFIG_H_ 29 #define V8CONFIG_H_
30 30
31 // Platform headers for feature detection below.
32 #if defined(__ANDROID__)
33 # include <sys/cdefs.h>
34 #elif defined(__APPLE__)
35 # include <TargetConditions.h>
36 #elif defined(__linux__)
37 # include <features.h>
38 #endif
39
40
41 // This macro allows to test for the version of the GNU C library (or
42 // a compatible C library that masquerades as glibc). It evaluates to
43 // 0 if libc is not GNU libc or compatible.
44 // Use like:
45 // #if V8_GLIBC_PREREQ(2, 3)
46 // ...
47 // #endif
48 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
49 # define V8_GLIBC_PREREQ(major, minor) \
50 ((__GLIBC__ * 100 + __GLIBC_MINOR__) >= ((major) * 100 + (minor)))
51 #else
52 # define V8_GLIBC_PREREQ(major, minor) 0
53 #endif
54
55
56 // This macro allows to test for the version of the GNU C++ compiler.
57 // Note that this also applies to compilers that masquerade as GCC,
58 // for example clang and the Intel C++ compiler for Linux.
59 // Use like:
60 // #if V8_GNUC_PREREQ(4, 3, 1)
61 // ...
62 // #endif
63 #if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
64 # define V8_GNUC_PREREQ(major, minor, patchlevel) \
65 ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \
66 ((major) * 10000 + (minor) * 100 + (patchlevel)))
67 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
68 # define V8_GNUC_PREREQ(major, minor, patchlevel) \
69 ((__GNUC__ * 10000 + __GNUC_MINOR__) >= \
70 ((major) * 10000 + (minor) * 100 + (patchlevel)))
71 #else
72 # define V8_GNUC_PREREQ(major, minor, patchlevel) 0
73 #endif
74
75
76
31 // ----------------------------------------------------------------------------- 77 // -----------------------------------------------------------------------------
32 // Operating system detection 78 // Operating system detection
33 // 79 //
34 // V8_OS_ANDROID - Android 80 // V8_OS_ANDROID - Android
35 // V8_OS_BSD - BSDish (Mac OS X, Net/Free/Open/DragonFlyBSD) 81 // V8_OS_BSD - BSDish (Mac OS X, Net/Free/Open/DragonFlyBSD)
36 // V8_OS_CYGWIN - Cygwin 82 // V8_OS_CYGWIN - Cygwin
37 // V8_OS_DRAGONFLYBSD - DragonFlyBSD 83 // V8_OS_DRAGONFLYBSD - DragonFlyBSD
38 // V8_OS_FREEBSD - FreeBSD 84 // V8_OS_FREEBSD - FreeBSD
39 // V8_OS_LINUX - Linux 85 // V8_OS_LINUX - Linux
40 // V8_OS_MACOSX - Mac OS X 86 // V8_OS_MACOSX - Mac OS X
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 #elif defined(__OpenBSD__) 126 #elif defined(__OpenBSD__)
81 # define V8_OS_BSD 1 127 # define V8_OS_BSD 1
82 # define V8_OS_OPENBSD 1 128 # define V8_OS_OPENBSD 1
83 # define V8_OS_POSIX 1 129 # define V8_OS_POSIX 1
84 #elif defined(_WIN32) 130 #elif defined(_WIN32)
85 # define V8_OS_WIN 1 131 # define V8_OS_WIN 1
86 #endif 132 #endif
87 133
88 134
89 // ----------------------------------------------------------------------------- 135 // -----------------------------------------------------------------------------
136 // C library detection
137 //
138 // V8_LIBC_BIONIC - Bionic libc
139 // V8_LIBC_BSD - BSD libc derivate
140 // V8_LIBC_GLIBC - GNU C library
141 // V8_LIBC_UCLIBC - uClibc
142 //
143 // Note that testing for libc must be done using #if not #ifdef. For example,
144 // to test for the GNU C library, use:
145 // #if V8_LIBC_GLIBC
146 // ...
147 // #endif
148
149 #if defined(__BIONIC__)
150 # define V8_LIBC_BIONIC 1
151 # define V8_LIBC_BSD 1
152 #elif defined(__UCLIBC__)
153 # define V8_LIBC_UCLIBC 1
154 #elif defined(__GLIBC__) || defined(__GNU_LIBRARY__)
155 # define V8_LIBC_GLIBC 1
156 #else
157 # define V8_LIBC_BSD V8_OS_BSD
158 #endif
159
160
161 // -----------------------------------------------------------------------------
90 // Compiler detection 162 // Compiler detection
91 // 163 //
92 // V8_CC_CLANG - Clang 164 // V8_CC_CLANG - Clang
93 // V8_CC_GNU - GNU C++ 165 // V8_CC_GNU - GNU C++
94 // V8_CC_INTEL - Intel C++ 166 // V8_CC_INTEL - Intel C++
95 // V8_CC_MINGW - Minimalist GNU for Windows 167 // V8_CC_MINGW - Minimalist GNU for Windows
96 // V8_CC_MINGW32 - Minimalist GNU for Windows (mingw32) 168 // V8_CC_MINGW32 - Minimalist GNU for Windows (mingw32)
97 // V8_CC_MINGW64 - Minimalist GNU for Windows (mingw-w64) 169 // V8_CC_MINGW64 - Minimalist GNU for Windows (mingw-w64)
98 // V8_CC_MSVC - Microsoft Visual C/C++ 170 // V8_CC_MSVC - Microsoft Visual C/C++
99 // 171 //
(...skipping 27 matching lines...) Expand all
127 // V8_HAS_SEALED - MSVC style sealed marker supported 199 // V8_HAS_SEALED - MSVC style sealed marker supported
128 // 200 //
129 // Note that testing for compilers and/or features must be done using #if 201 // Note that testing for compilers and/or features must be done using #if
130 // not #ifdef. For example, to test for Intel C++ Compiler, use: 202 // not #ifdef. For example, to test for Intel C++ Compiler, use:
131 // #if V8_CC_INTEL 203 // #if V8_CC_INTEL
132 // ... 204 // ...
133 // #endif 205 // #endif
134 206
135 #if defined(__clang__) 207 #if defined(__clang__)
136 208
137 // Don't treat clang as GCC.
138 # define V8_GNUC_PREREQ(major, minor, patchlevel) 0
139
140 # define V8_CC_CLANG 1 209 # define V8_CC_CLANG 1
141 210
142 // Clang defines __alignof__ as alias for __alignof 211 // Clang defines __alignof__ as alias for __alignof
143 # define V8_HAS___ALIGNOF 1 212 # define V8_HAS___ALIGNOF 1
144 # define V8_HAS___ALIGNOF__ V8_HAS___ALIGNOF 213 # define V8_HAS___ALIGNOF__ V8_HAS___ALIGNOF
145 214
146 # define V8_HAS_ATTRIBUTE_ALIGNED (__has_attribute(aligned)) 215 # define V8_HAS_ATTRIBUTE_ALIGNED (__has_attribute(aligned))
147 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) 216 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline))
148 # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated)) 217 # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated))
149 # define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline)) 218 # define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline))
150 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility)) 219 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility))
151 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ 220 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \
152 (__has_attribute(warn_unused_result)) 221 (__has_attribute(warn_unused_result))
153 222
154 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) 223 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect))
155 224
156 # define V8_HAS_CXX11_ALIGNAS (__has_feature(cxx_alignas)) 225 # define V8_HAS_CXX11_ALIGNAS (__has_feature(cxx_alignas))
157 # define V8_HAS_CXX11_STATIC_ASSERT (__has_feature(cxx_static_assert)) 226 # define V8_HAS_CXX11_STATIC_ASSERT (__has_feature(cxx_static_assert))
158 # define V8_HAS_CXX11_DELETE (__has_feature(cxx_deleted_functions)) 227 # define V8_HAS_CXX11_DELETE (__has_feature(cxx_deleted_functions))
159 # define V8_HAS_CXX11_FINAL (__has_feature(cxx_override_control)) 228 # define V8_HAS_CXX11_FINAL (__has_feature(cxx_override_control))
160 # define V8_HAS_CXX11_OVERRIDE (__has_feature(cxx_override_control)) 229 # define V8_HAS_CXX11_OVERRIDE (__has_feature(cxx_override_control))
161 230
162 #elif defined(__GNUC__) 231 #elif defined(__GNUC__)
163 232
164 # define V8_GNUC_PREREQ(major, minor, patchlevel) \
165 ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \
166 ((major) * 10000 + (minor) * 100 + (patchlevel)))
167
168 # define V8_CC_GNU 1 233 # define V8_CC_GNU 1
169 // Intel C++ also masquerades as GCC 3.2.0 234 // Intel C++ also masquerades as GCC 3.2.0
170 # define V8_CC_INTEL (defined(__INTEL_COMPILER)) 235 # define V8_CC_INTEL (defined(__INTEL_COMPILER))
171 # define V8_CC_MINGW32 (defined(__MINGW32__)) 236 # define V8_CC_MINGW32 (defined(__MINGW32__))
172 # define V8_CC_MINGW64 (defined(__MINGW64__)) 237 # define V8_CC_MINGW64 (defined(__MINGW64__))
173 # define V8_CC_MINGW (V8_CC_MINGW32 || V8_CC_MINGW64) 238 # define V8_CC_MINGW (V8_CC_MINGW32 || V8_CC_MINGW64)
174 239
175 # define V8_HAS___ALIGNOF__ (V8_GNUC_PREREQ(4, 3, 0)) 240 # define V8_HAS___ALIGNOF__ (V8_GNUC_PREREQ(4, 3, 0))
176 241
177 # define V8_HAS_ATTRIBUTE_ALIGNED (V8_GNUC_PREREQ(2, 95, 0)) 242 # define V8_HAS_ATTRIBUTE_ALIGNED (V8_GNUC_PREREQ(2, 95, 0))
(...skipping 22 matching lines...) Expand all
200 # define V8_HAS_CXX11_DELETE (V8_GNUC_PREREQ(4, 4, 0)) 265 # define V8_HAS_CXX11_DELETE (V8_GNUC_PREREQ(4, 4, 0))
201 # define V8_HAS_CXX11_OVERRIDE (V8_GNUC_PREREQ(4, 7, 0)) 266 # define V8_HAS_CXX11_OVERRIDE (V8_GNUC_PREREQ(4, 7, 0))
202 # define V8_HAS_CXX11_FINAL (V8_GNUC_PREREQ(4, 7, 0)) 267 # define V8_HAS_CXX11_FINAL (V8_GNUC_PREREQ(4, 7, 0))
203 # else 268 # else
204 // '__final' is a non-C++11 GCC synonym for 'final', per GCC r176655. 269 // '__final' is a non-C++11 GCC synonym for 'final', per GCC r176655.
205 # define V8_HAS___FINAL (V8_GNUC_PREREQ(4, 7, 0)) 270 # define V8_HAS___FINAL (V8_GNUC_PREREQ(4, 7, 0))
206 # endif 271 # endif
207 272
208 #elif defined(_MSC_VER) 273 #elif defined(_MSC_VER)
209 274
210 # define V8_GNUC_PREREQ(major, minor, patchlevel) 0
211
212 # define V8_CC_MSVC 1 275 # define V8_CC_MSVC 1
213 276
214 # define V8_HAS___ALIGNOF 1 277 # define V8_HAS___ALIGNOF 1
215 278
216 // Override control was added with Visual Studio 2005, but 279 // Override control was added with Visual Studio 2005, but
217 // Visual Studio 2010 and earlier spell "final" as "sealed". 280 // Visual Studio 2010 and earlier spell "final" as "sealed".
218 # define V8_HAS_CXX11_FINAL (_MSC_VER >= 1700) 281 # define V8_HAS_CXX11_FINAL (_MSC_VER >= 1700)
219 # define V8_HAS_CXX11_OVERRIDE (_MSC_VER >= 1400) 282 # define V8_HAS_CXX11_OVERRIDE (_MSC_VER >= 1400)
220 # define V8_HAS_SEALED (_MSC_VER >= 1400) 283 # define V8_HAS_SEALED (_MSC_VER >= 1400)
221 284
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 # define V8_ALIGNOF(type) __alignof__(type) 438 # define V8_ALIGNOF(type) __alignof__(type)
376 #else 439 #else
377 // Note that alignment of a type within a struct can be less than the 440 // Note that alignment of a type within a struct can be less than the
378 // alignment of the type stand-alone (because of ancient ABIs), so this 441 // alignment of the type stand-alone (because of ancient ABIs), so this
379 // should only be used as a last resort. 442 // should only be used as a last resort.
380 namespace v8 { template <typename T> class AlignOfHelper { char c; T t; }; } 443 namespace v8 { template <typename T> class AlignOfHelper { char c; T t; }; }
381 # define V8_ALIGNOF(type) (sizeof(::v8::AlignOfHelper<type>) - sizeof(type)) 444 # define V8_ALIGNOF(type) (sizeof(::v8::AlignOfHelper<type>) - sizeof(type))
382 #endif 445 #endif
383 446
384 #endif // V8CONFIG_H_ 447 #endif // V8CONFIG_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698