2008-05-04 Robert Jordan <robertj@gmx.net>
authorRobert Jordan <robertj@gmx.net>
Sun, 4 May 2008 16:22:22 +0000 (16:22 -0000)
committerRobert Jordan <robertj@gmx.net>
Sun, 4 May 2008 16:22:22 +0000 (16:22 -0000)
* libtest.c: disable struct tests for platforms with incompatible
native/managed alignments.

svn path=/trunk/mono/; revision=102468

mono/tests/ChangeLog
mono/tests/libtest.c

index eb708a715e0538aaf91b8d9e8f0be2346e9097ea..87472b691c3de5f70eb15d1d090f2d298d1b2475 100644 (file)
@@ -1,3 +1,8 @@
+2008-05-04  Robert Jordan  <robertj@gmx.net>
+
+       * libtest.c: disable struct tests for platforms with incompatible
+       native/managed alignments.
+
 2008-05-03  Robert Jordan  <robertj@gmx.net>
 
        * libtest.c, thunks.cs: tests for mono_method_get_unmanaged_thunk ().
index 8a137fbcaf7d9633cdf58b7a0ebd544a16727bd3..206bf6fab25655b26071e29fde069af3a5100d57 100644 (file)
@@ -2903,6 +2903,16 @@ mono_test_marshal_ccw_itest (MonoComObject *pUnk)
  * mono_method_get_unmanaged_thunk tests
  */
 
+
+#define NATIVE_ALIGNMENT(type) G_STRUCT_OFFSET(struct { char c; type x; }, x)
+#ifdef __GNUC__
+#define MANAGED_ALIGNMENT __alignof__
+#else
+#define MANAGED_ALIGNMENT NATIVE_ALIGNMENT
+#endif
+
+#define SAME_ALIGNMENT(type) (NATIVE_ALIGNMENT(type) == MANAGED_ALIGNMENT(type))
+
 /* thunks.cs:TestStruct */
 typedef struct _TestStruct {
        int A;
@@ -3112,18 +3122,15 @@ test_method_thunk (int id, gpointer test_method_handle, gpointer create_object_m
        }
 
        case 10: {
-
-               break;
-
-               /* disabled temporarily as it fails on linux/mac x86.
-                  struct alignment problem? */
-#if 0
                /* thunks.cs:Test.Foo10 */
                int (STDCALL *F)(TestStruct, gpointer*);
 
                TestStruct a1;
                int res;
 
+               if (!SAME_ALIGNMENT (double))
+                       break;
+
                a1.A = 42;
                a1.B = 3.1415;
 
@@ -3137,8 +3144,6 @@ test_method_thunk (int id, gpointer test_method_handle, gpointer create_object_m
                        return 5;
 
                break;
-#endif
-
        }
 
        case 11: {
@@ -3147,6 +3152,9 @@ test_method_thunk (int id, gpointer test_method_handle, gpointer create_object_m
 
                TestStruct a1;
 
+               if (!SAME_ALIGNMENT (double))
+                       break;
+
                F = test_method;
 
                F (&a1, &ex);
@@ -3168,6 +3176,9 @@ test_method_thunk (int id, gpointer test_method_handle, gpointer create_object_m
 
                TestStruct a1;
 
+               if (!SAME_ALIGNMENT (double))
+                       break;
+
                F = test_method;
 
                a1 = F (&ex);
@@ -3188,6 +3199,10 @@ test_method_thunk (int id, gpointer test_method_handle, gpointer create_object_m
                void (STDCALL *F)(TestStruct*, gpointer*);
 
                TestStruct a1;
+
+               if (!SAME_ALIGNMENT (double))
+                       break;
+
                a1.A = 42;
                a1.B = 3.1415;