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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // Specify memory alignment for structs, classes, etc. | 107 // Specify memory alignment for structs, classes, etc. |
108 // Use like: | 108 // Use like: |
109 // class ALIGNAS(16) MyClass { ... } | 109 // class ALIGNAS(16) MyClass { ... } |
110 // ALIGNAS(16) int array[4]; | 110 // ALIGNAS(16) int array[4]; |
111 #if defined(COMPILER_MSVC) | 111 #if defined(COMPILER_MSVC) |
112 #define ALIGNAS(byte_alignment) __declspec(align(byte_alignment)) | 112 #define ALIGNAS(byte_alignment) __declspec(align(byte_alignment)) |
113 #elif defined(COMPILER_GCC) | 113 #elif defined(COMPILER_GCC) |
114 #define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment))) | 114 #define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment))) |
115 #endif | 115 #endif |
116 | 116 |
117 // Return the byte alignment of the given type (available at compile time). Use | 117 // Return the byte alignment of the given type (available at compile time). |
118 // sizeof(type) prior to checking __alignof to workaround Visual C++ bug: | |
119 // http://goo.gl/isH0C | |
120 // Use like: | 118 // Use like: |
121 // ALIGNOF(int32) // this would be 4 | 119 // ALIGNOF(int32) // this would be 4 |
122 #if defined(COMPILER_MSVC) | 120 #if defined(COMPILER_MSVC) |
123 #define ALIGNOF(type) (sizeof(type) - sizeof(type) + __alignof(type)) | 121 #define ALIGNOF(type) __alignof(type) |
124 #elif defined(COMPILER_GCC) | 122 #elif defined(COMPILER_GCC) |
125 #define ALIGNOF(type) __alignof__(type) | 123 #define ALIGNOF(type) __alignof__(type) |
126 #endif | 124 #endif |
127 | 125 |
128 // Annotate a virtual method indicating it must be overriding a virtual | 126 // Annotate a virtual method indicating it must be overriding a virtual |
129 // method in the parent class. | 127 // method in the parent class. |
130 // Use like: | 128 // Use like: |
131 // virtual void foo() OVERRIDE; | 129 // virtual void foo() OVERRIDE; |
132 #if defined(COMPILER_MSVC) | 130 #if defined(COMPILER_MSVC) |
133 #define OVERRIDE override | 131 #define OVERRIDE override |
(...skipping 26 matching lines...) Expand all Loading... |
160 #endif | 158 #endif |
161 | 159 |
162 // WPRINTF_FORMAT is the same, but for wide format strings. | 160 // WPRINTF_FORMAT is the same, but for wide format strings. |
163 // This doesn't appear to yet be implemented in any compiler. | 161 // This doesn't appear to yet be implemented in any compiler. |
164 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 . | 162 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 . |
165 #define WPRINTF_FORMAT(format_param, dots_param) | 163 #define WPRINTF_FORMAT(format_param, dots_param) |
166 // If available, it would look like: | 164 // If available, it would look like: |
167 // __attribute__((format(wprintf, format_param, dots_param))) | 165 // __attribute__((format(wprintf, format_param, dots_param))) |
168 | 166 |
169 #endif // BASE_COMPILER_SPECIFIC_H_ | 167 #endif // BASE_COMPILER_SPECIFIC_H_ |
OLD | NEW |