[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnash-dev] Porting gnash to Sun Solaris x86, endianness detection i
Re: [Gnash-dev] Porting gnash to Sun Solaris x86, endianness detection issues.
Tue, 17 Apr 2007 20:34:51 -0700
> Sorry, I don't understand what changes you are suggesting. That code
> seems to be in tu_types.h already.
He wasn't suggesting that you adopt his hack. I advised him to do a
cheap hack to get it running, then let the maintainers figure out the
> Can you suggest a way to automatically detect endianness on your box
> so that we can make a patch that will also work everywhere else?
My suggestion is that the code should not be depending on host byte
order. It should just do the right thing regardless of the host byte
order. We did this at Cygnus and it simplified a lot of code. Rather
than picking up a field and then conditionally trying to "swap" it,
just pick it up correctly, based on the field's big/little endianness:
unsigned char buf;
m_read (buf, 4, m_data)
u = buf + // pointer points to the "little" end
(buf << 8) +
(buf << 16) +
(buf << 24); // "big" end is a few bytes away
Then you can throw away all the conditional compilation stuff. We measured
the speed at Cygnus and it made <1% difference (plus or minus), e.g. in
the linker, which reads and writes a LOT of binary fields.