Wine and endianness

GOUJON Alexandre ale.goujon at gmail.com
Mon Aug 1 01:31:50 CDT 2011


On 07/31/2011 08:12 PM, Stefan Dösinger wrote:
<snip>
> With the bitfields I'm not sure about stuff like endianess. My gut feeling
> would be to use bitmasks and shifts to separate a DWORD instead, but bitfields
> certainly look nicer. Beyond that endianess is a somewhat academic
> consideration with an API that's available on x86 only. So I'd say keep the
> bitfields.
<snip>

Sorry to disturb your conversation but the subject is worth discussing.

I'm currently trying to add UDF support on wine based on Steven Wallace 
work.
Quoting the specification : "On the media the UDF structures are stored 
little endian" as windows API.
But wine is not limited on x86 so what's the rule ?
Currently, my code is

     int i = 1;
     char *p = (char *)&i;
     BOOL isBigEndian = p[0]==1;

     /* Tag location (Uint32) at offset 12, little-endian */
     *offs  = (bloc[20+0] & 0xFF) << ( isBigEndian ?  0 : 24);
     *offs += (bloc[20+1] & 0xFF) << ( isBigEndian ?  8 : 16);
     *offs += (bloc[20+2] & 0xFF) << ( isBigEndian ? 16 :  8);
     *offs += (bloc[20+3] & 0xFF) << ( isBigEndian ? 24 :  0);

Is it correct ?
Any thoughts ?

Thanks



More information about the wine-devel mailing list