Menu

#428 endianness problem with FIX_ENDIAN_INT32_INPLACE

2.0 Series
closed-fixed
General (291)
5
2005-12-15
2005-11-30
Paul Wise
No

Copied from here:
http://forums.winamp.com/showthread.php?postid=1813470#post1813470

Explanation of the endianness problem: util.h wasn't
detecting the endianness correctly when defining
FIX_ENDIAN_INT32_INPLACE. On linux you detect this by
including endian.h and testing if BYTE_ORDER ==
LITTLE_ENDIAN. I'm not sure how portable this is, so
there is no proper patch yet. A quick grep reveals a
few places test for __BIG_ENDIAN__, most of them are
not relevant because they are in code that is compiled
using the Win32 cross compiler.

Discussion

  • Amir Szekely

    Amir Szekely - 2005-12-09

    Logged In: YES
    user_id=584402

    How about the attached patch?

     
  • Amir Szekely

    Amir Szekely - 2005-12-09

    proposed changes

     
  • Amir Szekely

    Amir Szekely - 2005-12-09
    • assigned_to: nobody --> kichik
     
  • Paul Wise

    Paul Wise - 2005-12-12

    Logged In: YES
    user_id=35028

    I won't be able to test it until I upload a new version.
    Anyway, this was with GCC 4.0, so your comments in the patch
    don't apply and I'm not sure how portable the test you used
    is. Perhaps the test could be something like this:

    #ifndef __BIG_ENDIAN__
    #include <endian.h>
    #endif
    int main() {

    #ifdef __BIG_ENDIAN__

    return 0;

    #else
    return BYTE_ORDER == BIG_ENDIAN;
    #endif

    }

    There is also PDP_ENDIAN, but those computers are rare and
    old, no point targeting them.

     
  • Amir Szekely

    Amir Szekely - 2005-12-13

    Logged In: YES
    user_id=584402

    I read somewhere that only GCC 4 defines those, but you're
    right, it doesn't either. Using endian.h is not portable
    enough. It doesn't, for example, work on sparc-solaris1 on
    SF CF. Do you see any problem with my test?

     
  • Paul Wise

    Paul Wise - 2005-12-14

    Logged In: YES
    user_id=35028

    OK, how about you apply it and we see how well it works out when I upload the next release. I'll get a list of endianness for all of Debian's platforms and compare that to what your test detects (I'll figure out a way of outputting the test results). Hopefully it will work and correctly detect the endianness for all platforms.

     
  • Amir Szekely

    Amir Szekely - 2005-12-15
    • status: open --> closed-fixed
     
  • Amir Szekely

    Amir Szekely - 2005-12-15

    Logged In: YES
    user_id=584402

    OK, it'll be released along with 2.12 this weekend. The test
    should print its result as part of the scons log. It should
    like the following:

    Checking for __BIG_ENDIAN__... no

     

Log in to post a comment.