Chromium Code Reviews| Index: base/compiler_specific.h |
| diff --git a/base/compiler_specific.h b/base/compiler_specific.h |
| index 0a6e05a6c67988b64b416b612d47ec41c457a78f..c47362a4e55c6932acfefa3277a19244b648afed 100644 |
| --- a/base/compiler_specific.h |
| +++ b/base/compiler_specific.h |
| @@ -96,6 +96,25 @@ |
| #define NOINLINE |
| #endif |
| +// Specify memory alignment for structs, classes or data. |
| +// Use like: |
| +// class ALIGNED(16) MyClass { ... } |
| +// int array[4] ALIGNED(16); |
| +#if defined(COMPILER_MSVC) |
| +#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
|
| +#elif defined(COMPILER_GCC) |
| +#define ALIGNED(byte_alignment) __attribute__((aligned(byte_alignment))) |
| +#endif |
| + |
| +// Return the byte alignment of the given type (available at compile time). |
| +// Use like: |
| +// ALIGNOF(int32) // this would be 4 |
| +#if defined(COMPILER_MSVC) |
| +#define ALIGNOF(type) __alignof(type) |
| +#elif defined(COMPILER_GCC) |
| +#define ALIGNOF(type) __alignof__(type) |
| +#endif |
| + |
| // Annotate a virtual method indicating it must be overriding a virtual |
| // method in the parent class. |
| // Use like: |