Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
michael@0 | 2 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 3 | // found in the LICENSE file. |
michael@0 | 4 | |
michael@0 | 5 | #ifndef BASE_COMPILER_SPECIFIC_H_ |
michael@0 | 6 | #define BASE_COMPILER_SPECIFIC_H_ |
michael@0 | 7 | |
michael@0 | 8 | #include "build/build_config.h" |
michael@0 | 9 | |
michael@0 | 10 | #if defined(COMPILER_MSVC) |
michael@0 | 11 | |
michael@0 | 12 | // Macros for suppressing and disabling warnings on MSVC. |
michael@0 | 13 | // |
michael@0 | 14 | // Warning numbers are enumerated at: |
michael@0 | 15 | // http://msdn.microsoft.com/en-us/library/8x5x43k7(VS.80).aspx |
michael@0 | 16 | // |
michael@0 | 17 | // The warning pragma: |
michael@0 | 18 | // http://msdn.microsoft.com/en-us/library/2c8f766e(VS.80).aspx |
michael@0 | 19 | // |
michael@0 | 20 | // Using __pragma instead of #pragma inside macros: |
michael@0 | 21 | // http://msdn.microsoft.com/en-us/library/d9x1s805.aspx |
michael@0 | 22 | |
michael@0 | 23 | // MSVC_SUPPRESS_WARNING disables warning |n| for the remainder of the line and |
michael@0 | 24 | // for the next line of the source file. |
michael@0 | 25 | #define MSVC_SUPPRESS_WARNING(n) __pragma(warning(suppress:n)) |
michael@0 | 26 | |
michael@0 | 27 | // MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled. |
michael@0 | 28 | // The warning remains disabled until popped by MSVC_POP_WARNING. |
michael@0 | 29 | #define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \ |
michael@0 | 30 | __pragma(warning(disable:n)) |
michael@0 | 31 | |
michael@0 | 32 | // MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level |
michael@0 | 33 | // remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all |
michael@0 | 34 | // warnings. |
michael@0 | 35 | #define MSVC_PUSH_WARNING_LEVEL(n) __pragma(warning(push, n)) |
michael@0 | 36 | |
michael@0 | 37 | // Pop effects of innermost MSVC_PUSH_* macro. |
michael@0 | 38 | #define MSVC_POP_WARNING() __pragma(warning(pop)) |
michael@0 | 39 | |
michael@0 | 40 | #define MSVC_DISABLE_OPTIMIZE() __pragma(optimize("", off)) |
michael@0 | 41 | #define MSVC_ENABLE_OPTIMIZE() __pragma(optimize("", on)) |
michael@0 | 42 | |
michael@0 | 43 | // Allows |this| to be passed as an argument in constructor initializer lists. |
michael@0 | 44 | // This uses push/pop instead of the seemingly simpler suppress feature to avoid |
michael@0 | 45 | // having the warning be disabled for more than just |code|. |
michael@0 | 46 | // |
michael@0 | 47 | // Example usage: |
michael@0 | 48 | // Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {} |
michael@0 | 49 | // |
michael@0 | 50 | // Compiler warning C4355: 'this': used in base member initializer list: |
michael@0 | 51 | // http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx |
michael@0 | 52 | #define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \ |
michael@0 | 53 | code \ |
michael@0 | 54 | MSVC_POP_WARNING() |
michael@0 | 55 | |
michael@0 | 56 | #else // Not MSVC |
michael@0 | 57 | |
michael@0 | 58 | #define MSVC_SUPPRESS_WARNING(n) |
michael@0 | 59 | #define MSVC_PUSH_DISABLE_WARNING(n) |
michael@0 | 60 | #define MSVC_PUSH_WARNING_LEVEL(n) |
michael@0 | 61 | #define MSVC_POP_WARNING() |
michael@0 | 62 | #define MSVC_DISABLE_OPTIMIZE() |
michael@0 | 63 | #define MSVC_ENABLE_OPTIMIZE() |
michael@0 | 64 | #define ALLOW_THIS_IN_INITIALIZER_LIST(code) code |
michael@0 | 65 | |
michael@0 | 66 | #endif // COMPILER_MSVC |
michael@0 | 67 | |
michael@0 | 68 | |
michael@0 | 69 | #if defined(COMPILER_GCC) |
michael@0 | 70 | #define ALLOW_UNUSED __attribute__((unused)) |
michael@0 | 71 | #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
michael@0 | 72 | #else // Not GCC |
michael@0 | 73 | #define ALLOW_UNUSED |
michael@0 | 74 | #define WARN_UNUSED_RESULT |
michael@0 | 75 | #endif |
michael@0 | 76 | |
michael@0 | 77 | #endif // BASE_COMPILER_SPECIFIC_H_ |