On Wed, Oct 05, 2011 at 10:50:56AM +0200, Émeric Maschino wrote: > 2011/10/4 Mike Hommey <m...@glandium.org>: > > On Tue, Oct 04, 2011 at 10:20:16PM +0200, > > > m0 is a 32-bit value, it needs 32-bits alignment. m1 is 16-bits, 16-bits > > alignment, etc. Overall, the struct only requires 32-bits alignment. > > Reading http://en.wikipedia.org/wiki/Data_structure_alignment, I > thought that gcc was padding the internal data of a structure so that > they are aligned. Furthermore, isn't nsID internal data nevertheless > packed on 16 bytes after compilation (it is 4+2+2+8 = 16 bytes before > compilation)? > > If "explicit" 64-bit alignment is still required, do we need to add > dummy padding data to align nsID internal data? Such as (with > alignment recommendations taken from > http://software.intel.com/en-us/articles/data-alignment-when-migrating-to-64-bit-intel-architecture/): > > struct nsID { > PRUint32 m0; > PRUint16 m1; > PRUint16 padding[1]; // 2 bytes for m2 to be aligned on a 4-byte boundary > (*) > PRUint16 m2; > PRUint8 m3[8]; > PRUint8 padding[6]; // 6 bytes to make total size of nsID 24 bytes > };
The problem is not the alignment of m2, the problem is the alignment of the whole struct, which has a requirement of 32-bits. Which means a struct nsID can end up at 0x0, 0x4, 0x8, or 0xc. When it's at 0x4 or 0xc, it can't be casted to a 64-bits word, because that's not 64-bits aligned. There are two solutions: make sure struct nsIDs are 64-bits aligned, or change the Equals function to use 2 32 bits words comparisons. Mike -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org