pharo-users@lists.pharo.org

Any question about pharo is welcome

View all threads

uFFI: Calling conventions?

E
egarrulo
Tue, Aug 24, 2021 7:33 PM

Hi all,

I haven't found any information on calling conventions in the "Unified
FFI - Calling Foreign Functions from Pharo" manual. What conventions are
available, please?

If the ThisCall[1] convention isn't supported, could it be implemented
in code with some boilerplate?

Thank you.

--

[1] ThisCall works like StdCall, but the first parameter - the "this"
pointer - is passed via the ECX register.

Hi all, I haven't found any information on calling conventions in the "Unified FFI - Calling Foreign Functions from Pharo" manual. What conventions are available, please? If the ThisCall[1] convention isn't supported, could it be implemented in code with some boilerplate? Thank you. -- [1] ThisCall works like StdCall, but the first parameter - the "this" pointer - is passed via the ECX register.
T
tesonep@gmail.com
Thu, Aug 26, 2021 1:38 PM

Hi All,
The answer is yes and no.
Let's go step by step.
To declare the calling convention a class can override the method
#ffiCallingConvention. Returning a Symbol representing the Calling
Convention.

Yesterday we have implemented the image side part in P10 to correctly
honour the calling convention.
I have implemented it for X86 but this can be easily extended to ARM32
(ARM64 has a single calling convention).
If this fix is useful, it can be backported to P9.

However, this only works for X86_64 as it depends on the new FFI
implementation. We still do not have an X86 32 bits VM, it is possible to
compile it from sources, but we are not distributing it.

In X86_64 only exists the Windows and the GNU calling convention, we are
supporting both.

On the other hand, you are asking about ThisCall. This calling convention
is only relevant in 32bits systems. What is your target system/library?
Does it not exist as 64-bit library?

Thanks

On Tue, Aug 24, 2021 at 9:33 PM egarrulo egarrulo@gmail.com wrote:

Hi all,

I haven't found any information on calling conventions in the "Unified
FFI - Calling Foreign Functions from Pharo" manual. What conventions are
available, please?

If the ThisCall[1] convention isn't supported, could it be implemented
in code with some boilerplate?

Thank you.

--

[1] ThisCall works like StdCall, but the first parameter - the "this"
pointer - is passed via the ECX register.

--
Pablo Tesone.
tesonep@gmail.com

Hi All, The answer is yes and no. Let's go step by step. To declare the calling convention a class can override the method #ffiCallingConvention. Returning a Symbol representing the Calling Convention. Yesterday we have implemented the image side part in P10 to correctly honour the calling convention. I have implemented it for X86 but this can be easily extended to ARM32 (ARM64 has a single calling convention). If this fix is useful, it can be backported to P9. However, this only works for X86_64 as it depends on the new FFI implementation. We still do not have an X86 32 bits VM, it is possible to compile it from sources, but we are not distributing it. In X86_64 only exists the Windows and the GNU calling convention, we are supporting both. On the other hand, you are asking about ThisCall. This calling convention is only relevant in 32bits systems. What is your target system/library? Does it not exist as 64-bit library? Thanks On Tue, Aug 24, 2021 at 9:33 PM egarrulo <egarrulo@gmail.com> wrote: > Hi all, > > I haven't found any information on calling conventions in the "Unified > FFI - Calling Foreign Functions from Pharo" manual. What conventions are > available, please? > > If the ThisCall[1] convention isn't supported, could it be implemented > in code with some boilerplate? > > Thank you. > > -- > > [1] ThisCall works like StdCall, but the first parameter - the "this" > pointer - is passed via the ECX register. > > -- Pablo Tesone. tesonep@gmail.com