Opterons are NOT big-endian! :)

I’ve been fiddling with SDL in my new computer, and been getting continuously
strange results… inexplicable crashes, odd error messages, things not
working that should just plain work, etc. I started probing deep into
SDL_mixer to figure out why it didn’t like WAV files anymore, and at last
noticed something completely wrong: SDL thinks my computer is big-endian!

The computer in question is a dual Opteron-242, and opterons are x86
compatible… just to make absolutely sure, I compared the ordering of
0xDEADBEEF on an Athlon-32 system with the ordering on the Opteron, and of
course they were the same. I would suggest adding x86_64 to the list of
defines triggering SDL to define SDL_LITTLE_ENDIAN in SDL_byteorder.h.

Tyler Montbriand wrote:

I would suggest adding x86_64 to the list of
defines triggering SDL to define SDL_LITTLE_ENDIAN in SDL_byteorder.h.

Autoconf 2.53 has AC_C_BIGENDIAN which works also for cross-compiling.
There’s no need to hardwire any architectures.–
Christian
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040120/bfb6fc58/attachment.pgp

That would force people to use Autoconf, though, so that’s no good for
non-UNIX platforms.On Tuesday 20 January 2004 09:53 pm, Christian Biere wrote:

Autoconf 2.53 has AC_C_BIGENDIAN which works also for cross-compiling.
There’s no need to hardwire any architectures.

Tyler Montbriand wrote:> On Tuesday 20 January 2004 09:53 pm, Christian Biere wrote:

Autoconf 2.53 has AC_C_BIGENDIAN which works also for cross-compiling.
There’s no need to hardwire any architectures.
That would force people to use Autoconf, though, so that’s no good for
non-UNIX platforms.

Too bad. I guess you meant non-POSIX. There’s still no need to hardwire
any values and as your example shows it doesn’t work. BTW, I didn’t say
that you have to use Autoconf, just that there’s a way to detect the
endianness during compiling. You can write such a check yourself, it’s
not patented. So, I’d rather have the nice platforms handled nicely and
the not-so-nice platforms might be hardwired. I’d also suggest to do
a runtime check in SDL_Init() because it takes a very few CPU cycles
to detect a compilation failure but it might take a lot longer to
figure out what went wrong. Especially, if your software isn’t
compiled by a skilled developer but a simple user and especially
because/if SDL wants(?) to rely on hardcoded values.

Nonetheless, the check for x86_64 is already in CVS.


Christian
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040120/c4cee471/attachment.pgp

This is fixed in CVS (has been for awhile) for linux on amd64. Are you
using Win64?

–ryan.On Tue, 2004-01-20 at 21:23, Tyler Montbriand wrote:

I’ve been fiddling with SDL in my new computer, and been getting continuously
strange results… inexplicable crashes, odd error messages, things not
working that should just plain work, etc. I started probing deep into
SDL_mixer to figure out why it didn’t like WAV files anymore, and at last
noticed something completely wrong: SDL thinks my computer is big-endian!

I am using Gentoo linux for AMD64. It’s package manager doesn’t have an
ebuild for a more recent version… I shall see if I can change that.On Wednesday 21 January 2004 10:51 am, Ryan C. Gordon wrote:

SDL thinks my computer is big-endian!

This is fixed in CVS (has been for awhile) for linux on amd64. Are you
using Win64?

I am using Gentoo linux for AMD64. It’s package manager doesn’t have an
ebuild for a more recent version… I shall see if I can change that.

I filed a bug report on this at bugs.gentoo.org awhile ago. SDL 1.2.6
(which has the the fix) is masked on amd64.

“ACCEPT_KEYWORDS=x86 emerge libsdl” will get it done in the short term.

–ryan.

To follow up, Gentoo just fixed this in Portage:

http://bugs.gentoo.org/show_bug.cgi?id=37143

–ryan.On Thu, 2004-01-22 at 14:28, Ryan C. Gordon wrote:

I am using Gentoo linux for AMD64. It’s package manager doesn’t have an
ebuild for a more recent version… I shall see if I can change that.

I filed a bug report on this at bugs.gentoo.org awhile ago. SDL 1.2.6
(which has the the fix) is masked on amd64.