Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | |
| 2 // Redistribution and use in source and binary forms, with or without | |
| 3 // modification, are permitted provided that the following conditions are | |
| 4 // met: | |
| 5 // | |
| 6 // * Redistributions of source code must retain the above copyright | |
| 7 // notice, this list of conditions and the following disclaimer. | |
| 8 // * Redistributions in binary form must reproduce the above | |
| 9 // copyright notice, this list of conditions and the following | |
| 10 // disclaimer in the documentation and/or other materials provided | |
| 11 // with the distribution. | |
| 12 // * Neither the name of Google Inc. nor the names of its | |
| 13 // contributors may be used to endorse or promote products derived | |
| 14 // from this software without specific prior written permission. | |
| 15 // | |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 27 | |
| 28 #ifndef V8CONFIG_H_ | |
| 29 #define V8CONFIG_H_ | |
| 30 | |
| 31 // ----------------------------------------------------------------------------- | |
| 32 // Operating system detection | |
| 33 // | |
| 34 // V8_OS_ANDROID - Android | |
| 35 // V8_OS_BSD - BSDish (Mac OS X, Net/Free/Open/DragonFlyBSD) | |
| 36 // V8_OS_CYGWIN - Cygwin | |
| 37 // V8_OS_DRAGONFLYBSD - DragonFlyBSD | |
| 38 // V8_OS_FREEBSD - FreeBSD | |
| 39 // V8_OS_LINUX - Linux | |
| 40 // V8_OS_MACOSX - Mac OS X | |
| 41 // V8_OS_NACL - Native Client | |
| 42 // V8_OS_NETBSD - NetBSD | |
| 43 // V8_OS_OPENBSD - OpenBSD | |
| 44 // V8_OS_POSIX - POSIX compatible (mostly everything except Windows) | |
| 45 // V8_OS_SOLARIS - Sun Solaris and OpenSolaris | |
| 46 // V8_OS_WIN - Microsoft Windows | |
| 47 | |
| 48 #if defined(__ANDROID__) | |
| 49 # define V8_OS_ANDROID 1 | |
| 50 # define V8_OS_LINUX 1 | |
| 51 # define V8_OS_POSIX 1 | |
| 52 #elif defined(__APPLE__) | |
| 53 # define V8_OS_BSD 1 | |
| 54 # define V8_OS_MACOSX 1 | |
| 55 # define V8_OS_POSIX 1 | |
| 56 #elif defined(__native_client__) | |
| 57 # define V8_OS_NACL 1 | |
| 58 # define V8_OS_POSIX 1 | |
| 59 #elif defined(__CYGWIN__) | |
| 60 # define V8_OS_CYGWIN 1 | |
| 61 # define V8_OS_POSIX 1 | |
| 62 #elif defined(__linux__) | |
| 63 # define V8_OS_LINUX 1 | |
| 64 # define V8_OS_POSIX 1 | |
| 65 #elif defined(__sun) | |
| 66 # define V8_OS_POSIX 1 | |
| 67 # define V8_OS_SOLARIS 1 | |
| 68 #elif defined(__FreeBSD__) | |
| 69 # define V8_OS_BSD 1 | |
| 70 # define V8_OS_FREEBSD 1 | |
| 71 # define V8_OS_POSIX 1 | |
| 72 #elif defined(__DragonFly__) | |
| 73 # define V8_OS_BSD 1 | |
| 74 # define V8_OS_DRAGONFLYBSD 1 | |
| 75 # define V8_OS_POSIX 1 | |
| 76 #elif defined(__NetBSD__) | |
| 77 # define V8_OS_BSD 1 | |
| 78 # define V8_OS_NETBSD 1 | |
| 79 # define V8_OS_POSIX 1 | |
| 80 #elif defined(__OpenBSD__) | |
| 81 # define V8_OS_BSD 1 | |
| 82 # define V8_OS_OPENBSD 1 | |
| 83 # define V8_OS_POSIX 1 | |
| 84 #elif defined(_WIN32) | |
| 85 # define V8_OS_WIN 1 | |
| 86 #endif | |
| 87 | |
| 88 | |
| 89 // ----------------------------------------------------------------------------- | |
| 90 // Compiler detection | |
| 91 // | |
| 92 // V8_CC_CLANG - Clang | |
| 93 // V8_CC_GNU - GNU C++ | |
| 94 // V8_CC_MINGW - Minimalist GNU for Windows | |
| 95 // V8_CC_MSVC - Microsoft Visual C/C++ | |
| 96 // | |
| 97 // C++11 feature detection | |
| 98 // | |
| 99 // V8_HAS_CXX11_ALIGNAS - alignas specifier supported | |
| 100 // V8_HAS_CXX11_STATIC_ASSERT - static_assert() supported | |
| 101 // V8_HAS_CXX11_DELETE - deleted functions supported | |
| 102 // V8_HAS_CXX11_FINAL - final marker supported | |
| 103 // V8_HAS_CXX11_OVERRIDE - override marker supported | |
| 104 // | |
| 105 // Compiler-specific feature detection | |
| 106 // | |
| 107 // V8_HAS_ATTRIBUTE___ALIGNED__ - __attribute__((__aligned__(n))) supported | |
| 108 // V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline)) supported | |
| 109 // V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported | |
| 110 // V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported | |
| 111 // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported | |
| 112 // V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported | |
| 113 // V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported | |
| 114 // V8_HAS___FINAL - __final supported in non-C++11 mode | |
| 115 // V8_HAS___FORCEINLINE - __forceinline supported | |
| 116 // V8_HAS_SEALED - MSVC style sealed marker supported | |
| 117 | |
| 118 #if defined(__clang__) | |
|
Nico
2014/11/26 21:43:20
This doesn't look like a good approach to me. Clan
Benedikt Meurer
2014/12/01 18:02:00
So you're talking about either setting both V8_CC_
Nico
2014/12/01 18:03:48
Yes, I'd let clang set V8_CC_GNU or V8_CC_MSVC (de
Nico
2014/12/01 20:10:08
It looks like it Just Works: https://codereview.ch
| |
| 119 | |
| 120 // Don't treat clang as GCC. | |
| 121 # define V8_GNUC_PREREQ(major, minor, patchlevel) 0 | |
| 122 | |
| 123 # define V8_CC_CLANG 1 | |
| 124 | |
| 125 # define V8_HAS_ATTRIBUTE___ALIGNED__ (__has_attribute(__aligned__)) | |
| 126 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) | |
| 127 # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated)) | |
| 128 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility)) | |
| 129 | |
| 130 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) | |
| 131 | |
| 132 # define V8_HAS_CXX11_ALIGNAS (__has_feature(cxx_alignas)) | |
| 133 # define V8_HAS_CXX11_STATIC_ASSERT (__has_feature(cxx_static_assert)) | |
| 134 # define V8_HAS_CXX11_DELETE (__has_feature(cxx_deleted_functions)) | |
| 135 # define V8_HAS_CXX11_FINAL (__has_feature(cxx_override_control)) | |
| 136 # define V8_HAS_CXX11_OVERRIDE (__has_feature(cxx_override_control)) | |
| 137 | |
| 138 #elif defined(__GNUC__) | |
| 139 | |
| 140 # define V8_GNUC_PREREQ(major, minor, patchlevel) \ | |
| 141 ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \ | |
| 142 ((major) * 10000 + (minor) * 100 + (patchlevel))) | |
| 143 | |
| 144 # define V8_CC_GNU 1 | |
| 145 # if defined(__MINGW32__) | |
| 146 # define V8_CC_MINGW 1 | |
| 147 # endif | |
| 148 | |
| 149 # define V8_HAS_ATTRIBUTE___ALIGNED__ (V8_GNUC_PREREQ(2, 95, 0)) | |
| 150 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 0, 0)) | |
| 151 # define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0)) | |
| 152 # define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0)) | |
| 153 | |
| 154 # define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0)) | |
| 155 | |
| 156 // g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality | |
| 157 // without warnings (functionality used by the macros below). These modes | |
| 158 // are detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, | |
| 159 // more standardly, by checking whether __cplusplus has a C++11 or greater | |
| 160 // value. Current versions of g++ do not correctly set __cplusplus, so we check | |
| 161 // both for forward compatibility. | |
| 162 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L | |
| 163 # define V8_HAS_CXX11_ALIGNAS (V8_GNUC_PREREQ(4, 8, 0)) | |
| 164 # define V8_HAS_CXX11_STATIC_ASSERT (V8_GNUC_PREREQ(4, 3, 0)) | |
| 165 # define V8_HAS_CXX11_DELETE (V8_GNUC_PREREQ(4, 4, 0)) | |
| 166 # define V8_HAS_CXX11_OVERRIDE (V8_GNUC_PREREQ(4, 7, 0)) | |
| 167 # define V8_HAS_CXX11_FINAL (V8_GNUC_PREREQ(4, 7, 0)) | |
| 168 # else | |
| 169 // '__final' is a non-C++11 GCC synonym for 'final', per GCC r176655. | |
| 170 # define V8_HAS___FINAL (V8_GNUC_PREREQ(4, 7, 0)) | |
| 171 # endif | |
| 172 | |
| 173 #elif defined(_MSC_VER) | |
| 174 | |
| 175 # define V8_GNUC_PREREQ(major, minor, patchlevel) 0 | |
| 176 | |
| 177 # define V8_CC_MSVC 1 | |
| 178 | |
| 179 // Override control was added with Visual Studio 2005, but | |
| 180 // Visual Studio 2010 and earlier spell "final" as "sealed". | |
| 181 # define V8_HAS_CXX11_FINAL (_MSC_VER >= 1700) | |
| 182 # define V8_HAS_CXX11_OVERRIDE (_MSC_VER >= 1400) | |
| 183 # define V8_HAS_SEALED (_MSC_VER >= 1400) | |
| 184 | |
| 185 # define V8_HAS_DECLSPEC_ALIGN 1 | |
| 186 # define V8_HAS_DECLSPEC_DEPRECATED (_MSC_VER >= 1300) | |
| 187 | |
| 188 # define V8_HAS___FORCEINLINE 1 | |
| 189 | |
| 190 #endif | |
| 191 | |
| 192 | |
| 193 // ----------------------------------------------------------------------------- | |
| 194 // Helper macros | |
| 195 | |
| 196 // A macro used to make better inlining. Don't bother for debug builds. | |
| 197 #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE | |
| 198 # define V8_INLINE(declarator) inline __attribute__((always_inline)) declarator | |
| 199 #elif !defined(DEBUG) && V8_HAS___FORCEINLINE | |
| 200 # define V8_INLINE(declarator) __forceinline declarator | |
| 201 #else | |
| 202 # define V8_INLINE(declarator) inline declarator | |
| 203 #endif | |
| 204 | |
| 205 | |
| 206 // A macro to mark classes or functions as deprecated. | |
| 207 #if !V8_DISABLE_DEPRECATIONS && V8_HAS_ATTRIBUTE_DEPRECATED | |
| 208 # define V8_DEPRECATED(declarator) declarator __attribute__((deprecated)) | |
| 209 #elif !V8_DISABLE_DEPRECATIONS && V8_HAS_DECLSPEC_DEPRECATED | |
| 210 # define V8_DEPRECATED(declarator) __declspec(deprecated) declarator | |
| 211 #else | |
| 212 # define V8_DEPRECATED(declarator) declarator | |
| 213 #endif | |
| 214 | |
| 215 | |
| 216 // A macro to provide the compiler with branch prediction information. | |
| 217 #if V8_HAS_BUILTIN_EXPECT | |
| 218 # define V8_UNLIKELY(condition) (__builtin_expect(!!(condition), 0)) | |
| 219 # define V8_LIKELY(condition) (__builtin_expect(!!(condition), 1)) | |
| 220 #else | |
| 221 # define V8_UNLIKELY(condition) (condition) | |
| 222 # define V8_LIKELY(condition) (condition) | |
| 223 #endif | |
| 224 | |
| 225 | |
| 226 // A macro to specify that a method is deleted from the corresponding class. | |
| 227 // Any attempt to use the method will always produce an error at compile time | |
| 228 // when this macro can be implemented (i.e. if the compiler supports C++11). | |
| 229 // If the current compiler does not support C++11, use of the annotated method | |
| 230 // will still cause an error, but the error will most likely occur at link time | |
| 231 // rather than at compile time. As a backstop, method declarations using this | |
| 232 // macro should be private. | |
| 233 // Use like: | |
| 234 // class A { | |
| 235 // private: | |
| 236 // A(const A& other) V8_DELETE; | |
| 237 // A& operator=(const A& other) V8_DELETE; | |
| 238 // }; | |
| 239 #if V8_HAS_CXX11_DELETE | |
| 240 # define V8_DELETE = delete | |
| 241 #else | |
| 242 # define V8_DELETE /* NOT SUPPORTED */ | |
| 243 #endif | |
| 244 | |
| 245 | |
| 246 // Annotate a virtual method indicating it must be overriding a virtual | |
| 247 // method in the parent class. | |
| 248 // Use like: | |
| 249 // virtual void bar() V8_OVERRIDE; | |
| 250 #if V8_HAS_CXX11_OVERRIDE | |
| 251 # define V8_OVERRIDE override | |
| 252 #else | |
| 253 # define V8_OVERRIDE /* NOT SUPPORTED */ | |
| 254 #endif | |
| 255 | |
| 256 | |
| 257 // Annotate a virtual method indicating that subclasses must not override it, | |
| 258 // or annotate a class to indicate that it cannot be subclassed. | |
| 259 // Use like: | |
| 260 // class B V8_FINAL : public A {}; | |
| 261 // virtual void bar() V8_FINAL; | |
| 262 #if V8_HAS_CXX11_FINAL | |
| 263 # define V8_FINAL final | |
| 264 #elif V8_HAS___FINAL | |
| 265 # define V8_FINAL __final | |
| 266 #elif V8_HAS_SEALED | |
| 267 # define V8_FINAL sealed | |
| 268 #else | |
| 269 # define V8_FINAL /* NOT SUPPORTED */ | |
| 270 #endif | |
| 271 | |
| 272 | |
| 273 // This macro allows to specify memory alignment for structs, classes, etc. | |
| 274 // Use like: | |
| 275 // class V8_ALIGNAS(16) MyClass { ... }; | |
| 276 // V8_ALIGNAS(32) int array[42]; | |
| 277 #if V8_HAS_CXX11_ALIGNAS | |
| 278 # define V8_ALIGNAS(n) alignas(n) | |
| 279 #elif V8_HAS_ATTRIBUTE___ALIGNED__ | |
| 280 # define V8_ALIGNAS(n) __attribute__((__aligned__(n))) | |
| 281 #elif V8_HAS_DECLSPEC_ALIGN | |
| 282 # define V8_ALIGNAS(n) __declspec(align(n)) | |
| 283 #else | |
| 284 # define V8_ALIGNAS(n) /* NOT SUPPORTED */ | |
| 285 #endif | |
| 286 | |
| 287 #endif // V8CONFIG_H_ | |
| OLD | NEW |