Package: icedove / 1:52.3.0-4~deb8u2

porting-m68k/Add-m68k-support-to-Thunderbird.patch Patch series | download
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Date: Sun, 2 Apr 2017 09:14:39 +0200
Subject: Add m68k support to Thunderbird

Origin: not yet exist
Bug-Debian: https://bugs.debian.org/859271
Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1325771
Applied-Upstream: TBD

All patches have been reviewed by positively by upstream with the
exception of the alignment fixes where upstream wants to use a
C++11 solution instead of the other suggestions I made. This patch
currently uses __attribute__((aligned(4))) to ensure the alignment
is at least 4 bytes. This method is safe and works on gcc and clang
and unlike the suggested alignas() from C++11 does not break on
architectures which require stricter alignment (e.g. alignas(4)
would break on x86_64 while __attribute__((aligned(4))) does not
as it still allows for 8 bytes alignment.

Cherry-picked and adapted patches from Firefox upstream:
- a31a2d92cf9a2f4e9ad2d12cb74f96579f54fa5e
  Bug 1325771 - layout:style: Make sure nsCSSValue has at least 4 bytes alignment
- b65c6cf80f7038f47c7f5d223a6528d4aa4538cf
  Bug 1325771 - js:src: Make sure shadow::Shape has at least 4 bytes alignment
- cbbe025c5034cfa28aa2a8a4e557f9a066ddd013
  Bug 1325771 - js:src: Make sure Cell has at least 4 bytes alignment
- 6441fad686d30230a6842a6432bc134ca20c4125
  Bug 1325771 - js:jit: Use 'Feeling Lucky' atomic operations on m68k
- ec66da836071ec0f05a3517947c8e1a68620c399
  Bug 1325771 - mfbt:tests: Handle targets with less strict alignment in TestPair
- 48f3a6331cad497b933dc6e197f7a006b9189290
  Bug 1325771 - ipc:chromium: Add platform defines for m68k
- 26cd64f37741d85bc13c19bc55e3c6e26da59052
  Bug 1325771 - media:webrtc: Add platform defines for m68k
- bd19fe85678f948f60caa864a2af28c3c39059c7
  Bug 1325771 - mfbt:tests: Define RETURN_INSTR for m68k in TestPoisonArea
- a3e704b48760e3d45d20fc6bb13282d3285ba6bb
  Bug 1325771 - xpcom: Fix type of result in NS_InvokeByIndex on Linux/m68k
- 174cfc890291778d12241c9a4cfc25ea85fdd3a0
  Bug 1325771 - xpcom: Fix syntax error in PrepareAndDispatch on Linux/m68k
Additional changes:
- Add defines for m68k to double-conversion library
- Make sure both "struct Class" and "struct JSClass" have at
  least 4 bytes alignment
---
 mozilla/build/moz.configure/init.configure                       | 3 +++
 mozilla/ipc/chromium/src/build/build_config.h                    | 3 +++
 mozilla/js/src/gc/Heap.h                                         | 2 +-
 mozilla/js/src/jit/AtomicOperations.h                            | 2 ++
 mozilla/js/src/jsfriendapi.h                                     | 2 +-
 mozilla/layout/style/nsCSSValue.h                                | 2 +-
 mozilla/media/webrtc/trunk/build/build_config.h                  | 5 +++++
 mozilla/mfbt/double-conversion/utils.h                           | 2 ++
 mozilla/mfbt/tests/TestPair.cpp                                  | 9 +++++++--
 mozilla/mfbt/tests/TestPoisonArea.cpp                            | 3 +++
 mozilla/python/mozbuild/mozbuild/configure/constants.py          | 2 ++
 .../mozbuild/mozbuild/test/configure/test_toolchain_configure.py | 3 +++
 mozilla/xpcom/reflect/xptcall/md/unix/xptcinvoke_linux_m68k.cpp  | 3 ++-
 mozilla/xpcom/reflect/xptcall/md/unix/xptcstubs_linux_m68k.cpp   | 2 +-
 14 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/mozilla/build/moz.configure/init.configure b/mozilla/build/moz.configure/init.configure
index 2123beb..3c2d609 100644
--- a/mozilla/build/moz.configure/init.configure
+++ b/mozilla/build/moz.configure/init.configure
@@ -380,6 +380,9 @@ def split_triplet(triplet):
     elif cpu.startswith('aarch64'):
         canonical_cpu = 'aarch64'
         endianness = 'little'
+    elif cpu in ('m68k'):
+        canonical_cpu = 'm68k'
+        endianness = 'big'
     else:
         die('Unknown CPU type: %s' % cpu)
 
diff --git a/mozilla/ipc/chromium/src/build/build_config.h b/mozilla/ipc/chromium/src/build/build_config.h
index 342bd56..6ac0918 100644
--- a/mozilla/ipc/chromium/src/build/build_config.h
+++ b/mozilla/ipc/chromium/src/build/build_config.h
@@ -78,6 +78,9 @@
 #define ARCH_CPU_ARMEL 1
 #define ARCH_CPU_32_BITS 1
 #define WCHAR_T_IS_UNSIGNED 1
+#elif defined(__m68k__)
+#define ARCH_CPU_M68K 1
+#define ARCH_CPU_32_BITS 1
 #elif defined(__powerpc64__)
 #define ARCH_CPU_PPC64 1
 #define ARCH_CPU_64_BITS 1
diff --git a/mozilla/js/src/gc/Heap.h b/mozilla/js/src/gc/Heap.h
index 2a9390e..4e08bc9 100644
--- a/mozilla/js/src/gc/Heap.h
+++ b/mozilla/js/src/gc/Heap.h
@@ -282,7 +282,7 @@ struct Cell
   protected:
     inline uintptr_t address() const;
     inline Chunk* chunk() const;
-} JS_HAZ_GC_THING;
+} JS_HAZ_GC_THING __attribute__ ((aligned(4)));
 
 // A GC TenuredCell gets behaviors that are valid for things in the Tenured
 // heap, such as access to the arena and mark bits.
