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

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

Issue 417093005: - Make sure to be able to deal with unaligned snapshot buffers (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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 | « no previous file | runtime/vm/globals.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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 inline D bit_copy(const S& source) { 470 inline D bit_copy(const S& source) {
471 D destination; 471 D destination;
472 // This use of memcpy is safe: source and destination cannot overlap. 472 // This use of memcpy is safe: source and destination cannot overlap.
473 memcpy(&destination, 473 memcpy(&destination,
474 reinterpret_cast<const void*>(&source), 474 reinterpret_cast<const void*>(&source),
475 sizeof(destination)); 475 sizeof(destination));
476 return destination; 476 return destination;
477 } 477 }
478 478
479 479
480 // Similar to bit_copy and bit_cast, but does take the type from the argument.
481 template <typename T>
482 static inline T ReadUnaligned(const T* ptr) {
483 T value;
484 memcpy(&value, ptr, sizeof(value));
485 return value;
486 }
487
488
480 // On Windows the reentrent version of strtok is called 489 // On Windows the reentrent version of strtok is called
481 // strtok_s. Unify on the posix name strtok_r. 490 // strtok_s. Unify on the posix name strtok_r.
482 #if defined(TARGET_OS_WINDOWS) 491 #if defined(TARGET_OS_WINDOWS)
483 #define snprintf _snprintf 492 #define snprintf _snprintf
484 #define strtok_r strtok_s 493 #define strtok_r strtok_s
485 #endif 494 #endif
486 495
487 #if !defined(TARGET_OS_WINDOWS) 496 #if !defined(TARGET_OS_WINDOWS)
488 #if defined(TEMP_FAILURE_RETRY) 497 #if defined(TEMP_FAILURE_RETRY)
489 // TEMP_FAILURE_RETRY is defined in unistd.h on some platforms. We should 498 // TEMP_FAILURE_RETRY is defined in unistd.h on some platforms. We should
(...skipping 11 matching lines...) Expand all
501 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods 510 // N.B.: As the GCC manual states, "[s]ince non-static C++ methods
502 // have an implicit 'this' argument, the arguments of such methods 511 // have an implicit 'this' argument, the arguments of such methods
503 // should be counted from two, not one." 512 // should be counted from two, not one."
504 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \ 513 #define PRINTF_ATTRIBUTE(string_index, first_to_check) \
505 __attribute__((__format__(__printf__, string_index, first_to_check))) 514 __attribute__((__format__(__printf__, string_index, first_to_check)))
506 #else 515 #else
507 #define PRINTF_ATTRIBUTE(string_index, first_to_check) 516 #define PRINTF_ATTRIBUTE(string_index, first_to_check)
508 #endif 517 #endif
509 518
510 #endif // PLATFORM_GLOBALS_H_ 519 #endif // PLATFORM_GLOBALS_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698