[fpc-devel] Safecall on Linux (and other unices?)

Michael Van Canneyt michael at freepascal.org
Wed Jul 21 11:33:36 CEST 2010



On Wed, 21 Jul 2010, Joost van der Sluis wrote:

> Hi all,
>
> I've finally managed to get xpcom/gecko to work (partly) on linux/i386.
>
> The delphi/fpc gecko-headers uses the safecall calling convention a
> lot.
>
> On Windows a safecall is in principle a stdcall with a 'hidden' function
> result which contains a value (nsresult) to check if there was any
> problem during the call of the procedure/function.
>
> I had to find out what calling convention is used by xpcom on Linux. And
> in fact it's quite logical: it uses cdecl. (As most c-libraries do, use
> stdcall on Windows, cdecl on others)
>
> So if we want to use xpcom on Linux the same way as on Windows we need a
> special calling convention which hides the nsresult from the programmer
> and is compatible with cdecl. We need to have a "cdecl+hidden exception
> handling" calling convention.
>
> At this moment the 'safecall' calling convention on Linux is undefined.
> It does exist but has no real meaning. (In fact it is just stdcall, the
> exception-handling code is only added on Windows by the compiler)
>
> Is it an idea to change the 'safecall' convention on Linux/i386 to be
> 'cdecl + hidden exception handling' ?

I think yes. Since xpcom is the only framework I heard of that uses it,
I think it is the logical thing to do.

If later we discover that there are variants of 'safecall' on non-windows, 
we can change it.

Michael.



More information about the fpc-devel mailing list