Waiting for comments on this patch! I think it's portable, but it
needs to be tested on platforms other than gcc to make sure those
platforms aren't broken!

Sameer.

On Fri, Dec 5, 2008 at 3:01 PM, Sameer Sahasrabuddhe <[email protected]> wrote:
> Hi,
>
> Attaching a patch that introduces a macro called "isfinite", which is
> used if the actual C99 macro with the same name is not available.
> Originally defined in the GNU coreutils:
>
> http://cvs.savannah.gnu.org/viewvc/coreutils/coreutils/src/seq.c?revision=1.95&view=markup
>
> /* Roll our own isfinite rather than using <math.h>, so that we don't
>   have to worry about linking -lm just for isfinite.  */
> #ifndef isfinite
> # define isfinite(x) ((x) * 0 == 0)
> #endif
>
> This works because in the world of floating point numbers, anything
> multiplied by zero is not always zero. If x is a NaN then the result
> is a NaN and if it is infinite then the result is infinite. So the
> multiplication cannot be optimised away by the compiler.
>
> This definition is supposed to work on all platforms (unless there is
> a bug in the compiler).  The reason we might want to use the system
> definition of isfinite is probably only for performance, which is not
> a very big priority here. Hence removed #include <math.h> and #include
> <float.h> since the only purpose of these files was to introduce
> suitable macros for checking finiteness. Also removed the check for
> OS/2.
>
> This change compiles correctly on GCC ... needs checking on other platforms.
>
> Sameer.
> --
> http://www.it.iitb.ac.in/~sameerds/
>



-- 
http://www.it.iitb.ac.in/~sameerds/
_______________________________________________
dia-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/dia-list
FAQ at http://live.gnome.org/Dia/Faq
Main page at http://live.gnome.org/Dia

Reply via email to