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

Side by Side Diff: src/base/macros.h

Issue 1869433004: Fix printf formats (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address review comments. Created 4 years, 8 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 | « src/base/logging.h ('k') | src/base/platform/platform.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 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"
14 #include "src/base/compiler-specific.h" 8 #include "src/base/compiler-specific.h"
9 #include "src/base/format-macros.h"
15 #include "src/base/logging.h" 10 #include "src/base/logging.h"
16 11
17 12
18 // TODO(all) Replace all uses of this macro with C++'s offsetof. To do that, we 13 // TODO(all) Replace all uses of this macro with C++'s offsetof. To do that, we
19 // have to make sure that only standard-layout types and simple field 14 // have to make sure that only standard-layout types and simple field
20 // designators are used. 15 // designators are used.
21 #define OFFSET_OF(type, field) \ 16 #define OFFSET_OF(type, field) \
22 (reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(16)->field)) - 16) 17 (reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(16)->field)) - 16)
23 18
24 19
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 #endif 266 #endif
272 267
273 #define V8PRIxPTR V8_PTR_PREFIX "x" 268 #define V8PRIxPTR V8_PTR_PREFIX "x"
274 #define V8PRIdPTR V8_PTR_PREFIX "d" 269 #define V8PRIdPTR V8_PTR_PREFIX "d"
275 #define V8PRIuPTR V8_PTR_PREFIX "u" 270 #define V8PRIuPTR V8_PTR_PREFIX "u"
276 271
277 // Fix for Mac OS X defining uintptr_t as "unsigned long": 272 // Fix for Mac OS X defining uintptr_t as "unsigned long":
278 #if V8_OS_MACOSX 273 #if V8_OS_MACOSX
279 #undef V8PRIxPTR 274 #undef V8PRIxPTR
280 #define V8PRIxPTR "lx" 275 #define V8PRIxPTR "lx"
276 #undef V8PRIdPTR
277 #define V8PRIdPTR "ld"
281 #undef V8PRIuPTR 278 #undef V8PRIuPTR
282 #define V8PRIuPTR "lxu" 279 #define V8PRIuPTR "lxu"
283 #endif 280 #endif
284 281
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
294 // The following macro works on both 32 and 64-bit platforms. 282 // The following macro works on both 32 and 64-bit platforms.
295 // Usage: instead of writing 0x1234567890123456 283 // Usage: instead of writing 0x1234567890123456
296 // write V8_2PART_UINT64_C(0x12345678,90123456); 284 // write V8_2PART_UINT64_C(0x12345678,90123456);
297 #define V8_2PART_UINT64_C(a, b) (((static_cast<uint64_t>(a) << 32) + 0x##b##u)) 285 #define V8_2PART_UINT64_C(a, b) (((static_cast<uint64_t>(a) << 32) + 0x##b##u))
298 286
299 287
300 // Compute the 0-relative offset of some absolute value x of type T. 288 // Compute the 0-relative offset of some absolute value x of type T.
301 // This allows conversion of Addresses and integral types into 289 // This allows conversion of Addresses and integral types into
302 // 0-relative int offsets. 290 // 0-relative int offsets.
303 template <typename T> 291 template <typename T>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 330
343 template <> 331 template <>
344 inline bool is_fundamental<uint8_t>() { 332 inline bool is_fundamental<uint8_t>() {
345 return true; 333 return true;
346 } 334 }
347 335
348 } // namespace base 336 } // namespace base
349 } // namespace v8 337 } // namespace v8
350 338
351 #endif // V8_BASE_MACROS_H_ 339 #endif // V8_BASE_MACROS_H_
OLDNEW
« no previous file with comments | « src/base/logging.h ('k') | src/base/platform/platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698