[runtime] Fix endianness issue with special static offsets.
authorAlex Rønne Petersen <alexrp@xamarin.com>
Fri, 15 May 2015 21:17:52 +0000 (23:17 +0200)
committerAlex Rønne Petersen <alexrp@xamarin.com>
Sat, 16 May 2015 00:49:32 +0000 (02:49 +0200)
On big endian systems, this code would break because we reinterpret the
structure as a `guint32` via memory. Fix this by reversing the order of
the fields on big endian systems.

mono/metadata/threads.c

index 1c8bae663a6d8c522bd552ea41eed4477a0d24d0..e1755a1dce66ffe962c0f12b82dd68a0fc05bd02 100644 (file)
@@ -499,9 +499,15 @@ static void thread_cleanup (MonoInternalThread *thread)
 
 typedef union {
        struct {
+#if G_BYTE_ORDER != G_LITTLE_ENDIAN
+               guint32 type : 1;
+               guint32 offset : 25;
+               guint32 index : 6;
+#else
                guint32 index : 6;
                guint32 offset : 25;
                guint32 type : 1;
+#endif
        } fields;
        guint32 raw;
 } SpecialStaticOffset;