Thank you :)
I've tested a bit more and it all seems to work :) Jna is great :)
For correctness sake, this was what i did:
protected static void setAlignment(Structure c ){
((Memory)(c.getPointer())).align(4);
}
and then for instance on Vector
SIMDx86Vector v =(SIMDx86Vector) Structure.newInstance(SIMDx86Vector.class);
SIMDx86Factory.setAlignment(v);
return v;
Is this correct way to do it ? :)
Thank you again for your fast and unvaluable help
________________________________
From: Timothy Wall <twal...@dev.java.net>
To: use...@jna.dev.java.net
Sent: Tuesday, December 9, 2008 3:18:39 AM
Subject: Re: [jna-users] setting structure alignment
You'll need to explicitly ensure that the memory allocated for the structure is
aligned, using Memory.align(4).
Hello.
I'm currently working on creating bindings for libSIMDx86
(http://simdx86.sourceforge.net/).
Some structures are aligned to the 16th byte for instance
typedef struct SIMDx86Vector
{
float x, y, z;
float __SIMD_pad__; /* Padding to 16th byte for SIMD operations (3DNow!/SSE)
*/
} SIMDx86Vector ALIGNED;
Where aligned is
#if defined(__GNUC__)
#define ALIGNED __attribute__(( aligned(16) ))
#elif defined(_MSC_VER)
#define ALIGNED __declspec(align(16))
#endif
My implementation is as follows
public class SIMDx86Vector extends Structure {
float x, y, z;
float __SIMD_pad__; /* Padding to 16th byte for SIMD operations (3DNow!/SSE)
*/
public SIMDx86Vector allocate(){
return (SIMDx86Vector) Structure.newInstance(this.getClass());
}
}
My question is do i need to do anything more on the Java side?
All the best and thanks in advance