File 05_sparc_unaligned_access.diff of Package qtwebkit

Description: fix some alignment problems on sparc.
Author: Mike Hommey <glandium@debian.org>

--- a/JavaScriptCore/wtf/FastMalloc.cpp
+++ b/JavaScriptCore/wtf/FastMalloc.cpp
@@ -2336,13 +2336,13 @@ static TCMalloc_Central_FreeListPadded c
 
 // Page-level allocator
 static SpinLock pageheap_lock = SPINLOCK_INITIALIZER;
-static void* pageheap_memory[(sizeof(TCMalloc_PageHeap) + sizeof(void*) - 1) / sizeof(void*)];
+static uint64_t pageheap_memory[(sizeof(TCMalloc_PageHeap) + sizeof(uint64_t) - 1) / sizeof(uint64_t)];
 static bool phinited = false;
 
 // Avoid extra level of indirection by making "pageheap" be just an alias
 // of pageheap_memory.
 typedef union {
-    void* m_memory;
+    uint64_t* m_memory;
     TCMalloc_PageHeap* m_pageHeap;
 } PageHeapUnion;
 
--- a/JavaScriptCore/wtf/ListHashSet.h
+++ b/JavaScriptCore/wtf/ListHashSet.h
@@ -127,7 +127,7 @@ namespace WTF {
             : m_freeList(pool())
             , m_isDoneWithInitialFreeList(false)
         { 
-            memset(m_pool.pool, 0, sizeof(m_pool.pool));
+            memset(m_pool, 0, sizeof(m_pool));
         }
 
         Node* allocate()
@@ -171,7 +171,7 @@ namespace WTF {
         }
 
     private:
-        Node* pool() { return reinterpret_cast<Node*>(m_pool.pool); }
+        Node* pool() { return reinterpret_cast<Node*>(m_pool); }
         Node* pastPool() { return pool() + m_poolSize; }
 
         bool inPool(Node* node)
@@ -182,10 +182,7 @@ namespace WTF {
         Node* m_freeList;
         bool m_isDoneWithInitialFreeList;
         static const size_t m_poolSize = inlineCapacity;
-        union {
-            char pool[sizeof(Node) * m_poolSize];
-            double forAlignment;
-        } m_pool;
+        uint32_t m_pool[(sizeof(Node) * m_poolSize + sizeof(uint32_t) - 1) / sizeof(uint32_t)];
     };
 
     template<typename ValueArg, size_t inlineCapacity> struct ListHashSetNode {
--- a/WebCore/platform/text/AtomicString.cpp
+++ b/WebCore/platform/text/AtomicString.cpp
@@ -103,9 +103,9 @@ static inline bool equal(StringImpl* str
     if (string->length() != length)
         return false;
 
+#if CPU(ARM) || CPU(SH4) || CPU(SPARC)
     // FIXME: perhaps we should have a more abstract macro that indicates when
     // going 4 bytes at a time is unsafe
-#if CPU(ARM) || CPU(SH4)
     const UChar* stringCharacters = string->characters();
     for (unsigned i = 0; i != length; ++i) {
         if (*stringCharacters++ != *characters++)
--- a/WebCore/platform/text/StringHash.h
+++ b/WebCore/platform/text/StringHash.h
@@ -54,13 +54,13 @@ namespace WebCore {
 
             // FIXME: perhaps we should have a more abstract macro that indicates when
             // going 4 bytes at a time is unsafe
-#if CPU(ARM) || CPU(SH4)
+#if CPU(ARM) || CPU(SH4) || CPU(SPARC)
             const UChar* aChars = a->characters();
             const UChar* bChars = b->characters();
-            for (unsigned i = 0; i != aLength; ++i) {
+            for (unsigned i = 0; i != aLength; ++i)
                 if (*aChars++ != *bChars++)
                     return false;
-            }
+
             return true;
 #else
             /* Do it 4-bytes-at-a-time on architectures where it's safe */