OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project 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 V8_BASE_MACROS_H_ | 5 #ifndef V8_BASE_MACROS_H_ |
6 #define V8_BASE_MACROS_H_ | 6 #define V8_BASE_MACROS_H_ |
7 | 7 |
8 #include "src/base/compiler-specific.h" | 8 #include "src/base/compiler-specific.h" |
9 #include "src/base/format-macros.h" | 9 #include "src/base/format-macros.h" |
10 #include "src/base/logging.h" | 10 #include "src/base/logging.h" |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 return AddressFrom<T>(OffsetFrom(x) & -m); | 275 return AddressFrom<T>(OffsetFrom(x) & -m); |
276 } | 276 } |
277 | 277 |
278 | 278 |
279 // Return the smallest multiple of m which is >= x. | 279 // Return the smallest multiple of m which is >= x. |
280 template <typename T> | 280 template <typename T> |
281 inline T RoundUp(T x, intptr_t m) { | 281 inline T RoundUp(T x, intptr_t m) { |
282 return RoundDown<T>(static_cast<T>(x + m - 1), m); | 282 return RoundDown<T>(static_cast<T>(x + m - 1), m); |
283 } | 283 } |
284 | 284 |
285 | |
286 namespace v8 { | |
287 namespace base { | |
288 | |
289 // TODO(yangguo): This is a poor man's replacement for std::is_fundamental, | |
290 // which requires C++11. Switch to std::is_fundamental once possible. | |
291 template <typename T> | |
292 inline bool is_fundamental() { | |
293 return false; | |
294 } | |
295 | |
296 template <> | |
297 inline bool is_fundamental<uint8_t>() { | |
298 return true; | |
299 } | |
300 | |
301 } // namespace base | |
302 } // namespace v8 | |
303 | |
304 #endif // V8_BASE_MACROS_H_ | 285 #endif // V8_BASE_MACROS_H_ |
OLD | NEW |