Message172484
I think it's not enough as some platforms prefix/suffix the macros with dashes. The values must be compared to BYTE_ORDER iff the macro is defined. too. I've checked some machines of the Snakebite network and came up with this macro cascade:
/*
* The endianess (byte order) can be defined in several ways. Some platforms
* define either LITTLE_ENDIAN or BIG_ENDIAN while other platforms define
* both and require comparison to BYTE_ORDER. Sometimes the macros are
* prefixed or suffixed with one or two dashes, too. SPAM seems to be an
* alias of __SPAM an all platforms that have SPAM.
* The endian check can't be handled in a configure step as it would break
* Apple's universal builds.
*/
#if defined(__BYTE_ORDER)
# if defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN
# define PY_IS_BIG_ENDIAN 1
# elif defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN
# define PY_IS_LITTLE_ENDIAN 1
# else
# error "__BYTE_ORDER not in (__BIG_ENDIAN, __LITTLE_ENDIAN)"
# endif
#elif defined(__BIG_ENDIAN) && !defined(__LITTLE_ENDIAN)
# define PY_IS_BIG_ENDIAN 1
#elif defined(__LITTLE_ENDIAN) && !defined(__BIG_ENDIAN)
# define PY_IS_LITTLE_ENDIAN 1
/* and know the same block with just one dash as prefix */
#elif defined(_BYTE_ORDER)
# if defined(_BIG_ENDIAN) && _BYTE_ORDER == _BIG_ENDIAN
# define PY_IS_BIG_ENDIAN 1
# elif defined(_LITTLE_ENDIAN) && _BYTE_ORDER == _LITTLE_ENDIAN
# define PY_IS_LITTLE_ENDIAN 1
# else
# error "_BYTE_ORDER not in (_BIG_ENDIAN, _LITTLE_ENDIAN)"
# endif
#elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
# define PY_IS_BIG_ENDIAN 1
#elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
# define PY_IS_LITTLE_ENDIAN 1
/* extra apple */
#elif defined(__APPLE__)
# if defined(__BIG_ENDIAN__)
# define PY_IS_BIG_ENDIAN 1
# elif defined(__LITTLE_ENDIAN__)
# define PY_IS_LITTLE_ENDIAN 1
# else
# error "__APPLE__ but neither __BIG_ENDIAN__ nor __LITTLE_ENDIAN__"
# endif
/* Windows */
#elif defined(WIN32)
# define PY_IS_LITTLE_ENDIAN 1
#else
# error "Unable to detect endianess"
#endif |
|
Date |
User |
Action |
Args |
2012-10-09 15:07:42 | christian.heimes | set | recipients:
+ christian.heimes, pitrou, ned.deily, serhiy.storchaka |
2012-10-09 15:07:42 | christian.heimes | set | messageid: <1349795262.04.0.757051467156.issue16166@psf.upfronthosting.co.za> |
2012-10-09 15:07:42 | christian.heimes | link | issue16166 messages |
2012-10-09 15:07:41 | christian.heimes | create | |
|