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

Side by Side Diff: runtime/platform/globals.h

Issue 12178025: - Avoid warnings when the result of TEMP_FAILURE_RETRY is unused. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/socket_macos.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #if !defined(_WIN32) 54 #if !defined(_WIN32)
55 #include "platform/floating_point.h" 55 #include "platform/floating_point.h"
56 #endif 56 #endif
57 57
58 58
59 // Target OS detection. 59 // Target OS detection.
60 // for more information on predefined macros: 60 // for more information on predefined macros:
61 // - http://msdn.microsoft.com/en-us/library/b0084kay.aspx 61 // - http://msdn.microsoft.com/en-us/library/b0084kay.aspx
62 // - with gcc, run: "echo | gcc -E -dM -" 62 // - with gcc, run: "echo | gcc -E -dM -"
63 #if defined(__ANDROID__) 63 #if defined(__ANDROID__)
64 #define TARGET_OS_ANDROID 64 #define TARGET_OS_ANDROID 1
65 #elif defined(__linux__) || defined(__FreeBSD__) 65 #elif defined(__linux__) || defined(__FreeBSD__)
66 #define TARGET_OS_LINUX 1 66 #define TARGET_OS_LINUX 1
67 #elif defined(__APPLE__) 67 #elif defined(__APPLE__)
68 #define TARGET_OS_MACOS 1 68 #define TARGET_OS_MACOS 1
69 #elif defined(_WIN32) 69 #elif defined(_WIN32)
70 #define TARGET_OS_WINDOWS 1 70 #define TARGET_OS_WINDOWS 1
71 #else 71 #else
72 #error Automatic target os detection failed. 72 #error Automatic target os detection failed.
73 #endif 73 #endif
74 74
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 #endif 384 #endif
385 385
386 386
387 // On Windows the reentrent version of strtok is called 387 // On Windows the reentrent version of strtok is called
388 // strtok_s. Unify on the posix name strtok_r. 388 // strtok_s. Unify on the posix name strtok_r.
389 #if defined(TARGET_OS_WINDOWS) 389 #if defined(TARGET_OS_WINDOWS)
390 #define snprintf _snprintf 390 #define snprintf _snprintf
391 #define strtok_r strtok_s 391 #define strtok_r strtok_s
392 #endif 392 #endif
393 393
394 #if !defined(TARGET_OS_WINDOWS) && !defined(TEMP_FAILURE_RETRY) 394 #if !defined(TARGET_OS_WINDOWS)
395 #if !defined(TEMP_FAILURE_RETRY)
395 // TEMP_FAILURE_RETRY is defined in unistd.h on some platforms. The 396 // TEMP_FAILURE_RETRY is defined in unistd.h on some platforms. The
396 // definition below is copied from Linux and adapted to avoid lint 397 // definition below is copied from Linux and adapted to avoid lint
397 // errors (type long int changed to int64_t and do/while split on 398 // errors (type long int changed to int64_t and do/while split on
398 // separate lines with body in {}s). 399 // separate lines with body in {}s).
399 # define TEMP_FAILURE_RETRY(expression) \ 400 #define TEMP_FAILURE_RETRY(expression) \
400 ({ int64_t __result; \ 401 ({ int64_t __result; \
401 do { \ 402 do { \
402 __result = (int64_t) (expression); \ 403 __result = static_cast<int64_t>(expression); \
403 } while (__result == -1L && errno == EINTR); \ 404 } while (__result == -1L && errno == EINTR); \
404 __result; }) 405 __result; })
405 #endif 406 #endif // !defined(TEMP_FAILURE_RETRY)
406 407
408 // This is a version of TEMP_FAILURE_RETRY which does not use the value
409 // returned from the expression.
410 #define VOID_TEMP_FAILURE_RETRY(expression) \
411 (static_cast<void>(TEMP_FAILURE_RETRY(expression)))
412
413 #endif // !defined(TARGET_OS_WINDOWS)
407 414
408 #if defined(TARGET_OS_LINUX) || defined(TARGET_OS_MACOS) 415 #if defined(TARGET_OS_LINUX) || defined(TARGET_OS_MACOS)
409 //
410 // Tell the compiler to do printf format string checking if the 416 // Tell the compiler to do printf format string checking if the
411 // compiler supports it; see the 'format' attribute in 417 // compiler supports it; see the 'format' attribute in
412 // <http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html>. 418 // <http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html>.
413 // 419 //
414 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods 420 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods
415 // have an implicit 'this' argument, the arguments of such methods 421 // have an implicit 'this' argument, the arguments of such methods
416 // should be counted from two, not one." 422 // should be counted from two, not one."
417 //
418 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \ 423 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \
419 __attribute__((__format__(__printf__, string_index, first_to_check))) 424 __attribute__((__format__(__printf__, string_index, first_to_check)))
420 #else 425 #else
421 #define PRINTF_ATTRIBUTE(string_index, first_to_check) 426 #define PRINTF_ATTRIBUTE(string_index, first_to_check)
422 #endif 427 #endif
423 428
424 #endif // PLATFORM_GLOBALS_H_ 429 #endif // PLATFORM_GLOBALS_H_
OLDNEW
« no previous file with comments | « runtime/bin/socket_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698