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

Unified Diff: runtime/platform/globals.h

Issue 2953653002: [arm, arm64] Convince the Android toolchain not to bypass memcpy in Read/StoreUnaligned. (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/globals.h
diff --git a/runtime/platform/globals.h b/runtime/platform/globals.h
index 30491f2e9626cb958efa79ba29086509fb4aba60..b0c031d8399d66d42c5554982ceef74fb56a4c78 100644
--- a/runtime/platform/globals.h
+++ b/runtime/platform/globals.h
@@ -669,7 +669,8 @@ inline D bit_copy(const S& source) {
template <typename T>
static inline T ReadUnaligned(const T* ptr) {
T value;
- memcpy(&value, ptr, sizeof(value));
+ memcpy(reinterpret_cast<void*>(&value), reinterpret_cast<const void*>(ptr),
+ sizeof(value));
return value;
}
@@ -677,7 +678,8 @@ static inline T ReadUnaligned(const T* ptr) {
// Similar to bit_copy and bit_cast, but does take the type from the argument.
template <typename T>
static inline void StoreUnaligned(T* ptr, T value) {
- memcpy(ptr, &value, sizeof(value));
+ memcpy(reinterpret_cast<void*>(ptr), reinterpret_cast<const void*>(&value),
+ sizeof(value));
}
#else // !(HOST_ARCH_ARM || HOST_ARCH_MIPS || HOST_ARCH_ARM64)
// Similar to bit_copy and bit_cast, but does take the type from the argument.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698