From: Mike Hommey <mh@glandium.org>
Date: Fri, 5 Feb 2010 20:31:42 +0100
Subject: Fixes for misaligned accesses on arm and sparc in uconv

https://bugzilla.mozilla.org/show_bug.cgi?id=544512
---
 intl/uconv/ucvlatin/nsUCS2BEToUnicode.cpp |    4 ++++
 intl/uconv/ucvlatin/nsUTF32ToUnicode.cpp  |    4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/intl/uconv/ucvlatin/nsUCS2BEToUnicode.cpp b/intl/uconv/ucvlatin/nsUCS2BEToUnicode.cpp
index 02fcae5..9314c2b 100644
--- a/intl/uconv/ucvlatin/nsUCS2BEToUnicode.cpp
+++ b/intl/uconv/ucvlatin/nsUCS2BEToUnicode.cpp
@@ -112,7 +112,11 @@ UTF16ConvertToUnicode(PRUint8& aState, PRUint8& aOddByte,
     if (dest == destEnd)
       goto error;
 
+#if !defined(__sparc__) && !defined(__arm__)
     u = *(const PRUnichar*)src;
+#else
+    memcpy(&u, src, 2);
+#endif
     src += 2;
 
 have_codepoint:
diff --git a/intl/uconv/ucvlatin/nsUTF32ToUnicode.cpp b/intl/uconv/ucvlatin/nsUTF32ToUnicode.cpp
index a16cb5b..c1f97e7 100644
--- a/intl/uconv/ucvlatin/nsUTF32ToUnicode.cpp
+++ b/intl/uconv/ucvlatin/nsUTF32ToUnicode.cpp
@@ -46,7 +46,7 @@
 //----------------------------------------------------------------------
 // static functions and macro definition common to nsUTF32(BE|LE)ToUnicode
 
-#ifdef IS_BIG_ENDIAN
+#if defined(IS_BIG_ENDIAN) || defined(__arm__)
 #define LE_STRING_TO_UCS4(s)                                       \
         (PRUint8(*(s)) | (PRUint8(*((s) + 1)) << 8) |              \
          (PRUint8(*((s) + 2)) << 16) | (PRUint8(*((s) + 3)) << 24))
@@ -54,7 +54,7 @@
 #define LE_STRING_TO_UCS4(s) (*(PRUint32*) (s))
 #endif
 
-#ifdef IS_BIG_ENDIAN
+#if defined(IS_BIG_ENDIAN) && !defined(__sparc__)
 #define BE_STRING_TO_UCS4(s) (*(PRUint32*) (s))
 #else
 #define BE_STRING_TO_UCS4(s)                                       \
