[PATCH] netio.sys: Remove WINAPI on static functions where not needed.
Francois Gouget
fgouget at free.fr
Mon Jun 29 16:16:22 CDT 2020
On Mon, 29 Jun 2020, Paul Gofman wrote:
[...]
> I don't think it matters much, but is it really an improvement? If we
> call a single helper function from WINAPI function, which in turn calls
> just WINAPI functions, isn't it cleaner to keep the same calling ABI to
> potentially reduce the number of register saves?
This check was originally created because gcc had a bug on the Mac which
caused it to mishandle 'static WINAPI' functions in some cases. Ken
actually provided the following explanation at the time:
| On the Mac, WINAPI (and other declspecs) include the
| force_align_arg_pointer attribute. With -O2 optimization (actually
| -funit-at-a-time, implied by -O2) the compiler may change the calling
| convention used by non-exported functions to take arguments via
| registers rather than on the stack. The prologue generated for
| force_align_arg_pointer clobbers one of those registers (and hence
| one of the arguments).
That was 12 years ago mind you so presumably gcc has been fixed
since then. But this does hint that the compiler may indeed adjust
the calling convention to optimise things.
Also note that static functions that are exported through vtables or
other pointer passing methods are not impacted because the compiler is
smart enough to realise it cannot change the calling convention at will.
--
Francois Gouget <fgouget at free.fr> http://fgouget.free.fr/
Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke
More information about the wine-devel
mailing list