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

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

Issue 10869063: Add attributions so printf like functions can have their arguments checked. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebased Created 8 years, 3 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/platform/assert.h ('k') | runtime/platform/json.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 (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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 #define PRIdPTR DART_PRINTF_PTR_PREFIX "d" 123 #define PRIdPTR DART_PRINTF_PTR_PREFIX "d"
124 #endif 124 #endif
125 125
126 #if !defined(PRIxPTR) 126 #if !defined(PRIxPTR)
127 #define PRIxPTR DART_PRINTF_PTR_PREFIX "x" 127 #define PRIxPTR DART_PRINTF_PTR_PREFIX "x"
128 #endif 128 #endif
129 129
130 #endif // defined(TARGET_OS_WINDOWS) 130 #endif // defined(TARGET_OS_WINDOWS)
131 131
132 132
133 // Short form printf format specifiers
134 #define Pd PRIdPTR
135 #define Pu PRIuPTR
136 #define Px PRIxPTR
137 #define Pd64 PRId64
138 #define Pu64 PRIu64
139 #define Px64 PRIx64
140
141
133 // Suffixes for 64-bit integer literals. 142 // Suffixes for 64-bit integer literals.
134 #ifdef _MSC_VER 143 #ifdef _MSC_VER
135 #define DART_INT64_C(x) x##I64 144 #define DART_INT64_C(x) x##I64
136 #define DART_UINT64_C(x) x##UI64 145 #define DART_UINT64_C(x) x##UI64
137 #else 146 #else
138 #define DART_INT64_C(x) x##LL 147 #define DART_INT64_C(x) x##LL
139 #define DART_UINT64_C(x) x##ULL 148 #define DART_UINT64_C(x) x##ULL
140 #endif 149 #endif
141 150
142 151
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 // errors (type long int changed to int64_t and do/while split on 361 // errors (type long int changed to int64_t and do/while split on
353 // separate lines with body in {}s). 362 // separate lines with body in {}s).
354 # define TEMP_FAILURE_RETRY(expression) \ 363 # define TEMP_FAILURE_RETRY(expression) \
355 ({ int64_t __result; \ 364 ({ int64_t __result; \
356 do { \ 365 do { \
357 __result = (int64_t) (expression); \ 366 __result = (int64_t) (expression); \
358 } while (__result == -1L && errno == EINTR); \ 367 } while (__result == -1L && errno == EINTR); \
359 __result; }) 368 __result; })
360 #endif 369 #endif
361 370
371
372 #if defined(TARGET_OS_LINUX) || defined(TARGET_OS_MACOS)
373 //
374 // Tell the compiler to do printf format string checking if the
375 // compiler supports it; see the 'format' attribute in
376 // <http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html>.
377 //
378 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods
379 // have an implicit 'this' argument, the arguments of such methods
380 // should be counted from two, not one."
381 //
382 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \
383 __attribute__((__format__(__printf__, string_index, first_to_check)))
384 #else
385 #define PRINTF_ATTRIBUTE(string_index, first_to_check)
386 #endif
387
362 #endif // PLATFORM_GLOBALS_H_ 388 #endif // PLATFORM_GLOBALS_H_
OLDNEW
« no previous file with comments | « runtime/platform/assert.h ('k') | runtime/platform/json.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698