Re: 32 bit applet on 64 bit Java?
On 11/10/2010 04:23 AM, John Smith wrote:
It seems that some pointers are casted to int which are 2 bytes IIRC.
On most systems, sizeof(int) == 4 (most 64-bit compilers keep
sizeof(int) equal to 4). sizeof(long) is problematic in C, some 64-bit
compilers keep it 4, while others make it 8. sizeof(void*) would be 8 in
64-bit computers, though.
Should I change to:
---------------------------------------------------------------------
JAVA:
public static native void jni_SetMem(long i, byte abyte0[], long j, long
k);
C:
SetMem(JNIEnv *pEnv, jclass jObj, jint i_pDest, jbyteArray jArr, jlong
iDestOffset, jlong iSize) //maybe I could leave the size to int, but id
doesn't matter to much
Strictly speaking, you want to move to size_t for the iSize, which will
still be sizeof(void*), so yes, moving to long might be preferable.
You'll also probably want checking to make sure that the Java long
values are valid memory addresses for the processor you are on.
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth