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

Unified Diff: src/conversions-inl.h

Issue 996004: Take ARM big-endian floating point numbers into account in FastD2UI. (Closed)
Patch Set: Created 10 years, 9 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: src/conversions-inl.h
diff --git a/src/conversions-inl.h b/src/conversions-inl.h
index f7210d5af9c47f7b7d3d650bc6ce7fd54546a776..7753c76150dd8bf59d0660b5b54b9ece41285f8c 100644
--- a/src/conversions-inl.h
+++ b/src/conversions-inl.h
@@ -60,7 +60,8 @@ static inline int FastD2I(double x) {
// The fast double-to-unsigned-int conversion routine does not guarantee
-// rounding towards zero.
+// rounding towards zero, or any reasonable value if the argument is larger
+// than what fits in an unsigned 32-bit integer.
static inline unsigned int FastD2UI(double x) {
// There is no unsigned version of lrint, so there is no fast path
// in this function as there is in FastD2I. Using lrint doesn't work
@@ -77,7 +78,13 @@ static inline unsigned int FastD2UI(double x) {
if (x < k2Pow52) {
x += k2Pow52;
uint32_t result;
- memcpy(&result, &x, sizeof(result)); // Copy low 32 bits.
+ Address mantissa_ptr;
+#ifdef BIG_ENDIAN_FLOATING_POINT
+ mantissa_ptr = reinterpret_cast<Address>(&x) + kIntSize;
+#else
+ mantissa_ptr = reinterpret_cast<Address>(&x);
+#endif
+ memcpy(&result, mantissa_ptr, sizeof(result)); // Copy low 32 bits.
Erik Corry 2010/03/16 12:12:15 Comment is out of date!
return negative ? ~result + 1 : result;
}
// Large number (outside uint32 range), Infinity or NaN.
« 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