Re: [Boost-bugs] [Boost C++ Libraries] #10505: Use gcc/clang built-in endianity macros (too)

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #10505: Use gcc/clang built-in endianity macros (too)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-07-02 21:27:39


#10505: Use gcc/clang built-in endianity macros (too)
---------------------------------+----------------------
  Reporter: Jan Hudec <bulb@…> | Owner: grafik
      Type: Bugs | Status: reopened
 Milestone: To Be Determined | Component: predef
   Version: Boost 1.56.0 | Severity: Problem
Resolution: | Keywords:
---------------------------------+----------------------

Comment (by grafik):

 Replying to [comment:6 anonymous]:
> The current version fixes the part of the problem that the checks on in
 `endian.h` lines 72-99 now won't trigger in the errorneous Bionic libc
 case when `_BYTE_ORDER` is defined, but `_LITTLE_ENDIAN` is not.
>
> However, the gcc 4.6 toolchain (which we still need, because binaries
 built with newer ones don't work on Android < 2.3 and our code otherwise
 works on 2.1 just fine) does //not// define `__LITTLE_ENDIAN__`, so the
 fallbacks further down on lines 106 and 124 don't trigger on x86 (on arm
 the `__ARMEL__` define is found).
>
> So I would still suggest adding the test for the older gcc macros:
>
> {{{
> #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
> defined(__ORDER_LITTLE_ENDIAN__) &&
 defined(__ORDER_PDP_ENDIAN__)
> # if (__BYTE_ORDER == __ORDER_BIG_ENDIAN__)
> # undef BOOST_ENDIAN_BIG_BYTE
> # define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_AVAILABLE
> # endif
> # if (__BYTE_ORDER == __ORDER_LITTLE_ENDIAN__)
> # undef BOOST_ENDIAN_LITTLE_BYTE
> # define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
> # endif
> # if (__BYTE_ORDER == __ORDER_PDP_ENDIAN__)
> # undef BOOST_ENDIAN_LITTLE_WORD
> # define BOOST_ENDIAN_LITTLE_WORD BOOST_VERSION_NUMBER_AVAILABLE
> # endif
> #endif
> }}}
>
> Since things depend on these in the gcc-provided headers, they should be
 reliable in gcc and clang.
>
> Sorry, I missed the question on new year's eve.
>
> PS: I wanted to make the line references to github, but trac won't
 accept it.

 I still how your code above works. You are checking for
 `defined(__BYTE_ORDER__)`. But are actually checking for `__BYTE_ORDER`
 equality to the `__ORDER_*` macros. Is the whole thing supposed to be a
 third alternative in the GNU libc branch? As in `__BYTE_ORDER__` should
 get used if neither `__BYTE_ORDER` nor `_BYTE_ORDER` are defined?

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10505#comment:7>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC