How about this?

https://github.com/OpenImageIO/oiio/pull/2415 
<https://github.com/OpenImageIO/oiio/pull/2415>



> On Nov 21, 2019, at 5:34 PM, Shane Ambler <free...@shaneware.biz> wrote:
> 
> G'day Larry
> 
> I am just passing this on from a freebsd ports bug report.
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242134
> 
> In src/libutil/ustring.cpp oiio uses _LIBCPP_BIG_ENDIAN which looks to
> be an llvm libc++ only definition. Should this be wrapped in a LIBCPP
> only testing?
> 
> So it seems we want a reliable endian test - while clang defines
> __BIG_ENDIAN__ or __LITTLE_ENDIAN__ I don't see that in gcc.
> 
> One solution could be to use a custom definition with cmakes
> TEST_BIG_ENDIAN()
> 
> As we already use boost there is boost/detail/endian.hpp
> 
> There is the system header sys/endian.h which has
> 
> #define       _LITTLE_ENDIAN  1234    /* LSB first: i386, vax */
> #define       _BIG_ENDIAN     4321    /* MSB first: 68000, ibm, net */
> #define       _BYTE_ORDER     _LITTLE_ENDIAN
> 
> So you could use
> 
> #if _BYTE_ORDER == _BIG_ENDIAN
> ...
> 
> 
> When using clang/gcc the compiler defines provide a similar choice.
> Would this also work with MS/Intel compilers?
> 
> # if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
> 
> 
> As a test --
> 
> % g++ -dM -E -x c++ /dev/null | grep ENDIAN
> #define __ORDER_LITTLE_ENDIAN__ 1234
> #define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__
> #define __ORDER_PDP_ENDIAN__ 3412
> #define __ORDER_BIG_ENDIAN__ 4321
> #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
> 
> % clang++ -dM -E -x c++ /dev/null | grep ENDIAN
> #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
> #define __LITTLE_ENDIAN__ 1
> #define __ORDER_BIG_ENDIAN__ 4321
> #define __ORDER_LITTLE_ENDIAN__ 1234
> #define __ORDER_PDP_ENDIAN__ 3412
> 
> % clang++ -target powerpc64-pc-bsd-elf -mcpu=ppc64 -dM -E -x c++
> /dev/null | grep ENDIAN
> #define _BIG_ENDIAN 1
> #define __BIG_ENDIAN__ 1
> #define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
> #define __ORDER_BIG_ENDIAN__ 4321
> #define __ORDER_LITTLE_ENDIAN__ 1234
> #define __ORDER_PDP_ENDIAN__ 3412
> 
> -- 
> FreeBSD - the place to B...Software Developing
> 
> Shane Ambler
> 
> _______________________________________________
> Oiio-dev mailing list
> Oiio-dev@lists.openimageio.org
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
> 

--
Larry Gritz
l...@larrygritz.com




_______________________________________________
Oiio-dev mailing list
Oiio-dev@lists.openimageio.org
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to