Use StdCall calling convention by default

It appears that calli callsites cannot be decorated with the
“platformapi” calling convention like DllImport signatures can. This is
problematic since Windows uses stdcall by default and most other
platforms use cdecl.

There are three approaches to this issue, without going back to
delegate calls: (a) generate an unmanaged thunk that cleans up the
stack after a GL call; (b) use libFFI; (c) use cdecl *or* stdcall
everywhere and hope that the runtime can cope.

.Net 2.0 can detect and fix stdcall functions invoked through a cdecl
callsite. .Net 4.0 adds a configuration option to enable or disable
this fixup (faster p/invoke if disabled) and raise a MDA exception when
this condition is detected. (This affects x86 only.)

Mono appears to be able to cope with cdecl functions invoked through a
stdcall callsite.

More testing is required.
This commit is contained in:
Stefanos A 2013-12-01 21:25:03 +01:00
parent 438f83c8d9
commit 6ccab1784f

View file

@ -415,7 +415,7 @@ namespace OpenTK.Rewrite
{
var signature = new CallSite(reference.ReturnType)
{
CallingConvention = MethodCallingConvention.C,
CallingConvention = MethodCallingConvention.StdCall,
};
foreach (var p in reference.Parameters)