| 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 <stddef.h> | 
 |    9 #include <stdint.h> | 
 |   10  | 
 |   11 #include <cstring> | 
 |   12  | 
 |   13 #include "src/base/build_config.h" | 
|    8 #include "src/base/compiler-specific.h" |   14 #include "src/base/compiler-specific.h" | 
|    9 #include "src/base/format-macros.h" |  | 
|   10 #include "src/base/logging.h" |   15 #include "src/base/logging.h" | 
|   11  |   16  | 
|   12  |   17  | 
|   13 // TODO(all) Replace all uses of this macro with C++'s offsetof. To do that, we |   18 // TODO(all) Replace all uses of this macro with C++'s offsetof. To do that, we | 
|   14 // have to make sure that only standard-layout types and simple field |   19 // have to make sure that only standard-layout types and simple field | 
|   15 // designators are used. |   20 // designators are used. | 
|   16 #define OFFSET_OF(type, field) \ |   21 #define OFFSET_OF(type, field) \ | 
|   17   (reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(16)->field)) - 16) |   22   (reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(16)->field)) - 16) | 
|   18  |   23  | 
|   19  |   24  | 
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  262 #define V8_PTR_PREFIX "l" |  267 #define V8_PTR_PREFIX "l" | 
|  263 #else |  268 #else | 
|  264 # define V8_PTR_PREFIX    "" |  269 # define V8_PTR_PREFIX    "" | 
|  265 #endif |  270 #endif | 
|  266 #endif |  271 #endif | 
|  267  |  272  | 
|  268 #define V8PRIxPTR V8_PTR_PREFIX "x" |  273 #define V8PRIxPTR V8_PTR_PREFIX "x" | 
|  269 #define V8PRIdPTR V8_PTR_PREFIX "d" |  274 #define V8PRIdPTR V8_PTR_PREFIX "d" | 
|  270 #define V8PRIuPTR V8_PTR_PREFIX "u" |  275 #define V8PRIuPTR V8_PTR_PREFIX "u" | 
|  271  |  276  | 
|  272 // ptrdiff_t is 't' according to the standard, but MSVC uses 'I'. |  | 
|  273 #if V8_CC_MSVC |  | 
|  274 #define V8PRIxPTRDIFF "Ix" |  | 
|  275 #define V8PRIdPTRDIFF "Id" |  | 
|  276 #define V8PRIuPTRDIFF "Iu" |  | 
|  277 #else |  | 
|  278 #define V8PRIxPTRDIFF "tx" |  | 
|  279 #define V8PRIdPTRDIFF "td" |  | 
|  280 #define V8PRIuPTRDIFF "tu" |  | 
|  281 #endif |  | 
|  282  |  | 
|  283 // Fix for Mac OS X defining uintptr_t as "unsigned long": |  277 // Fix for Mac OS X defining uintptr_t as "unsigned long": | 
|  284 #if V8_OS_MACOSX |  278 #if V8_OS_MACOSX | 
|  285 #undef V8PRIxPTR |  279 #undef V8PRIxPTR | 
|  286 #define V8PRIxPTR "lx" |  280 #define V8PRIxPTR "lx" | 
|  287 #undef V8PRIdPTR |  | 
|  288 #define V8PRIdPTR "ld" |  | 
|  289 #undef V8PRIuPTR |  281 #undef V8PRIuPTR | 
|  290 #define V8PRIuPTR "lxu" |  282 #define V8PRIuPTR "lxu" | 
|  291 #endif |  283 #endif | 
|  292  |  284  | 
 |  285 // GCC on S390 31-bit expands 'size_t' to 'long unsigned int' | 
 |  286 // instead of 'int', resulting in compilation errors with %d. | 
 |  287 // The printf format specifier needs to be %zd instead. | 
 |  288 #if V8_HOST_ARCH_S390 && !V8_HOST_ARCH_64_BIT | 
 |  289 #define V8_SIZET_PREFIX "z" | 
 |  290 #else | 
 |  291 #define V8_SIZET_PREFIX "" | 
 |  292 #endif | 
 |  293  | 
|  293 // The following macro works on both 32 and 64-bit platforms. |  294 // The following macro works on both 32 and 64-bit platforms. | 
|  294 // Usage: instead of writing 0x1234567890123456 |  295 // Usage: instead of writing 0x1234567890123456 | 
|  295 //      write V8_2PART_UINT64_C(0x12345678,90123456); |  296 //      write V8_2PART_UINT64_C(0x12345678,90123456); | 
|  296 #define V8_2PART_UINT64_C(a, b) (((static_cast<uint64_t>(a) << 32) + 0x##b##u)) |  297 #define V8_2PART_UINT64_C(a, b) (((static_cast<uint64_t>(a) << 32) + 0x##b##u)) | 
|  297  |  298  | 
|  298  |  299  | 
|  299 // Compute the 0-relative offset of some absolute value x of type T. |  300 // Compute the 0-relative offset of some absolute value x of type T. | 
|  300 // This allows conversion of Addresses and integral types into |  301 // This allows conversion of Addresses and integral types into | 
|  301 // 0-relative int offsets. |  302 // 0-relative int offsets. | 
|  302 template <typename T> |  303 template <typename T> | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  341  |  342  | 
|  342 template <> |  343 template <> | 
|  343 inline bool is_fundamental<uint8_t>() { |  344 inline bool is_fundamental<uint8_t>() { | 
|  344   return true; |  345   return true; | 
|  345 } |  346 } | 
|  346  |  347  | 
|  347 }  // namespace base |  348 }  // namespace base | 
|  348 }  // namespace v8 |  349 }  // namespace v8 | 
|  349  |  350  | 
|  350 #endif   // V8_BASE_MACROS_H_ |  351 #endif   // V8_BASE_MACROS_H_ | 
| OLD | NEW |