On Sun, Jan 27, 2013 at 2:26 PM, Ciprian Teodorov <ciprian.teodorov@gmail.com> wrote:
Hi Guys,

Today I wanted to test my TalkFFI project on linux, and I run into some NB issue.
It seems that the VM crashes when trying to invoke a function returning a 8 byte structure.
I have tried with 4 bytes structure and I get some bogus data but no crash
with 12 bytes structure it seems to work...

I suspect this is a win32/linux difference that NB doesn't handle yet. �On win32 power-of-two structures <= 8 bytes in length are returned in registers. �On linux they're always returned through memory. �Here are the relevant defs from the�ThreadedIA32FFIPlugin


#if defined(_X86_) || defined(i386) || defined(__i386) || defined(__i386__)
/* Both Mac OS X x86 and Win32 x86 return structs of a power of two in size
�* less than or equal to eight bytes in length in registers. Linux never does so.
�*/
# if __linux__
# define WIN32_X86_STRUCT_RETURN 0
# else
# define WIN32_X86_STRUCT_RETURN 1
# endif
#define�returnStructInRegisters(sz) (WIN32_X86_STRUCT_RETURN && (sz) <= 8 && !((sz)&((sz)-1)))


HTH

Attached to this mail you will find a simple test case.

the c file I have compiled with:

gcc -g -fPIC -Wall -c -m32 strreturn.c
gcc -shared -g -Wl,-soname,libret.so.1 -o libret.so -m32 strreturn.o -lc

Cheers,
--
Dr. Ciprian TEODOROV
Ing
nieur�D�veloppement�CAO

t�l : 06 08 54 73 48

mail :�ciprian.teodorov@gmail.com
www.teodorov.ro



--
best,
Eliot