* On 20 Jan 2015, Ben Boeckel wrote: 
> > -    unsigned char digest[16];
> > +    union {
> > +      unsigned char charval[16];
> > +      unsigned int intval;
> > +    } digest;
> 
> How does this work with big endian versus little endian?

BE and LE may pack structs differently, but I believe members of a
union should have the same alignment even if of differing size.  This
should be safe for byte transposition between a char[] and an int.  (You
can't port the cache file across endianness, but that's true for other
reasons.)

This will cause a different end of the char[] to transpose into the int
on BE vs LE systems, but that's OK within the same CPU so long as the
hash algorithm is fairly well distributed across the 16 bytes.

-- 
David Champion • d...@bikeshed.us

Reply via email to