[Insight-developers] found sane.c offending line

Michel Audette michel.audette at kitware.com
Fri Feb 26 12:49:11 EST 2010


Hi gents,

I'll make the change  with if defined(__APPLE__) and commit it today.

Cheers,

Michel
On Fri, Feb 26, 2010 at 9:13 AM, Gordon L. Kindlmann <glk at uchicago.edu> wrote:
> Hello,
>
> Endian-ness and qnan-hi-bit-ness are separate aspects of hardware, and right
> now the endien-ness is being correctly handled, and explicitly checked by
> airSanity().
>
> In any case,, "if defined(__APPLE__)" seems to be a legit way of blocking
> out this code for now.
>
> Gordon
>
> On Feb 26, 2010, at 9:24 AM, Bradley Lowekamp wrote:
>
>> I believe the solution to the problem involves using code which is similar
>> to that in itkConfigure.h.in into teemEndian.c.
>>
>> From NrrdIO CMakeList:
>>
>> # 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)
>>
>> from teemEndian.h:
>> #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 */
>> #else
>> #  error TEEM_ENDIAN not set to 1234 (little endian) or 4321 (big endian),
>> see architecture-specific .mk file or check compilatio\
>> n options
>> #endif
>>
>> From itkConfigure.h.in:
>> /* 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__)
>>  #cmakedefine CMAKE_WORDS_BIGENDIAN
>>  #ifdef CMAKE_WORDS_BIGENDIAN
>>    #define ITK_WORDS_BIGENDIAN
>>  #endif
>> #elif defined(__BIG_ENDIAN__)
>>  #define CMAKE_WORDS_BIGENDIAN
>>  #define ITK_WORDS_BIGENDIAN
>> #endif
>>
>>
>>
>>>
>>>
>>> Thanks for investigating this.
>>>
>>> If there isn't a way for the preprocessor to know "am I a cross-
>>> compiled mac", for the time being we can just use whatever pre-
>>> processor means is used to say "am I a mac", and then fix it a more
>>> refined way later.
>>>
>>> Gordon
>>>
>>> On Feb 25, 2010, at 3:54 PM, Michel Audette wrote:
>>>
>>>> Hi Brad,
>>>>
>>>> as Gordon suspected, the line in sane.c which was causing your tests
>>>> to fail is the one with #ifdef /#endif section within
>>>>  if (!( airFP_QNAN == airFPClass_f(AIR_NAN)
>>>>        && airFP_QNAN == airFPClass_f(AIR_QNAN)
>>>> #if !defined(_MSC_VER) || _MSC_VER < 1400 /* VS2005 converts SNAN to
>>>> QNAN */
>>>>        && airFP_SNAN == airFPClass_f(AIR_SNAN)
>>>> #endif
>>>>        && airFP_QNAN == airFPClass_d(AIR_NAN)
>>>>        && airFP_QNAN == airFPClass_d(AIR_QNAN) )) {
>>>>
>>>>   return airInsane_AIR_NAN;
>>>>  }
>>>>
>>>> On the cross-compiled Mac, I did a printf:
>>>> airFP_QNAN 2 airFPClass_f(AIR_NAN) 2
>>>> airFP_QNAN 2 airFPClass_f(AIR_QNAN) 2
>>>> !ifdef airFP_SNAN 1 airFPClass_f(AIR_NAN) 2
>>>> airFP_QNAN 2 airFPClass_f(AIR_NAN) 2
>>>> airFP_QNAN 2 airFPClass_f(AIR_QNAN) 2
>>>>
>>>> On Linux, I get:
>>>> airFP_QNAN 2 airFPClass_f(AIR_NAN) 2
>>>> airFP_QNAN 2 airFPClass_f(AIR_QNAN) 2
>>>> !ifdef airFP_SNAN 1 airFPClass_f(AIR_NAN) 1
>>>> airFP_QNAN 2 airFPClass_f(AIR_NAN) 2
>>>> airFP_QNAN 2 airFPClass_f(AIR_QNAN) 2
>>>>
>>>> Question is then: what is an appropriate preprocessor flag for cross-
>>>> compiled Macs?
>>>>
>>>> Best wishes,
>>>>
>>>> Michel
>>>> --
>>>> Michel Audette, Ph.D.
>>>> R & D Engineer,
>>>> Kitware Inc.,
>>>> Chapel Hill, N.C.
>>>>
>>>
>>
>
>



--
Michel Audette, Ph.D.
R & D Engineer,
Kitware Inc.,
Chapel Hill, N.C.



-- 
Michel Audette, Ph.D.
R & D Engineer,
Kitware Inc.,
Chapel Hill, N.C.


More information about the Insight-developers mailing list