Skip to content
  • Andy Fawcett's avatar
    Portability fix for FreeBSD, probably needs fixing for other non-glibc systems too · 125dcb33
    Andy Fawcett authored
    I'm pretty sure this can be done with auto*, but it is beyond my skills.
    
    From Jason's commit log (for the backport to KDE_3_0_BRANCH)
    --
    two performance backports:  Replaced dms::PI() with const double dms::PI.
    We had been actually computing acos(-1) every time we needed PI (duh).
    Now we just use the value defined in math.h.  Also, using sincos()
    function defined in math.h in place of calling sin() and cos() separately
    in dms::SinCos().  This is about 33% faster.  However, sincos() is not a
    standard C/C++ function; it is defined in GNU C.  We may need to add a
    contingency for non-Linux compiles...
    --
    
    This has just ensured that the Branch won't build for some people (me for a start, and I
    am quite sure others too). Please consider reverting the sincos() stuff in the branch,
    as I am not going to commit a partial fix there, just to sort out something that should
    have been fully tested in HEAD before backporting.
    
    CCMAIL: kstars@30doradus.org
    
    diff -u -3 -p -r1.11 dms.cpp
    --- dms.cpp     2002/09/19 11:52:57     1.11
    +++ dms.cpp     2002/09/20 06:03:06
    @@ -106,17 +106,21 @@ dms dms::operator- (dms angle)
    
     void dms::SinCos( double &sina, double &cosa ) {
     // This is the old implementation of sincos which is standard C compliant
    +#if defined(__FreeBSD__)
    +// almost certainly this needs more checks for other non-glibc platforms
    +// but I am currently unable to check those
     /*
            register double rad = radians();
            sina = sin( rad );
            cosa = cos( rad );
     */
    -
    +#else
     /**The sincos function computes sin and cos at once (hardware accelareted / fsincos in assembler).
            *It's ~33% faster than computing sin and cos separate. But sincos() is not a standard C/C++
            *function and requires #define _GNU_SOURCE. It's defined in math.h.
            */
            sincos(radians(), &sina, &cosa);
    +#endif
     }
    
    svn path=/trunk/kdeedu/kstars/; revision=179090
    125dcb33