Hi James, hi all,

I've re-encountered this problem (after I had assumed it doesn't happen with 
clang/llvm)
in a project that's using particles.  The culprit here was sqrt/sqrtf.

I would like to propose that we remove these wrappers for OS X >= 10.7:

Index: include/osg/Math
===================================================================
--- include/osg/Math    (revision 12822)
+++ include/osg/Math    (working copy)
@@ -38,14 +38,17 @@
         #define APPLE_PRE_10_2
     #endif
 #endif
+#if !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MIN_REQUIRED <
MAC_OS_X_VERSION_10_7)
+    #define APPLE_PRE_10_7
 #endif
+#endif

 #if defined(_MSC_VER)
     #include <float.h>
 #endif

 #if defined (sun) || \
-    defined (__APPLE__) || \
+    defined (APPLE_PRE_10_7) || \
     (defined (_AIX) && defined (__GNUC__))

     #include <float.h>

Cheers,
/ulrich

On 15/09/11 0:47 , James Turner wrote:
> I've encountered a problem with the osg/Math header, which a few previous 
> emails on
> this list have alluded to (based on searching the recent archives), but which 
> has an
> interesting explanation.
> 
> osg/Math defines the 'f' versions of cos/sin/floor/etc in terms of the double 
> versions,
> on various platforms, including Mac. The implementation is an inline 
> function, which
> casts the input argument, and calls the 'base' version from math.h
> 
> Unfortunately, LLVM (or the GCC frontend) is smart enough to turn the cast + 
> call of
> the base version back into the floating point version - but the symbol 
> look-up then
> resolves to the osg wrapper - and hence the problem we're seeing. Since 
> osg/Math was
> created, OS-X does define the 'f' versions - but I'm not sure which version 
> started
> doing so - the 10.6 SDK math.h includes the 'f' variants, but plain gcc 4.2 
> wasn't
> smart enough to turn the cast-to-double + call pattern into the float version.
> 
> The local workaround is simply to remove the __APPLE__ case around line 48 of 
> osg/Math,
> but really it would be changed to a MAC_OS_X_VERSION_10_z, if someone can 
> identify what
> value 'z' should have. If anyone still has a 10.5 SDK, they could check
> '/usr/include/architecture/i386/math.h' and see if the 'f' variants of the 
> math
> functions are present.
> 
> (What's the minimum version OSG claims to support at this time? 10.5 or still 
> holding
> out with 10.4?) (Potentially this affects iOS too, though I'm not sure if 
> Apple have
> enabled gcc-llvm for ARM yet, by de default)
> 
> James


_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to