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

Side by Side Diff: base/compiler_specific.h

Issue 2670873002: Remove base's ALIGNOF/ALIGNAS in favor of alignof/alignas. (Closed)
Patch Set: rebase Created 3 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
« no previous file with comments | « no previous file | base/containers/stack_container.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 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 #endif 101 #endif
102 102
103 #if COMPILER_GCC && defined(NDEBUG) 103 #if COMPILER_GCC && defined(NDEBUG)
104 #define ALWAYS_INLINE inline __attribute__((__always_inline__)) 104 #define ALWAYS_INLINE inline __attribute__((__always_inline__))
105 #elif COMPILER_MSVC && defined(NDEBUG) 105 #elif COMPILER_MSVC && defined(NDEBUG)
106 #define ALWAYS_INLINE __forceinline 106 #define ALWAYS_INLINE __forceinline
107 #else 107 #else
108 #define ALWAYS_INLINE inline 108 #define ALWAYS_INLINE inline
109 #endif 109 #endif
110 110
111 // Specify memory alignment for structs, classes, etc.
112 // Use like:
113 // class ALIGNAS(16) MyClass { ... }
114 // ALIGNAS(16) int array[4];
115 #if defined(COMPILER_MSVC)
116 #define ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
117 #elif defined(COMPILER_GCC)
118 #define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
119 #endif
120
121 // Return the byte alignment of the given type (available at compile time).
122 // Use like:
123 // ALIGNOF(int32_t) // this would be 4
124 #if defined(COMPILER_MSVC)
125 #define ALIGNOF(type) __alignof(type)
126 #elif defined(COMPILER_GCC)
127 #define ALIGNOF(type) __alignof__(type)
128 #endif
129
130 // Annotate a function indicating the caller must examine the return value. 111 // Annotate a function indicating the caller must examine the return value.
131 // Use like: 112 // Use like:
132 // int foo() WARN_UNUSED_RESULT; 113 // int foo() WARN_UNUSED_RESULT;
133 // To explicitly ignore a result, see |ignore_result()| in base/macros.h. 114 // To explicitly ignore a result, see |ignore_result()| in base/macros.h.
134 #undef WARN_UNUSED_RESULT 115 #undef WARN_UNUSED_RESULT
135 #if defined(COMPILER_GCC) || defined(__clang__) 116 #if defined(COMPILER_GCC) || defined(__clang__)
136 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) 117 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
137 #else 118 #else
138 #define WARN_UNUSED_RESULT 119 #define WARN_UNUSED_RESULT
139 #endif 120 #endif
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 205
225 // Compiler feature-detection. 206 // Compiler feature-detection.
226 // clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension 207 // clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension
227 #if defined(__has_feature) 208 #if defined(__has_feature)
228 #define HAS_FEATURE(FEATURE) __has_feature(FEATURE) 209 #define HAS_FEATURE(FEATURE) __has_feature(FEATURE)
229 #else 210 #else
230 #define HAS_FEATURE(FEATURE) 0 211 #define HAS_FEATURE(FEATURE) 0
231 #endif 212 #endif
232 213
233 #endif // BASE_COMPILER_SPECIFIC_H_ 214 #endif // BASE_COMPILER_SPECIFIC_H_
OLDNEW
« no previous file with comments | « no previous file | base/containers/stack_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698