diff --git a/mozilla/js/src/jit/AtomicOperations.h b/mozilla/js/src/jit/AtomicOperations.h
index 078be67..e12cb86 100644
--- a/mozilla/js/src/jit/AtomicOperations.h
+++ b/mozilla/js/src/jit/AtomicOperations.h
@@ -326,6 +326,8 @@ AtomicOperations::isLockfree(int32_t size)
 # include "jit/arm64/AtomicOperations-arm64.h"
 #elif defined(__hppa__)
 # include "jit/none/AtomicOperations-ppc.h"
+#elif defined(__m68k__)
+# include "jit/none/AtomicOperations-ppc.h"
 #elif defined(JS_CODEGEN_MIPS32) || defined(JS_CODEGEN_MIPS64)
 # include "jit/mips-shared/AtomicOperations-mips-shared.h"
 #elif defined(__ppc__) || defined(__PPC__)
diff --git a/mozilla/js/src/jsfriendapi.h b/mozilla/js/src/jsfriendapi.h
index b1c7cb0..2b6b956 100644
--- a/mozilla/js/src/jsfriendapi.h
+++ b/mozilla/js/src/jsfriendapi.h
@@ -571,7 +571,7 @@ public:
     uint32_t          slotInfo;
 
     static const uint32_t FIXED_SLOTS_SHIFT = 27;
