summaryrefslogtreecommitdiff
path: root/debian/patches/30_webkit_unaligned_access.diff
blob: 8bc92113f626bfe4665611c94ac9ac1b3ea3fc03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
From: Mike Hommey <glandium@debian.org>
Date: Sun, 6 Jul 2008 08:37:28 +0000 (+0200)
Subject: Fixed some alignment problems on sparc
X-Git-Tag: debian/1.0.1-1~7
X-Git-Url: http://git.debian.org/?p=pkg-webkit%2Fwebkit.git;a=commitdiff_plain;h=11c220f6d31898a7a1dfafd5d96619fefe6ba597;hp=1db04c3a5c8c3e9c990b93836d5bb09d43a47921

Fixed some alignment problems on sparc

(and some that might occur on arm, too).

Some compiler warnings about alignment remain, but I don't know if they are
a real problem yet.
---

--- a/src/3rdparty/webkit/JavaScriptCore/wtf/FastMalloc.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/wtf/FastMalloc.cpp
@@ -1267,14 +1267,14 @@ 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/src/3rdparty/webkit/JavaScriptCore/wtf/ListHashSet.h
+++ b/src/3rdparty/webkit/JavaScriptCore/wtf/ListHashSet.h
@@ -122,7 +122,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()
@@ -166,7 +166,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)
@@ -177,10 +177,7 @@ namespace WTF {
         Node* m_freeList;
         bool m_isDoneWithInitialFreeList;
         static const size_t m_poolSize = 256;
-        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> struct ListHashSetNode {
--- a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h
+++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h
@@ -167,6 +167,23 @@
 #define WTF_PLATFORM_X86_64 1
 #endif
 
+/* PLATFORM(SPARC) */
+#if   defined(__sparc__) \
+   || defined(__sparc)
+#define WTF_PLATFORM_SPARC 1
+#define WTF_PLATFORM_BIG_ENDIAN 1
+#endif
+
+/* For undefined platforms */
+#if !defined(WTF_PLATFORM_BIG_ENDIAN) && !defined(WTF_PLATFORM_MIDDLE_ENDIAN)
+#include <sys/param.h>
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define WTF_PLATFORM_BIG_ENDIAN 1
+#elif  __BYTE_ORDER == __PDP_ENDIAN
+#define WTF_PLATFORM_MIDDLE_ENDIAN 1
+#endif
+#endif
+
 /* Compiler */
 
 /* COMPILER(MSVC) */
--- a/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h
+++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h
@@ -355,8 +355,7 @@ namespace WTF {
         static const size_t m_inlineBufferSize = inlineCapacity * sizeof(T);
         T* inlineBuffer() { return reinterpret_cast<T*>(&m_inlineBuffer); }
 
-        // FIXME: Nothing guarantees this buffer is appropriately aligned to hold objects of type T.
-        char m_inlineBuffer[m_inlineBufferSize];
+        uint64_t m_inlineBuffer[(m_inlineBufferSize + sizeof(uint64_t) - 1) / sizeof(uint64_t)];
     };
 
     template<typename T, size_t inlineCapacity = 0>
--- a/src/3rdparty/webkit/WebCore/platform/AtomicString.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/AtomicString.cpp
@@ -104,7 +104,7 @@ struct UCharBufferTranslator {
         if (strLength != bufLength)
             return false;
 
-#if PLATFORM(ARM)
+#if PLATFORM(ARM) || PLATFORM(SPARC)
         const UChar* strChars = str->characters();
         const UChar* bufChars = buf.s;
 
--- a/src/3rdparty/webkit/WebCore/platform/StringHash.h
+++ b/src/3rdparty/webkit/WebCore/platform/StringHash.h
@@ -44,6 +44,15 @@ namespace WTF {
             if (aLength != bLength)
                 return false;
 
+#if PLATFORM(ARM) || PLATFORM(SPARC)
+            const UChar* aChars = a->characters();
+            const UChar* bChars = b->characters();
+            for (unsigned i = 0; i != aLength; ++i)
+                if (*aChars++ != *bChars++)
+                    return false;
+
+            return true;
+#else
             const uint32_t* aChars = reinterpret_cast<const uint32_t*>(a->characters());
             const uint32_t* bChars = reinterpret_cast<const uint32_t*>(b->characters());
 
@@ -56,6 +65,7 @@ namespace WTF {
                 return false;
 
             return true;
+#endif
         }
     };