Fix Endianess detection on Linux.

Some platforms like MIPS can come either in little or
in big endian. Therefore a static decision based on the
system used is invalid. The header file endian.h should
be used for systems on which it is available. At the moment
this is at least Linux.

Patch by Frank Neufingerl <fneufingerl@psi.de>

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@51 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
Moritz Bunkus 2010-03-23 13:35:44 +00:00
parent 22a45d1ac3
commit a65901063d

View File

@ -36,6 +36,14 @@
#ifndef LIBEBML_CONFIG_H #ifndef LIBEBML_CONFIG_H
#define LIBEBML_CONFIG_H #define LIBEBML_CONFIG_H
#if defined(__linux__)
#include <endian.h>
#if __BYTE_ORDER == __LITTLE_ENDIAN
#undef WORDS_BIGENDIAN
#elif __BYTE_ORDER == __BIG_ENDIAN
#define WORDS_BIGENDIAN 1
#endif
#else
// automatic endianess detection working on GCC // automatic endianess detection working on GCC
#if !defined(WORDS_BIGENDIAN) #if !defined(WORDS_BIGENDIAN)
#if (defined (__arm__) && ! defined (__ARMEB__)) || defined (__i386__) || defined (__i860__) || defined (__ns32000__) || defined (__vax__) || defined (__amd64__) || defined (__x86_64__) #if (defined (__arm__) && ! defined (__ARMEB__)) || defined (__i386__) || defined (__i860__) || defined (__ns32000__) || defined (__vax__) || defined (__amd64__) || defined (__x86_64__)
@ -47,6 +55,7 @@
#undef WORDS_BIGENDIAN // for my testing platform (x86) #undef WORDS_BIGENDIAN // for my testing platform (x86)
#endif #endif
#endif // not autoconf #endif // not autoconf
#endif
#define LIBEBML_NAMESPACE libebml #define LIBEBML_NAMESPACE libebml
#if defined(NO_NAMESPACE) // for older GCC #if defined(NO_NAMESPACE) // for older GCC