From: <Mic...@us...> - 2010-03-05 21:18:33
|
Revision: 4592 http://teem.svn.sourceforge.net/teem/?rev=4592&view=rev Author: MichelKitware Date: 2010-03-05 21:18:27 +0000 (Fri, 05 Mar 2010) Log Message: ----------- ENH: modified endianness for Macs. Modified Paths: -------------- NrrdIO/trunk/CMakeLists.txt NrrdIO/trunk/teemEndian.h Modified: NrrdIO/trunk/CMakeLists.txt =================================================================== --- NrrdIO/trunk/CMakeLists.txt 2010-03-02 22:51:58 UTC (rev 4591) +++ NrrdIO/trunk/CMakeLists.txt 2010-03-05 21:18:27 UTC (rev 4592) @@ -47,11 +47,11 @@ ADD_DEFINITIONS(-DTEEM_BUILD=1) # Set compiler flags for endian-ness. -IF(CMAKE_WORDS_BIGENDIAN) - ADD_DEFINITIONS(-DTEEM_ENDIAN=4321) -ELSE(CMAKE_WORDS_BIGENDIAN) - ADD_DEFINITIONS(-DTEEM_ENDIAN=1234) -ENDIF(CMAKE_WORDS_BIGENDIAN) +#IF(CMAKE_WORDS_BIGENDIAN) +# ADD_DEFINITIONS(-DTEEM_ENDIAN=4321) +#ELSE(CMAKE_WORDS_BIGENDIAN) +# ADD_DEFINITIONS(-DTEEM_ENDIAN=1234) +#ENDIF(CMAKE_WORDS_BIGENDIAN) # Set compiler flags for 32 or 64 bit architecture (based on the size # of a void pointer). Modified: NrrdIO/trunk/teemEndian.h =================================================================== --- NrrdIO/trunk/teemEndian.h 2010-03-02 22:51:58 UTC (rev 4591) +++ NrrdIO/trunk/teemEndian.h 2010-03-05 21:18:27 UTC (rev 4592) @@ -30,11 +30,28 @@ */ #ifndef TEEM_ENDIAN -# error TEEM_ENDIAN not defined, see architecture-specific .mk file or check compilation options -#elif TEEM_ENDIAN == 1234 -# /* okay, its little endian */ -#elif TEEM_ENDIAN == 4321 -# /* okay, its big endian */ + +/* what byte order */ +/* All compilers that support Mac OS X define either __BIG_ENDIAN__ or +__LITTLE_ENDIAN__ to match the endianness of the architecture being +compiled for. This is not necessarily the same as the architecture of +the machine doing the building. In order to support Universal Binaries on +Mac OS X, we prefer those defines to decide the endianness. +On other platform, we use the result of the TRY_RUN. */ +#if !defined(__APPLE__) +#if @CMAKE_WORDS_BIGENDIAN@ +#define TEEM_ENDIAN 4321 #else +#define TEEM_ENDIAN 1234 +#endif +#else +#if defined(__BIG_ENDIAN__) +#define TEEM_ENDIAN 4321 +#else +#define TEEM_ENDIAN 1234 +#endif +#endif + +#else # error TEEM_ENDIAN not set to 1234 (little endian) or 4321 (big endian), see architecture-specific .mk file or check compilation options #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |