[src] Use proper return type for stret functions. by rolfbjarne · Pull Request #19682 · dotnet/macios (original) (raw)

Many, many, many years ago (before my time!) Mono didn't properly handle
P/Invokes that returned structures. The arm ABI stated that certain structures
had be returned by having the function take a hidden first argument, where the
argument would be a pointer to where the returned structure should be stored
by the called function.

We worked around this in the generator by modifying functions returning
structures to functions taking a pointer to the function to return as the
first argument.

So this:

SomeStruct SomeFunction ();

would become:

void SomeFunction (SomeStruct *retval);

This workaround isn't necessary anymore, because both Mono and CoreCLR will
just do the right thing.

Except... when the the pointer to the structure must have a specific
alignment. In that case we still need the workaround, so keep it then.