Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PLATFORM_GLOBALS_H_ | 5 #ifndef PLATFORM_GLOBALS_H_ |
| 6 #define PLATFORM_GLOBALS_H_ | 6 #define PLATFORM_GLOBALS_H_ |
| 7 | 7 |
| 8 // __STDC_FORMAT_MACROS has to be defined before including <inttypes.h> to | 8 // __STDC_FORMAT_MACROS has to be defined before including <inttypes.h> to |
| 9 // enable platform independent printf format specifiers. | 9 // enable platform independent printf format specifiers. |
| 10 #ifndef __STDC_FORMAT_MACROS | 10 #ifndef __STDC_FORMAT_MACROS |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 const uint32_t kMaxUint32 = 0xFFFFFFFF; | 248 const uint32_t kMaxUint32 = 0xFFFFFFFF; |
| 249 const int64_t kMinInt64 = DART_INT64_C(0x8000000000000000); | 249 const int64_t kMinInt64 = DART_INT64_C(0x8000000000000000); |
| 250 const int64_t kMaxInt64 = DART_INT64_C(0x7FFFFFFFFFFFFFFF); | 250 const int64_t kMaxInt64 = DART_INT64_C(0x7FFFFFFFFFFFFFFF); |
| 251 const uint64_t kMaxUint64 = DART_2PART_UINT64_C(0xFFFFFFFF, FFFFFFFF); | 251 const uint64_t kMaxUint64 = DART_2PART_UINT64_C(0xFFFFFFFF, FFFFFFFF); |
| 252 | 252 |
| 253 // Types for native machine words. Guaranteed to be able to hold pointers and | 253 // Types for native machine words. Guaranteed to be able to hold pointers and |
| 254 // integers. | 254 // integers. |
| 255 typedef intptr_t word; | 255 typedef intptr_t word; |
| 256 typedef uintptr_t uword; | 256 typedef uintptr_t uword; |
| 257 | 257 |
| 258 #if defined(TARGET_OS_WINDOWS) || defined(TARGET_OS_MACOS) | |
| 259 // off64_t is not defined on Windows or Mac OS. | |
| 260 typedef int64_t off64_t; | |
| 261 #endif | |
| 262 | |
| 263 // Byte sizes. | 258 // Byte sizes. |
| 264 const int kWordSize = sizeof(word); | 259 const int kWordSize = sizeof(word); |
| 265 const int kDoubleSize = sizeof(double); // NOLINT | 260 const int kDoubleSize = sizeof(double); // NOLINT |
| 266 const int kFloatSize = sizeof(float); // NOLINT | 261 const int kFloatSize = sizeof(float); // NOLINT |
| 267 const int kSimd128Size = sizeof(simd128_value_t); // NOLINT | 262 const int kSimd128Size = sizeof(simd128_value_t); // NOLINT |
| 268 #ifdef ARCH_IS_32_BIT | 263 #ifdef ARCH_IS_32_BIT |
| 269 const int kWordSizeLog2 = 2; | 264 const int kWordSizeLog2 = 2; |
| 270 const uword kUwordMax = kMaxUint32; | 265 const uword kUwordMax = kMaxUint32; |
| 271 #else | 266 #else |
| 272 const int kWordSizeLog2 = 3; | 267 const int kWordSizeLog2 = 3; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 // strtok_s. Unify on the posix name strtok_r. | 457 // strtok_s. Unify on the posix name strtok_r. |
| 463 #if defined(TARGET_OS_WINDOWS) | 458 #if defined(TARGET_OS_WINDOWS) |
| 464 #define snprintf _snprintf | 459 #define snprintf _snprintf |
| 465 #define strtok_r strtok_s | 460 #define strtok_r strtok_s |
| 466 #endif | 461 #endif |
| 467 | 462 |
| 468 #if !defined(TARGET_OS_WINDOWS) | 463 #if !defined(TARGET_OS_WINDOWS) |
| 469 #if !defined(TEMP_FAILURE_RETRY) | 464 #if !defined(TEMP_FAILURE_RETRY) |
| 470 // TEMP_FAILURE_RETRY is defined in unistd.h on some platforms. The | 465 // TEMP_FAILURE_RETRY is defined in unistd.h on some platforms. The |
| 471 // definition below is copied from Linux and adapted to avoid lint | 466 // definition below is copied from Linux and adapted to avoid lint |
| 472 // errors (type long int changed to int64_t and do/while split on | 467 // errors (type long int changed to intptr_t and do/while split on |
| 473 // separate lines with body in {}s). | 468 // separate lines with body in {}s). |
| 474 #define TEMP_FAILURE_RETRY(expression) \ | 469 #define TEMP_FAILURE_RETRY(expression) \ |
| 475 ({ int64_t __result; \ | 470 ({ intptr_t __result; \ |
| 476 do { \ | 471 do { \ |
| 477 __result = static_cast<int64_t>(expression); \ | 472 __result = static_cast<intptr_t>(expression); \ |
|
siva
2014/01/16 00:15:59
We probably should not have a static cast here to
Ivan Posva
2014/01/16 05:05:41
You are absolutely right. I did review the current
| |
| 478 } while (__result == -1L && errno == EINTR); \ | 473 } while (__result == -1L && errno == EINTR); \ |
| 479 __result; }) | 474 __result; }) |
| 480 #endif // !defined(TEMP_FAILURE_RETRY) | 475 #endif // !defined(TEMP_FAILURE_RETRY) |
| 481 | 476 |
| 482 // This is a version of TEMP_FAILURE_RETRY which does not use the value | 477 // This is a version of TEMP_FAILURE_RETRY which does not use the value |
| 483 // returned from the expression. | 478 // returned from the expression. |
| 484 #define VOID_TEMP_FAILURE_RETRY(expression) \ | 479 #define VOID_TEMP_FAILURE_RETRY(expression) \ |
| 485 (static_cast<void>(TEMP_FAILURE_RETRY(expression))) | 480 (static_cast<void>(TEMP_FAILURE_RETRY(expression))) |
| 486 | 481 |
| 487 #endif // !defined(TARGET_OS_WINDOWS) | 482 #endif // !defined(TARGET_OS_WINDOWS) |
| 488 | 483 |
| 489 #if defined(TARGET_OS_LINUX) || defined(TARGET_OS_MACOS) | 484 #if defined(TARGET_OS_LINUX) || defined(TARGET_OS_MACOS) |
| 490 // Tell the compiler to do printf format string checking if the | 485 // Tell the compiler to do printf format string checking if the |
| 491 // compiler supports it; see the 'format' attribute in | 486 // compiler supports it; see the 'format' attribute in |
| 492 // <http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html>. | 487 // <http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html>. |
| 493 // | 488 // |
| 494 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods | 489 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods |
| 495 // have an implicit 'this' argument, the arguments of such methods | 490 // have an implicit 'this' argument, the arguments of such methods |
| 496 // should be counted from two, not one." | 491 // should be counted from two, not one." |
| 497 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \ | 492 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \ |
| 498 __attribute__((__format__(__printf__, string_index, first_to_check))) | 493 __attribute__((__format__(__printf__, string_index, first_to_check))) |
| 499 #else | 494 #else |
| 500 #define PRINTF_ATTRIBUTE(string_index, first_to_check) | 495 #define PRINTF_ATTRIBUTE(string_index, first_to_check) |
| 501 #endif | 496 #endif |
| 502 | 497 |
| 503 #endif // PLATFORM_GLOBALS_H_ | 498 #endif // PLATFORM_GLOBALS_H_ |
| OLD | NEW |