ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> opendarwin-discuss
opendarwin-discuss
Strange things in math.h under Intel OSX
by Max Persson other posts by this author
May 19 2006 4:06AM messages near this date
Re: I have just installed OpenDarwin on my Wallstreet | Re: Strange things in math.h under Intel OSX
Hi there,

It seems like Apple may have done some mistakes in their port
of the standard c library (which I seriously doubt). I bumped in to
this problem when I compiled
some tests for OpenEXR (under Intel OS X on a MacBook Pro). It says
that a function from math.h is invalid. As you may know, there are two
versions of some of the stuff in the std-c library, one for ppc and
the other for i386. math.h is one of them. There is a macro/function
called isnan() that determines if a float is a number or not, and it
was here I bumped into the strange things. I opened up both versions
of math.h and compared the implementation of the isnan() macro...


Here is the one in the i386 math.h:

#define isnan(x)               (       sizeof (x) == sizeof(float )    ?       __isnanf(x)  
          :       sizeof (x) == sizeof(double)    ?       __isnand(x)     
        :       __isnan (x))


And here is the one from the ppc math.h:

#define      isnan( x )         ( ( sizeof ( (x) ) == sizeof(double) )
?                                        __isnand ( (double)(x) ) :
                                                ( sizeof ( (x) ) == sizeof( float) ) ?
                                       __isnanf ( (float)(x) ) :
                                             __isnan  ( ( long double )(x) ) )


The one that is used in my particular case is the first of them as I
am on a i386 OS X. What I have learnt, you always put surrounding
parenthesis in macros to prevent them from failing due to strange
input. That is NOT the case in the i386 math.h (along with a couple of
other macros there too).


The input argument in the call to the isnan() macro is in this case:

isnan(pf[y][x])


What I belive is happening here is that the macro gets very confused
with the array access here, because of the missing input parenthesis
in the macro. This is what I got from the compiler to further
strengthen the theory:

testTiledCompression.cpp:59: error: expected unqualified-id before 'sizeof'
testTiledCompression.cpp:59: error: expected `)' before 'sizeof'


But enough talking about this. I do not look for a quick fix here,
what I'm concerned about is that Apple may have delivered a faulty
math.h file for the Intel version of OS X. What do you think about it?


Kind regards,
Max Persson

MFX AB, Sweden
www.mfx.se
_______________________________________________
Discuss mailing list
Discuss@[...].org
http://www.opendarwin.org/mailman/listinfo/discuss
Thread:
Max Persson
Shantonu Sen

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved