Hi,<br><br>  There is a method called a managed-to-native wrapper between the test method and the<br> C function, this method is generated by the runtime, in marshal.c, and it does the marshalling of parameters, in this case, it should convert the &#39;true&#39; value to a 0xffff.<br>
Also, I can&#39;t reproduce this failure on either ppc or ppc64 (debian).<br><br>                                                    Zoltan<br><br><div class="gmail_quote">On Sat, May 30, 2009 at 5:37 PM, Steven Munroe <span dir="ltr">&lt;<a href="mailto:munroesj@us.ibm.com">munroesj@us.ibm.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">Zoltan Varga wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; The last argument is marshalled as VariantBool:<br>
&gt;<br>
&gt;                             [MarshalAs (UnmanagedType.VariantBool)]<br>
&gt; bool bVBCustMarsh);<br>
&gt;<br>
&gt; VariantBool is marshalled as: (2 bytes, VARIANT_TRUE = 0xFFFF,<br>
&gt; VARIANT_FALSE = 0)<br>
&gt;<br>
&gt; so the the C function should receive 0xffff in bVBCustMarsh, not 1. No<br>
&gt; idea why this happens<br>
&gt; on ppc.<br>
&gt;<br>
&gt;                                     Zoltan<br>
<br>
</div>This is strange as it appears that x86_64 is also passing 1 to the 7th<br>
parm bVBCustMarsh.<br>
<br>
0000000000000000 &lt;shalbool_test_0_VariantBool_In_Native&gt;:<br>
&lt;BB&gt;:3<br>
   0:    55                       push   %rbp<br>
   1:    48 8b ec                 mov    %rsp,%rbp<br>
   4:    41 56                    push   %r14<br>
   6:    48 83 ec 28              sub    $0x28,%rsp<br>
   a:    c6 45 ef 00              movb   $0x0,-0x11(%rbp)<br>
/* 1st call to mono_test_marshal_bool_in (5, 0, false, false, false,<br>
false, false);<br>
    Note the 7th parm is passed on the stack and set to 0 */<br>
   e:    48 c7 04 24 00 00 00     movq   $0x0,(%rsp)<br>
  15:    00<br>
  16:    bf 05 00 00 00           mov    $0x5,%edi<br>
  1b:    33 f6                    xor    %esi,%esi<br>
  1d:    33 d2                    xor    %edx,%edx<br>
  1f:    33 c9                    xor    %ecx,%ecx<br>
  21:    45 33 c0                 xor    %r8d,%r8d<br>
  24:    45 33 c9                 xor    %r9d,%r9d<br>
  27:    e8 53 fb ff ff           callq  fffffffffffffb7f<br>
&lt;shalbool_test_0_VariantBool_In_Native+0xfffffffffffffb7f&gt;<br>
  2c:    4c 8b f0                 mov    %rax,%r14<br>
  2f:    45 85 f6                 test   %r14d,%r14d<br>
  32:    74 0d                    je     41<br>
&lt;shalbool_test_0_VariantBool_In_Native+0x41&gt;<br>
&lt;BB&gt;:5<br>
  34:    49 8b c6                 mov    %r14,%rax<br>
  37:    05 00 01 00 00           add    $0x100,%eax<br>
  3c:    e9 94 00 00 00           jmpq   d5<br>
&lt;shalbool_test_0_VariantBool_In_Native+0xd5&gt;<br>
&lt;BB&gt;:4<br>
/* 2nd call to mono_test_marshal_bool_in (5, 0xFFFF, false, false,<br>
false, false, true);<br>
    Note the 7th parm is set to 0x1 not 0xffff */<br>
  41:    48 c7 04 24 01 00 00     movq   $0x1,(%rsp)<br>
  48:    00<br>
  49:    bf 05 00 00 00           mov    $0x5,%edi<br>
  4e:    be ff ff 00 00           mov    $0xffff,%esi<br>
  53:    33 d2                    xor    %edx,%edx<br>
  55:    33 c9                    xor    %ecx,%ecx<br>
  57:    45 33 c0                 xor    %r8d,%r8d<br>
  5a:    45 33 c9                 xor    %r9d,%r9d<br>
  5d:    66 90                    xchg   %ax,%ax<br>
  5f:    e8 1b fb ff ff           callq  fffffffffffffb7f<br>
