This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Committed to trunk], was: Re: [RFD] -ffinite-math-only.


Toon Moene <toon@moene.indiv.nluug.nl> writes:

[...]

| > Fixed into (!FLOAT_MODE_P (mode) || !HONOR_NANS (mode))
| > which will be installed after another make bootstrap / make -k check on
| > i686-pc-linux-gnu.
| 
| I committed the following [attached] after make bootstrap, make -k check
| and make install on i686-pc-linux-gnu.

Hi,

   Many thanks for having done this.   I have a small request however
(I'll implement it if agreed upon):  I'll prefer __FINITE_MATH_ONLY__
be defined to be 1 if flag_finite_math_only is set and 0 otherwise (I
wasn't clear in my previous message, sorry).  Thay way, it makes it
easy (and compliant with GNU coding standard suggestion) to
communicate the comppiler flags to the built library.

    // General routines assuming -fno-finite-math-only
    template<bool>
       struct __math_strategy {
         template<typename T>
            static T _S_pow(T, double);
       };

    // routines to handle -ffinite-math-only
    template<>
       struct __math_strategy<true> {
          template<typename T>
           static T _S_pow(T, double);
       };

    // Somewhere in the library header files.
    template<typename T>
    inline T pow(T x, double y)
    {
       return __math_strategy<__FINITE_MATH_ONLY__>::_S_pow(x, y);
    }
    
With your current implementation, I could play macro games with #if
#elif #endif but then the GNU Coding Standards prefer

    if (HAVE_FOO)
       // ....
    else
       ....

over 

    #if HAVE_FOO
      // ...
    #else
      // ...
    #endif

There are various places in the libstdc++-v3 where the above scheme
could be used to take advantages of compiler flags.

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]