OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_COMPILER_SPECIFIC_H_ | 5 #ifndef BASE_COMPILER_SPECIFIC_H_ |
6 #define BASE_COMPILER_SPECIFIC_H_ | 6 #define BASE_COMPILER_SPECIFIC_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #if defined(COMPILER_MSVC) | 10 #if defined(COMPILER_MSVC) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 #define MSVC_PUSH_DISABLE_WARNING(n) | 61 #define MSVC_PUSH_DISABLE_WARNING(n) |
62 #define MSVC_PUSH_WARNING_LEVEL(n) | 62 #define MSVC_PUSH_WARNING_LEVEL(n) |
63 #define MSVC_POP_WARNING() | 63 #define MSVC_POP_WARNING() |
64 #define MSVC_DISABLE_OPTIMIZE() | 64 #define MSVC_DISABLE_OPTIMIZE() |
65 #define MSVC_ENABLE_OPTIMIZE() | 65 #define MSVC_ENABLE_OPTIMIZE() |
66 #define NON_EXPORTED_BASE(code) code | 66 #define NON_EXPORTED_BASE(code) code |
67 | 67 |
68 #endif // COMPILER_MSVC | 68 #endif // COMPILER_MSVC |
69 | 69 |
70 | 70 |
71 // The C++ standard requires that static const members have an out-of-class | |
72 // definition (in a single compilation unit), but MSVC chokes on this (when | |
73 // language extensions, which are required, are enabled). (You're only likely to | |
74 // notice the need for a definition if you take the address of the member or, | |
75 // more commonly, pass it to a function that takes it as a reference argument -- | |
76 // probably an STL function.) This macro makes MSVC do the right thing. See | |
77 // http://msdn.microsoft.com/en-us/library/34h23df8(v=vs.100).aspx for more | |
78 // information. Use like: | |
79 // | |
80 // In .h file: | |
81 // struct Foo { | |
82 // static const int kBar = 5; | |
83 // }; | |
84 // | |
85 // In .cc file: | |
86 // STATIC_CONST_MEMBER_DEFINITION const int Foo::kBar; | |
87 #if defined(COMPILER_MSVC) | |
88 #define STATIC_CONST_MEMBER_DEFINITION __declspec(selectany) | |
89 #else | |
90 #define STATIC_CONST_MEMBER_DEFINITION | |
91 #endif | |
Nico
2013/11/07 19:50:35
Ugh, can we just use an enum? That's what we've do
viettrungluu
2013/11/08 19:05:41
a) enums aren't typed, which is unfortunate.
b) It
| |
92 | |
71 // Annotate a variable indicating it's ok if the variable is not used. | 93 // Annotate a variable indicating it's ok if the variable is not used. |
72 // (Typically used to silence a compiler warning when the assignment | 94 // (Typically used to silence a compiler warning when the assignment |
73 // is important for some other reason.) | 95 // is important for some other reason.) |
74 // Use like: | 96 // Use like: |
75 // int x ALLOW_UNUSED = ...; | 97 // int x ALLOW_UNUSED = ...; |
76 #if defined(COMPILER_GCC) | 98 #if defined(COMPILER_GCC) |
77 #define ALLOW_UNUSED __attribute__((unused)) | 99 #define ALLOW_UNUSED __attribute__((unused)) |
78 #else | 100 #else |
79 #define ALLOW_UNUSED | 101 #define ALLOW_UNUSED |
80 #endif | 102 #endif |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 | 197 |
176 // Mark a memory region fully initialized. | 198 // Mark a memory region fully initialized. |
177 // Use this to annotate code that deliberately reads uninitialized data, for | 199 // Use this to annotate code that deliberately reads uninitialized data, for |
178 // example a GC scavenging root set pointers from the stack. | 200 // example a GC scavenging root set pointers from the stack. |
179 #define MSAN_UNPOISON(p, s) __msan_unpoison(p, s) | 201 #define MSAN_UNPOISON(p, s) __msan_unpoison(p, s) |
180 #else // MEMORY_SANITIZER | 202 #else // MEMORY_SANITIZER |
181 #define MSAN_UNPOISON(p, s) | 203 #define MSAN_UNPOISON(p, s) |
182 #endif // MEMORY_SANITIZER | 204 #endif // MEMORY_SANITIZER |
183 | 205 |
184 #endif // BASE_COMPILER_SPECIFIC_H_ | 206 #endif // BASE_COMPILER_SPECIFIC_H_ |
OLD | NEW |