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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 | 467 |
468 | 468 |
469 // On Windows the reentrent version of strtok is called | 469 // On Windows the reentrent version of strtok is called |
470 // strtok_s. Unify on the posix name strtok_r. | 470 // strtok_s. Unify on the posix name strtok_r. |
471 #if defined(TARGET_OS_WINDOWS) | 471 #if defined(TARGET_OS_WINDOWS) |
472 #define snprintf _snprintf | 472 #define snprintf _snprintf |
473 #define strtok_r strtok_s | 473 #define strtok_r strtok_s |
474 #endif | 474 #endif |
475 | 475 |
476 #if !defined(TARGET_OS_WINDOWS) | 476 #if !defined(TARGET_OS_WINDOWS) |
477 #if !defined(TEMP_FAILURE_RETRY) | 477 #if defined(TEMP_FAILURE_RETRY) |
478 // TEMP_FAILURE_RETRY is defined in unistd.h on some platforms. The | 478 // TEMP_FAILURE_RETRY is defined in unistd.h on some platforms. We should |
479 // definition below is copied from Linux and adapted to avoid lint | 479 // not use that version, but instead the one in signal_blocker.h, to ensure |
480 // errors (type long int changed to intptr_t and do/while split on | 480 // we disable signal interrupts. |
481 // separate lines with body in {}s). | 481 #undef TEMP_FAILURE_RETRY |
482 #define TEMP_FAILURE_RETRY(expression) \ | 482 #endif // defined(TEMP_FAILURE_RETRY) |
483 ({ intptr_t __result; \ | |
484 do { \ | |
485 __result = (expression); \ | |
486 } while ((__result == -1L) && (errno == EINTR)); \ | |
487 __result; }) | |
488 #endif // !defined(TEMP_FAILURE_RETRY) | |
489 | |
490 // This is a version of TEMP_FAILURE_RETRY which does not use the value | |
491 // returned from the expression. | |
492 #define VOID_TEMP_FAILURE_RETRY(expression) \ | |
493 (static_cast<void>(TEMP_FAILURE_RETRY(expression))) | |
494 | |
495 #endif // !defined(TARGET_OS_WINDOWS) | 483 #endif // !defined(TARGET_OS_WINDOWS) |
496 | 484 |
497 #if defined(TARGET_OS_LINUX) || defined(TARGET_OS_MACOS) | 485 #if defined(TARGET_OS_LINUX) || defined(TARGET_OS_MACOS) |
498 // Tell the compiler to do printf format string checking if the | 486 // Tell the compiler to do printf format string checking if the |
499 // compiler supports it; see the 'format' attribute in | 487 // compiler supports it; see the 'format' attribute in |
500 // <http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html>. | 488 // <http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html>. |
501 // | 489 // |
502 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods | 490 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods |
503 // have an implicit 'this' argument, the arguments of such methods | 491 // have an implicit 'this' argument, the arguments of such methods |
504 // should be counted from two, not one." | 492 // should be counted from two, not one." |
505 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \ | 493 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \ |
506 __attribute__((__format__(__printf__, string_index, first_to_check))) | 494 __attribute__((__format__(__printf__, string_index, first_to_check))) |
507 #else | 495 #else |
508 #define PRINTF_ATTRIBUTE(string_index, first_to_check) | 496 #define PRINTF_ATTRIBUTE(string_index, first_to_check) |
509 #endif | 497 #endif |
510 | 498 |
511 #endif // PLATFORM_GLOBALS_H_ | 499 #endif // PLATFORM_GLOBALS_H_ |
OLD | NEW |