[squeak-dev] apical, cdecl, what's the difference?

Jakob Reschke jakob.reschke at student.hpi.de
Fri Aug 4 08:47:34 UTC 2017


Here is what I found, experts please double-check (and I only looked up
x86):

The Windows API uses the stdcall calling convention, which has the same
argument order and register preservation rules as cdecl, but the callee is
responsible to pop arguments from the stack.

In IA32FFIPlugin there is a macro PLATFORM_API_USES_CALLEE_POPS_CONVENTION,
which is only 1 on Windows. If this is 1 and apicall is used
(isCalleePopsConvention), the foreign function invocation code knows that
the callee modifies the stack pointer and reacts accordingly.

So, apicall does stdcall instead of cdecl on Windows, but not on the other
x86 platforms.

Stdcall is not the same as the Pascal calling convention, which pushes
arguments from left to right, contrary to cdecl and stdcall, which push
from right to left.

Best,
Jakob


Am 04.08.2017 3:45 vorm. schrieb "tim Rowledge" <tim at rowledge.org>:

Whilst looking at ancient OpenGL code I noted that many primitive calls
used apicall and not cdecl. The swiki entry (http://wiki.squeak.org/
squeak/2426) for FFI is… vague, and explicitly mentions confusion about the
matter. It wold be nice to clear this up, document it on the swiki and
maybe even make a Help page to go into the image.

tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Strange OpCodes: MII: Mask all Interrupts and then Interrupt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170804/f7d34825/attachment.html>


More information about the Squeak-dev mailing list