Add m68k support to Thunderbird
authorJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Sun, 2 Apr 2017 07:14:39 +0000 (09:14 +0200)
committerCarsten Schoenert <c.schoenert@t-online.de>
Thu, 14 Feb 2019 19:01:03 +0000 (19:01 +0000)
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

Gbp-Pq: Topic porting-m68k
Gbp-Pq: Name Add-m68k-support-to-Thunderbird.patch

build/moz.configure/init.configure
ipc/chromium/src/build/build_config.h
js/src/jsfriendapi.h
layout/style/nsCSSValue.h
media/webrtc/trunk/build/build_config.h
mfbt/tests/TestPair.cpp
mfbt/tests/TestPoisonArea.cpp
python/mozbuild/mozbuild/configure/constants.py
python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
xpcom/reflect/xptcall/md/unix/xptcinvoke_linux_m68k.cpp
xpcom/reflect/xptcall/md/unix/xptcstubs_linux_m68k.cpp

index 83b8d705591b1f5afc52eb36f36de25af74bcf8a..0d0f048c35910c69fff10919bf6f9edfde3b8dca 100644 (file)
@@ -676,6 +676,9 @@ def split_triplet(triplet, allow_unknown=False):
     elif cpu == 'sh4':
         canonical_cpu = 'sh4'
         endianness = 'little'
+    elif cpu in ('m68k'):
+        canonical_cpu = 'm68k'
+        endianness = 'big'
     elif allow_unknown:
         canonical_cpu = cpu
         endianness = 'unknown'
index 6196d9204c24eeab252ac82a61f110c3980f97c6..1000d0019086676932d5bf33316088b5bd052bd9 100644 (file)
@@ -81,6 +81,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
index 4b8d18a4cb699612d42d58a6a5d2caf22a492e61..4ff10b0b20cd855f3c2ba7a4ef9cb593e6d930fc 100644 (file)
@@ -563,7 +563,7 @@ class Shape {
   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
index 53bd3ad1e1b7cfe4fd78b81e444b18b45f45927b..fa3cdcd64297041fa905c1d38f0498b85a2456dd 100644 (file)
@@ -1017,7 +1017,7 @@ class nsCSSValue {
     mozilla::SharedFontList* MOZ_OWNING_REF mFontFamilyList;
     mozilla::css::ComplexColorValue* MOZ_OWNING_REF mComplexColor;
   } mValue;
-};
+} __attribute__ ((aligned(4)));
 
 struct nsCSSValue::Array final {
   // return |Array| with reference count of zero
index 312674baab0074d16352ba068344beadab059229..e10a23476121e2b9df122e93ca704e8746797d70 100644 (file)
 #define ARCH_CPU_LITTLE_ENDIAN 1
 #elif defined(__pnacl__)
 #define ARCH_CPU_32_BITS 1
+#elif defined(__MIPSEL__)
+#define ARCH_CPU_MIPS_FAMILY 1
+#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
index f1fa9c554f1101c081d567a718fda3368f59ab02..41b463a136eff4fe875f78126536fe7d61233d17 100644 (file)
@@ -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) {} };
index 06c24ed03256e81c2f59f1ef01de6d92f6053212..763dfbce136efff41c403d4731b8b0f2f9abe30c 100644 (file)
 #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 */
 
index 33ae5a4568f369e128aa70447b19231f4e3d2450..a67ab80d2146656fe96b64b5c2a423303683880d 100644 (file)
@@ -46,6 +46,7 @@ CPU_bitness = {
     'arm': 32,
     'hppa': 32,
     'ia64': 64,
+    'm68k': 32,
     'mips32': 32,
     'mips64': 64,
     'ppc': 32,
@@ -89,6 +90,7 @@ CPU_preprocessor_checks = OrderedDict((
     ('mips64', '__mips64'),
     ('mips32', '__mips__'),
     ('sh4', '__sh__'),
+    ('m68k', '__m68k__'),
 ))
 
 assert sorted(CPU_preprocessor_checks.keys()) == sorted(CPU.POSSIBLE_VALUES)
index cb7ff709e1b78aeea31557532be980719c14a685..a1b444ac0dab7b63d4bc2168e3bac23f5fb952ba 100755 (executable)
@@ -1165,6 +1165,9 @@ class LinuxCrossCompileToolchainTest(BaseToolchainTest):
         'sh4-unknown-linux-gnu': little_endian + {
             '__sh__': 1,
         },
+        'm68k-unknown-linux-gnu': big_endian + {
+            '__m68k__': 1,
+        },
     }
 
     PLATFORMS['powerpc64le-unknown-linux-gnu'] = \
index 7d042a7b0152a390e21343cb2ba559070c57414d..6989340f3f8601e4e3532fba00a27fe1be3e92aa 100644 (file)
@@ -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;
 
index 3720a5c37f97d0690903cdc86a5585591d2a8eba..fc33ba09b38f9d4a0e45478e3a0cf5ab841e1582 100644 (file)
@@ -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: