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). | 117 // Return the byte alignment of the given type (available at compile time). Use |
118 // sizeof(type) prior to checking __alignof to workaround Visual C++ bug: | |
119 // http://goo.gl/isH0C | |
scherkus (not reviewing)
2012/07/19 21:49:39
FYI it's ok to exceed 80 chars for long urls
DaleCurtis
2012/07/20 02:38:56
Yeah, this one is 131 chars though, so it seemed n
| |
118 // Use like: | 120 // Use like: |
119 // ALIGNOF(int32) // this would be 4 | 121 // ALIGNOF(int32) // this would be 4 |
120 #if defined(COMPILER_MSVC) | 122 #if defined(COMPILER_MSVC) |
121 #define ALIGNOF(type) __alignof(type) | 123 #define ALIGNOF(type) (sizeof(type) - sizeof(type)) + __alignof(type) |
jbates
2012/07/19 03:45:37
parens should probably go around the whole express
DaleCurtis
2012/07/20 02:38:56
Done.
| |
122 #elif defined(COMPILER_GCC) | 124 #elif defined(COMPILER_GCC) |
123 #define ALIGNOF(type) __alignof__(type) | 125 #define ALIGNOF(type) __alignof__(type) |
124 #endif | 126 #endif |
125 | 127 |
126 // Annotate a virtual method indicating it must be overriding a virtual | 128 // Annotate a virtual method indicating it must be overriding a virtual |
127 // method in the parent class. | 129 // method in the parent class. |
128 // Use like: | 130 // Use like: |
129 // virtual void foo() OVERRIDE; | 131 // virtual void foo() OVERRIDE; |
130 #if defined(COMPILER_MSVC) | 132 #if defined(COMPILER_MSVC) |
131 #define OVERRIDE override | 133 #define OVERRIDE override |
(...skipping 26 matching lines...) Expand all Loading... | |
158 #endif | 160 #endif |
159 | 161 |
160 // WPRINTF_FORMAT is the same, but for wide format strings. | 162 // WPRINTF_FORMAT is the same, but for wide format strings. |
161 // This doesn't appear to yet be implemented in any compiler. | 163 // This doesn't appear to yet be implemented in any compiler. |
162 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 . | 164 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 . |
163 #define WPRINTF_FORMAT(format_param, dots_param) | 165 #define WPRINTF_FORMAT(format_param, dots_param) |
164 // If available, it would look like: | 166 // If available, it would look like: |
165 // __attribute__((format(wprintf, format_param, dots_param))) | 167 // __attribute__((format(wprintf, format_param, dots_param))) |
166 | 168 |
167 #endif // BASE_COMPILER_SPECIFIC_H_ | 169 #endif // BASE_COMPILER_SPECIFIC_H_ |
OLD | NEW |