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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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)) | 93 #define NOINLINE __attribute__((noinline)) |
94 #else | 94 #else |
95 #define ALLOW_UNUSED | 95 #define ALLOW_UNUSED |
96 #define NOINLINE | 96 #define NOINLINE |
97 #endif | 97 #endif |
98 | 98 |
99 // Specify memory alignment for structs, classes or data. | |
100 // Use like: | |
101 // class ALIGNED(16) MyClass { ... } | |
102 // int array[4] ALIGNED(16); | |
103 #if defined(COMPILER_MSVC) | |
104 #define ALIGNED(byte_alignment) __declspec(align(byte_alignment)) | |
Sigurður Ásgeirsson
2012/01/13 14:32:18
MSVS wants __declspec to precede the declarator, w
jbates
2012/01/13 17:29:18
At least for struct and class, I think GCC allows
| |
105 #elif defined(COMPILER_GCC) | |
106 #define ALIGNED(byte_alignment) __attribute__((aligned(byte_alignment))) | |
107 #endif | |
108 | |
109 // Return the byte alignment of the given type (available at compile time). | |
110 // Use like: | |
111 // ALIGNOF(int32) // this would be 4 | |
112 #if defined(COMPILER_MSVC) | |
113 #define ALIGNOF(type) __alignof(type) | |
114 #elif defined(COMPILER_GCC) | |
115 #define ALIGNOF(type) __alignof__(type) | |
116 #endif | |
117 | |
99 // Annotate a virtual method indicating it must be overriding a virtual | 118 // Annotate a virtual method indicating it must be overriding a virtual |
100 // method in the parent class. | 119 // method in the parent class. |
101 // Use like: | 120 // Use like: |
102 // virtual void foo() OVERRIDE; | 121 // virtual void foo() OVERRIDE; |
103 #if defined(COMPILER_MSVC) | 122 #if defined(COMPILER_MSVC) |
104 #define OVERRIDE override | 123 #define OVERRIDE override |
105 #elif defined(__clang__) | 124 #elif defined(__clang__) |
106 #define OVERRIDE override | 125 #define OVERRIDE override |
107 #else | 126 #else |
108 #define OVERRIDE | 127 #define OVERRIDE |
(...skipping 22 matching lines...) Expand all Loading... | |
131 #endif | 150 #endif |
132 | 151 |
133 // WPRINTF_FORMAT is the same, but for wide format strings. | 152 // WPRINTF_FORMAT is the same, but for wide format strings. |
134 // This doesn't appear to yet be implemented in any compiler. | 153 // This doesn't appear to yet be implemented in any compiler. |
135 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 . | 154 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 . |
136 #define WPRINTF_FORMAT(format_param, dots_param) | 155 #define WPRINTF_FORMAT(format_param, dots_param) |
137 // If available, it would look like: | 156 // If available, it would look like: |
138 // __attribute__((format(wprintf, format_param, dots_param))) | 157 // __attribute__((format(wprintf, format_param, dots_param))) |
139 | 158 |
140 #endif // BASE_COMPILER_SPECIFIC_H_ | 159 #endif // BASE_COMPILER_SPECIFIC_H_ |
OLD | NEW |