You'll need to explicitly ensure that the memory allocated for the
structure is aligned, using Memory.align(4).
On Dec 8, 2008, at 9:08 PM, Rui Caridade wrote:
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