&lt;shalbool_test_0_VariantBool_In_Native+0xfffffffffffffb7f&gt;<br>
<br>
So if [MarshalAs (UnmanagedType.VariantBool)] should result in<br>
generating a 0xffff for true then x86_64 is broken to.<br>
<div class="im">&gt;<br>
&gt;<br>
&gt; On Sat, May 30, 2009 at 3:36 AM, Steven Munroe &lt;<a href="mailto:munroesj@us.ibm.com">munroesj@us.ibm.com</a><br>
</div><div><div></div><div class="h5">&gt; &lt;mailto:<a href="mailto:munroesj@us.ibm.com">munroesj@us.ibm.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     The test:<br>
&gt;<br>
&gt;        unsafe public static int test_0_VariantBool_In_Native ()<br>
&gt;        {<br>
&gt;            int ret;<br>
&gt;<br>
&gt;            ret = mono_test_marshal_bool_in (5, 0, false, false, false,<br>
&gt;     false, false);<br>
&gt;            if (ret != 0)<br>
&gt;                return 0x0100 + ret;<br>
&gt;            ret = mono_test_marshal_bool_in (5, 0xFFFF, false, false,<br>
&gt;     false,<br>
&gt;     false, true);<br>
&gt;            if (ret != 0)<br>
&gt;                return 0x0200 + ret;<br>
&gt;<br>
&gt;            bool testVal = false;<br>
&gt;            bool* ptestVal = &amp;testVal;<br>
&gt;<br>
&gt;            Marshal.WriteByte ((IntPtr)ptestVal, 0x22);<br>
&gt;            ret = mono_test_marshal_bool_in (5, 0xFFFF, false, false,<br>
&gt;     false,<br>
&gt;     false, testVal);<br>
&gt;            if (ret != 0)<br>
&gt;                return 0x0300 + ret;<br>
&gt;<br>
&gt;            return 0;<br>
&gt;        }<br>
&gt;<br>
&gt;     is failing specifically:<br>
&gt;<br>
&gt;            ret = mono_test_marshal_bool_in (5, 0xFFFF, false, false,<br>
&gt;     false,<br>
&gt;     false, true);<br>
&gt;            if (ret != 0)<br>
&gt;                return 0x0200 + ret;<br>
&gt;<br>
&gt;     In PPC we pass 0x00000005 parm arg in R3, 0x0000FFFF to parm<br>
&gt;     &quot;expected&quot;<br>
&gt;     in R4 and 0x00000001 parm bVBCustMarsh in R9 to<br>
&gt;     mono_test_marshal_bool_in. The Implementation of<br>
&gt;     mono_test_marshal_bool_in is:<br>
&gt;<br>
&gt;     LIBTEST_API int STDCALL<br>
&gt;     mono_test_marshal_bool_in (int arg, unsigned int expected,<br>
&gt;     unsigned int<br>
&gt;     bDefaultMarsh, unsigned int bBoolCustMarsh,<br>
&gt;                   char bI1CustMarsh, unsigned char bU1CustMarsh, unsigned<br>
&gt;     short bVBCustMarsh)<br>
&gt;     {<br>
&gt;        switch (arg) {<br>
&gt;        case 1:<br>
&gt;            if (bDefaultMarsh != expected)<br>
&gt;                return 1;<br>
&gt;            break;<br>
&gt;        case 2:<br>
&gt;            if (bBoolCustMarsh != expected)<br>
&gt;                return 2;<br>
&gt;            break;<br>
&gt;        case 3:<br>
&gt;            if (bI1CustMarsh != expected)<br>
&gt;                return 3;<br>
&gt;            break;<br>
&gt;        case 4:<br>
&gt;            if (bU1CustMarsh != expected)<br>
&gt;                return 4;<br>
&gt;            break;<br>
&gt;        case 5:<br>
&gt;            if (bVBCustMarsh != expected)<br>
&gt;                return 5;<br>
&gt;            break;<br>
&gt;        default:<br>
&gt;            return 999;<br>
&gt;        }<br>
&gt;        return 0;<br>
&gt;     }<br>
&gt;<br>
&gt;     In this case<br>
&gt;<br>
&gt;            if (bVBCustMarsh != expected)<br>
&gt;                return 5;<br>
&gt;<br>
&gt;     will compare 0x0000FFFF != 0x00000001 and return 5.<br>
&gt;<br>
&gt;     There seems to be a number of problems with this test and its not<br>
&gt;     clean<br>
&gt;     why it (appears to) work for x86_64. In marshalbool.cs we see<br>
&gt;     mono_test_marshal_bool_in declared as:<br>
&gt;<br>
&gt;        [DllImport (&quot;libtest&quot;)]<br>
&gt;        static extern int mono_test_marshal_bool_in (int arg, uint<br>
&gt;     expected,<br>
&gt;                                 bool bDefaultMarsh,<br>
&gt;                                 [MarshalAs (UnmanagedType.Bool)] bool<br>
&gt;     bBoolCustMarsh,<br>
&gt;                                 [MarshalAs (UnmanagedType.I1)] bool<br>
&gt;     bI1CustMarsh,<br>
&gt;                                 [MarshalAs (UnmanagedType.U1)] bool<br>
&gt;     bU1CustMarsh,<br>
&gt;                                 [MarshalAs (UnmanagedType.VariantBool)]<br>
&gt;     bool bVBCustMarsh);<br>
&gt;<br>
&gt;     Which does not match the declaration on libtest.c:<br>
&gt;<br>
&gt;     LIBTEST_API int STDCALL<br>
&gt;     mono_test_marshal_bool_in (int arg, unsigned int expected,<br>
&gt;     unsigned int<br>
&gt;     bDefaultMarsh, unsigned int bBoolCustMarsh,<br>
&gt;                   char bI1CustMarsh, unsigned char bU1CustMarsh, unsigned<br>
&gt;     short bVBCustMarsh)<br>
&gt;<br>
&gt;     I don&#39;t see how this test is supposed to work (0x0000FFFF !=<br>
&gt;     0x00000001)<br>
&gt;     especially as we are comparing a unsigned int to a unsigned short?<br>
&gt;<br>
&gt;<br>
&gt;     _______________________________________________<br>
&gt;     Mono-devel-list mailing list<br>
&gt;     <a href="mailto:Mono-devel-list@lists.ximian.com">Mono-devel-list@lists.ximian.com</a><br>
</div></div>&gt;     &lt;mailto:<a href="mailto:Mono-devel-list@lists.ximian.com">Mono-devel-list@lists.ximian.com</a>&gt;<br>
<div><div></div><div class="h5">&gt;     <a href="http://lists.ximian.com/mailman/listinfo/mono-devel-list" target="_blank">http://lists.ximian.com/mailman/listinfo/mono-devel-list</a><br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br>