need to call native function that returns 128bit value with JNA (objc_msgSend)

137 Views Asked by At

I'm writting a JNA binding for ObjectiveC and I have a problem:

[NSValue sizeValue] returns an NSSize structure.

Normally you would think to use objc_msgSend_stret but when the structure is small enough it is returned in registers so you must use just objc_msgSend in this case. NSSize is two floats in 32bit mode, so that's basically a long. No problem. I use Function.invokeLong() and then grab the pointer to my structure and write the long to the two float storage space. But in 64bit mode it's two doubles which is 128bits. I used GCC --save-temps and sure enough the returned structure is in xmm0 and xmm1. So objc_msgSend must be used.

JNA doesn't have a Function.invokeLongDouble() or Function.invokeLongLong() (128bit return value)

What do I do???

See this link for more details on objc_msgSend and structures: http://www.sealiesoftware.com/blog/archive/2008/10/30/objc_explain_objc_msgSend_stret.html

1

There are 1 best solutions below

0
On

I found a workaround.

[NSValue getValue:void*] will work. It's places the contents into the pointer.