Multiple fixes for Windows x86 p/invoke test failures. (#3186)
authorJohan Lorensson <lateralusx.github@gmail.com>
Wed, 6 Jul 2016 04:32:08 +0000 (06:32 +0200)
committerMiguel de Icaza <miguel@gnome.org>
Wed, 6 Jul 2016 04:32:08 +0000 (00:32 -0400)
commitee05c8a322b3083f147d2c2d1464e381fdd19756
treeed0b6331b54c4c26872f538e5ac1a765df34b7b8
parent4d9ffd3db28563a57bc29321d5b4faba79f19006
Multiple fixes for Windows x86 p/invoke test failures.  (#3186)

* Fix for non GCC win x86 calling convention when passing empty structs over pinvoke.

Port of https://github.com/mono/mono/pull/3085 to Winwdows x86 fixing failures
in pinvoke2 tests:

test_0_marshal_empty_struct

* Fix for incorrect implementation of small struct (single float/double) on Windows x86.

Failure in pinvoke3 test_0_marshal_small_struct_delegate9 is caused by incorrect
implemented small struct ABI on Windows x86.

Windows x86 ABI for returning structs of size 4 or 8 bytes (regardless of type)
dictates that values are passed in EDX:EAX register pairs,
https://msdn.microsoft.com/en-us/library/984x0h58.aspx.
This is different compared to for example float or double return types
(not in struct) that will be returned in ST(0),
https://msdn.microsoft.com/en-us/library/ha59cbfz.aspx.

Fix disables the alternative to do special handling of structs with 1 float or double
and make sure same logic is always applied to all small structs regardless type
as dictated by Windows x86 ABI.

* mono_test_marshal_delegate_ref_delegate uses incorrect calling convention.

mono_test_marshal_delegate_ref_delegate called by pinvoke3::test_55_marshal_delegate_ref_delegate
uses incorrect calling convention. Mono assumes delegates to be stdcall but
current definitions will be cdecl, this will cause an incorrect stack pointer
on architectures where cdecl and stdcall are different (Windows x86). Test fails
with "corrupt" stack pointer on Windows x86.

* Smaller adjustment based on feedback.

* Changed boolean struct member to bit field (on both x86 and x64)
* Changed compare code style from 0 == x to x == 0 to comply with coding standard.
mono/mini/mini-amd64.h
mono/mini/mini-x86.c
mono/mini/mini-x86.h
mono/tests/libtest.c