OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 #endif // COMPILER_MSVC | 83 #endif // COMPILER_MSVC |
84 | 84 |
85 | 85 |
86 // Annotate a variable indicating it's ok if the variable is not used. | 86 // Annotate a variable indicating it's ok if the variable is not used. |
87 // (Typically used to silence a compiler warning when the assignment | 87 // (Typically used to silence a compiler warning when the assignment |
88 // is important for some other reason.) | 88 // is important for some other reason.) |
89 // Use like: | 89 // Use like: |
90 // int x ALLOW_UNUSED = ...; | 90 // int x ALLOW_UNUSED = ...; |
91 #if defined(COMPILER_GCC) | 91 #if defined(COMPILER_GCC) |
92 #define ALLOW_UNUSED __attribute__((unused)) | 92 #define ALLOW_UNUSED __attribute__((unused)) |
93 #define NOINLINE __attribute__((noinline)) | |
94 #else | 93 #else |
95 #define ALLOW_UNUSED | 94 #define ALLOW_UNUSED |
95 #endif | |
96 | |
97 // Annotate a function indicating it should not be inlined. | |
98 // Use like: | |
99 // NOINLINE void DoStuff() { ... } | |
Nico
2012/02/10 22:54:57
Hm, this seems not general enough for me to belong
eroman
2012/02/10 23:06:00
To be clear this was already present in base, I am
| |
100 #if defined(COMPILER_GCC) | |
101 #define NOINLINE __attribute__((noinline)) | |
102 #elif defined(COMPILER_MSVC) | |
103 #define NOINLINE __declspec(noinline) | |
104 #else | |
96 #define NOINLINE | 105 #define NOINLINE |
97 #endif | 106 #endif |
98 | 107 |
99 // Annotate a virtual method indicating it must be overriding a virtual | 108 // Annotate a virtual method indicating it must be overriding a virtual |
100 // method in the parent class. | 109 // method in the parent class. |
101 // Use like: | 110 // Use like: |
102 // virtual void foo() OVERRIDE; | 111 // virtual void foo() OVERRIDE; |
103 #if defined(COMPILER_MSVC) | 112 #if defined(COMPILER_MSVC) |
104 #define OVERRIDE override | 113 #define OVERRIDE override |
105 #elif defined(__clang__) | 114 #elif defined(__clang__) |
(...skipping 25 matching lines...) Expand all Loading... | |
131 #endif | 140 #endif |
132 | 141 |
133 // WPRINTF_FORMAT is the same, but for wide format strings. | 142 // WPRINTF_FORMAT is the same, but for wide format strings. |
134 // This doesn't appear to yet be implemented in any compiler. | 143 // This doesn't appear to yet be implemented in any compiler. |
135 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 . | 144 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 . |
136 #define WPRINTF_FORMAT(format_param, dots_param) | 145 #define WPRINTF_FORMAT(format_param, dots_param) |
137 // If available, it would look like: | 146 // If available, it would look like: |
138 // __attribute__((format(wprintf, format_param, dots_param))) | 147 // __attribute__((format(wprintf, format_param, dots_param))) |
139 | 148 |
140 #endif // BASE_COMPILER_SPECIFIC_H_ | 149 #endif // BASE_COMPILER_SPECIFIC_H_ |
OLD | NEW |