-};
+} __attribute__ ((aligned(4)));
 
 /**
  * This layout is shared by all native objects. For non-native objects, the
diff --git a/mozilla/layout/style/nsCSSValue.h b/mozilla/layout/style/nsCSSValue.h
index 1721cc8..7531fe8 100644
--- a/mozilla/layout/style/nsCSSValue.h
+++ b/mozilla/layout/style/nsCSSValue.h
@@ -1032,7 +1032,7 @@ protected:
     mozilla::css::FontFamilyListRefCnt* MOZ_OWNING_REF mFontFamilyList;
     mozilla::css::ComplexColorValue* MOZ_OWNING_REF mComplexColor;
   } mValue;
-};
+} __attribute__ ((aligned(4)));
 
 struct nsCSSValue::Array final {
 
diff --git a/mozilla/media/webrtc/trunk/build/build_config.h b/mozilla/media/webrtc/trunk/build/build_config.h
index dcb3d47..bbd0b22 100644
--- a/mozilla/media/webrtc/trunk/build/build_config.h
+++ b/mozilla/media/webrtc/trunk/build/build_config.h
@@ -123,6 +123,11 @@
 #define ARCH_CPU_MIPSEL 1
 #define ARCH_CPU_32_BITS 1
 #define ARCH_CPU_LITTLE_ENDIAN 1
+#elif defined(__m68k__)
+#define ARCH_CPU_M68K_FAMILY 1
+#define ARCH_CPU_M68K 1
+#define ARCH_CPU_32_BITS 1
+#define ARCH_CPU_BIG_ENDIAN 1
 #elif defined(__powerpc64__)
 #define ARCH_CPU_PPC_FAMILY 1
 #define ARCH_CPU_PPC64 1
diff --git a/mozilla/mfbt/double-conversion/utils.h b/mozilla/mfbt/double-conversion/utils.h
index 15dd4bf..f14b6b1 100644
--- a/mozilla/mfbt/double-conversion/utils.h
+++ b/mozilla/mfbt/double-conversion/utils.h
@@ -62,6 +62,8 @@
     defined(_MIPS_ARCH_MIPS32R2) || \
     defined(__AARCH64EL__) || defined(__aarch64__)
 #define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
+#elif defined(__mc68000__)
+#undef DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS
 #elif defined(_M_IX86) || defined(__i386__) || defined(__i386)
 #if defined(_WIN32)
 // Windows uses a 64bit wide floating point stack.
diff --git a/mozilla/mfbt/tests/TestPair.cpp b/mozilla/mfbt/tests/TestPair.cpp
index f1fa9c5..41b463a 100644
--- a/mozilla/mfbt/tests/TestPair.cpp
+++ b/mozilla/mfbt/tests/TestPair.cpp
@@ -29,14 +29,19 @@ using mozilla::Pair;
   static_assert(sizeof(name##_2) == (size), \
                 "Pair<" #T2 ", " #T1 "> has an unexpected size");
 
+static constexpr size_t sizemax(size_t a, size_t b)
+{
+  return (a > b) ? a : b;
+}
+
 INSTANTIATE(int, int, prim1, 2 * sizeof(int));
-INSTANTIATE(int, long, prim2, 2 * sizeof(long));
+INSTANTIATE(int, long, prim2, sizeof(long) + sizemax(sizeof(int), alignof(long)));
 
 struct EmptyClass { explicit EmptyClass(int) {} };
 struct NonEmpty { char mC; explicit NonEmpty(int) {} };
 
 INSTANTIATE(int, EmptyClass, both1, sizeof(int));
-INSTANTIATE(int, NonEmpty, both2, 2 * sizeof(int));
+INSTANTIATE(int, NonEmpty, both2, sizeof(int) + alignof(int));
 INSTANTIATE(EmptyClass, NonEmpty, both3, 1);
 
 struct A { char dummy; explicit A(int) {} };
diff --git a/mozilla/mfbt/tests/TestPoisonArea.cpp b/mozilla/mfbt/tests/TestPoisonArea.cpp
index 6f1b61e..9360ac9 100644
--- a/mozilla/mfbt/tests/TestPoisonArea.cpp
+++ b/mozilla/mfbt/tests/TestPoisonArea.cpp
@@ -133,6 +133,9 @@
 #elif defined _ARCH_PPC || defined _ARCH_PWR || defined _ARCH_PWR2
 #define RETURN_INSTR 0x4E800020 /* blr */
 
