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

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

Issue 23578046: Replace the memcpy macro with a lint check. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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/bin/process_win.cc ('k') | runtime/vm/os_win.cc » ('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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 inline D bit_copy(const S& source) { 410 inline D bit_copy(const S& source) {
411 D destination; 411 D destination;
412 // This use of memcpy is safe: source and destination cannot overlap. 412 // This use of memcpy is safe: source and destination cannot overlap.
413 memcpy(&destination, 413 memcpy(&destination,
414 reinterpret_cast<const void*>(&source), 414 reinterpret_cast<const void*>(&source),
415 sizeof(destination)); 415 sizeof(destination));
416 return destination; 416 return destination;
417 } 417 }
418 418
419 419
420 // A macro to ensure that memcpy cannot be called. memcpy does not handle
421 // overlapping memory regions. Even though this is well documented it seems
422 // to be used in error quite often. To avoid problems we disallow the direct
423 // use of memcpy here.
424 //
425 // On Android and Windows the basic libraries use memcpy and therefore
426 // compilation will fail if memcpy is overwritten even if user code does not
427 // use memcpy.
428 #if defined(memcpy)
429 #undef memcpy
430 #endif
431 #if !( defined(TARGET_OS_ANDROID) || defined(TARGET_OS_WINDOWS) )
432 #define memcpy "Please use memmove instead of memcpy."
433 #endif
434
435
436 // On Windows the reentrent version of strtok is called 420 // On Windows the reentrent version of strtok is called
437 // strtok_s. Unify on the posix name strtok_r. 421 // strtok_s. Unify on the posix name strtok_r.
438 #if defined(TARGET_OS_WINDOWS) 422 #if defined(TARGET_OS_WINDOWS)
439 #define snprintf _snprintf 423 #define snprintf _snprintf
440 #define strtok_r strtok_s 424 #define strtok_r strtok_s
441 #endif 425 #endif
442 426
443 #if !defined(TARGET_OS_WINDOWS) 427 #if !defined(TARGET_OS_WINDOWS)
444 #if !defined(TEMP_FAILURE_RETRY) 428 #if !defined(TEMP_FAILURE_RETRY)
445 // TEMP_FAILURE_RETRY is defined in unistd.h on some platforms. The 429 // TEMP_FAILURE_RETRY is defined in unistd.h on some platforms. The
(...skipping 23 matching lines...) Expand all
469 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods 453 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods
470 // have an implicit 'this' argument, the arguments of such methods 454 // have an implicit 'this' argument, the arguments of such methods
471 // should be counted from two, not one." 455 // should be counted from two, not one."
472 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \ 456 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \
473 __attribute__((__format__(__printf__, string_index, first_to_check))) 457 __attribute__((__format__(__printf__, string_index, first_to_check)))
474 #else 458 #else
475 #define PRINTF_ATTRIBUTE(string_index, first_to_check) 459 #define PRINTF_ATTRIBUTE(string_index, first_to_check)
476 #endif 460 #endif
477 461
478 #endif // PLATFORM_GLOBALS_H_ 462 #endif // PLATFORM_GLOBALS_H_
OLDNEW
« no previous file with comments | « runtime/bin/process_win.cc ('k') | runtime/vm/os_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698