Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(613)

Side by Side Diff: base/compiler_specific.h

Issue 9186057: Add ALIGNAS and ALIGNOF macros to ensure proper alignment of StaticMemorySingletonTraits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: willchan feedback Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/base.gyp ('k') | base/lazy_instance.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #pragma once 7 #pragma once
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // Use like: 98 // Use like:
99 // NOINLINE void DoStuff() { ... } 99 // NOINLINE void DoStuff() { ... }
100 #if defined(COMPILER_GCC) 100 #if defined(COMPILER_GCC)
101 #define NOINLINE __attribute__((noinline)) 101 #define NOINLINE __attribute__((noinline))
102 #elif defined(COMPILER_MSVC) 102 #elif defined(COMPILER_MSVC)
103 #define NOINLINE __declspec(noinline) 103 #define NOINLINE __declspec(noinline)
104 #else 104 #else
105 #define NOINLINE 105 #define NOINLINE
106 #endif 106 #endif
107 107
108 // Specify memory alignment for structs, classes, etc.
109 // Use like:
110 // class ALIGNAS(16) MyClass { ... }
111 // ALIGNAS(16) int array[4];
112 #if defined(COMPILER_MSVC)
113 #define ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
114 #elif defined(COMPILER_GCC)
115 #define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
116 #endif
117
118 // Return the byte alignment of the given type (available at compile time).
119 // Use like:
120 // ALIGNOF(int32) // this would be 4
121 #if defined(COMPILER_MSVC)
122 #define ALIGNOF(type) __alignof(type)
123 #elif defined(COMPILER_GCC)
124 #define ALIGNOF(type) __alignof__(type)
125 #endif
126
108 // Annotate a virtual method indicating it must be overriding a virtual 127 // Annotate a virtual method indicating it must be overriding a virtual
109 // method in the parent class. 128 // method in the parent class.
110 // Use like: 129 // Use like:
111 // virtual void foo() OVERRIDE; 130 // virtual void foo() OVERRIDE;
112 #if defined(COMPILER_MSVC) 131 #if defined(COMPILER_MSVC)
113 #define OVERRIDE override 132 #define OVERRIDE override
114 #elif defined(__clang__) 133 #elif defined(__clang__)
115 #define OVERRIDE override 134 #define OVERRIDE override
116 #else 135 #else
117 #define OVERRIDE 136 #define OVERRIDE
(...skipping 22 matching lines...) Expand all
140 #endif 159 #endif
141 160
142 // WPRINTF_FORMAT is the same, but for wide format strings. 161 // WPRINTF_FORMAT is the same, but for wide format strings.
143 // This doesn't appear to yet be implemented in any compiler. 162 // This doesn't appear to yet be implemented in any compiler.
144 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 . 163 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 .
145 #define WPRINTF_FORMAT(format_param, dots_param) 164 #define WPRINTF_FORMAT(format_param, dots_param)
146 // If available, it would look like: 165 // If available, it would look like:
147 // __attribute__((format(wprintf, format_param, dots_param))) 166 // __attribute__((format(wprintf, format_param, dots_param)))
148 167
149 #endif // BASE_COMPILER_SPECIFIC_H_ 168 #endif // BASE_COMPILER_SPECIFIC_H_
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/lazy_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698