Re: [Sablevm-developer] powerpc port status
Brought to you by:
egagnon
From: David P. B. <db...@CS...> - 2002-12-13 22:18:46
|
I found the source of the problem: If you have: int v =3D 0x1234ABCD; On x86: (unsigned char) v and (unsigned char*) &v are both equivalent. Both will return byte 0 of the word which 0xCD which is correct. On PowerPC (big endian) (unsigned char) v and *((unsigned char*) &v) are different. The first one will return correctly byte 3 that is 0xCD. But the 2nd one returns byte 0 which is 0x12 on a big endian. Accessing the value simply with: params[0].jint =3D result[0].jint; instead of params[0].jint =3D *((jboolean *) &result[0]); =20 and this should work if the field jint is always located at the beginning= of the union in memory. The other possible fix is to take byte at offset 3 for big endian machines: *(((unsigned char*) &v) + 3) this does not rely on the layout of the union in memory. David On Thu, Dec 12, 2002 at 08:14:46PM -0500, Etienne M. Gagnon wrote: > On Thu, Dec 12, 2002 at 08:09:23PM -0500, David Paul BELANGER wrote: > > Hi, > >=20 > > I got HelloWorld to work on sablevm 1.0.5! >=20 > This is really great! So, were there any endianness problem you had to= fix? >=20 > Etienne >=20 > --=20 > Etienne M. Gagnon http://www.info.uqam.ca/~egagnon/ > SableVM: http://www.sablevm.org/ > SableCC: http://www.sablecc.org/ --=20 --- David B=E9langer Graduate Student School of Computer Science McGill University Office: MC226 Web page: http://www.cs.mcgill.ca/~dbelan2/ Public key: http://www.cs.mcgill.ca/~dbelan2/public_key.txt |