Comment 41 for bug 1995274

Revision history for this message
In , Mark J. Wielaard (3y9m2vcw-ll9d-fkzsxrqg) wrote :

(In reply to Lubos Lunak from comment #38)
> > imho to use #if defined(VG_BIGENDIAN) instead of doing a runtime trick.
>
> Updated.

Thanks, looks good.

> > Is the big endian variant correct?
>
> I don't have actual big endian HW, but I think it is. The input is 3-byte
> bigendian that needs byte-by-byte handling, not the output.

It is a little tricky to know how to interpret endianness for these "3-byte" values.
But what I mean is that I believe others interpret this as a 4-byte value where the 4th byte is zero.
Which doesn't matter for little endian, but does for big endian.
With the assumption of the 4th byte is zero the code would look like:

   c1 = ML_(img_get_UChar)(c->sli.img, c->sli_next);
   c2 = ML_(img_get_UChar)(c->sli.img, c->sli_next+1);
   c3 = ML_(img_get_UChar)(c->sli.img, c->sli_next+2);
   c4 = 0;
   c->sli_next += 3;
#if defined(VG_BIGENDIAN)
   return c1 << 24 | c2 << 16 | c3 << 8 | c4;
#else
   return c1 | c2 << 8 | c3 << 16 | c4 << 24;
#endif