+#elif defined __m68k__
+#define RETURN_INSTR 0x4E754E75 /* rts; rts */
+
 #elif defined __sparc || defined __sparcv9
 #define RETURN_INSTR 0x81c3e008 /* retl */
 
diff --git a/mozilla/python/mozbuild/mozbuild/configure/constants.py b/mozilla/python/mozbuild/mozbuild/configure/constants.py
index dfc7cf8..9c0f0ca 100644
--- a/mozilla/python/mozbuild/mozbuild/configure/constants.py
+++ b/mozilla/python/mozbuild/mozbuild/configure/constants.py
@@ -44,6 +44,7 @@ CPU_bitness = {
     'arm': 32,
     'hppa': 32,
     'ia64': 64,
+    'm68k': 32,
     'mips32': 32,
     'mips64': 64,
     'ppc': 32,
@@ -85,6 +86,7 @@ CPU_preprocessor_checks = OrderedDict((
     ('sparc', '__sparc__'),
     ('mips64', '__mips64'),
     ('mips32', '__mips__'),
+    ('m68k', '__m68k__'),
 ))
 
 assert sorted(CPU_preprocessor_checks.keys()) == sorted(CPU.POSSIBLE_VALUES)
diff --git a/mozilla/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py b/mozilla/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
index 2ef9379..b06ddde 100644
--- a/mozilla/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
+++ b/mozilla/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
@@ -1037,6 +1037,9 @@ class LinuxCrossCompileToolchainTest(BaseToolchainTest):
         'mips-unknown-linux-gnu': big_endian + {
             '__mips__': 1,
         },
+        'm68k-unknown-linux-gnu': big_endian + {
+            '__m68k__': 1,
+        },
     }
 
     PLATFORMS['powerpc64le-unknown-linux-gnu'] = \
diff --git a/mozilla/xpcom/reflect/xptcall/md/unix/xptcinvoke_linux_m68k.cpp b/mozilla/xpcom/reflect/xptcall/md/unix/xptcinvoke_linux_m68k.cpp
index 6f2934c..a64fd62 100644
--- a/mozilla/xpcom/reflect/xptcall/md/unix/xptcinvoke_linux_m68k.cpp
+++ b/mozilla/xpcom/reflect/xptcall/md/unix/xptcinvoke_linux_m68k.cpp
@@ -100,7 +100,8 @@ EXPORT_XPCOM_API(nsresult)
 NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
                    uint32_t paramCount, nsXPTCVariant* params)
 {
-    uint32_t result, n;
+    nsresult result;
+    uint32_t n;
 
     n = invoke_count_words(paramCount, params) * 4;
 
diff --git a/mozilla/xpcom/reflect/xptcall/md/unix/xptcstubs_linux_m68k.cpp b/mozilla/xpcom/reflect/xptcall/md/unix/xptcstubs_linux_m68k.cpp
index 3720a5c..fc33ba0 100644
--- a/mozilla/xpcom/reflect/xptcall/md/unix/xptcstubs_linux_m68k.cpp
+++ b/mozilla/xpcom/reflect/xptcall/md/unix/xptcstubs_linux_m68k.cpp
@@ -63,7 +63,7 @@ extern "C" {
             case nsXPTType::T_U64    : dp->val.u64 = *((uint64_t*)ap); ap++; break;
             case nsXPTType::T_FLOAT  : dp->val.f   = *((float*)   ap);       break;
             case nsXPTType::T_DOUBLE : dp->val.d   = *((double*)  ap); ap++; break;
-            case nsXPTType::T_BOOL   : dp->val.b   = *((uint32_t* ap);       break;
+            case nsXPTType::T_BOOL   : dp->val.b   = *((uint32_t*)ap);       break;
             case nsXPTType::T_CHAR   : dp->val.c   = *(((char*)   ap) + 3);  break;
             case nsXPTType::T_WCHAR  : dp->val.wc  = *((wchar_t*) ap);       break;
             default: