comparison lib/math.in.h @ 9898:02bfc9acab82

Work around Solaris 10 math.h bug. * m4/math_h.m4 (gl_MATH_H): Check for bug. (gl_MATH_H_DEFAULTS): Set up default. * modules/math (Makefile.am): Replace new indicators. * lib/math.in.h (NAN, HUGE_VAL): Provide replacements. * tests/test-math.c (main): Test this. * m4/strtod.m4 (gl_FUNC_STRTOD): Don't rely on HUGE_VAL. * doc/posix-headers/math.texi (math.h): Mention bug. Reported by Nelson H. F. Beebe and Jim Meyering. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Sat, 12 Apr 2008 07:22:40 -0600
parents 7f3ed6b093be
children d3f5a70dc1ba
comparison
equal deleted inserted replaced
9897:ebc67bd296ad 9898:02bfc9acab82
1 /* A GNU-like <math.h>. 1 /* A GNU-like <math.h>.
2 2
3 Copyright (C) 2002-2003, 2007, 2008 Free Software Foundation, Inc. 3 Copyright (C) 2002-2003, 2007-2008 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
32 #endif 32 #endif
33 33
34 34
35 /* POSIX allows platforms that don't support NAN. But all major 35 /* POSIX allows platforms that don't support NAN. But all major
36 machines in the past 15 years have supported something close to 36 machines in the past 15 years have supported something close to
37 IEEE NaN, so we define this unconditionally. */ 37 IEEE NaN, so we define this unconditionally. We also must define
38 #ifndef NAN 38 it on platforms like Solaris 10, where NAN is present but defined
39 as a function pointer rather than a floating point constant. */
40 #if !defined NAN || @REPLACE_NAN@
41 # undef NAN
39 /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ 42 /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
40 # ifdef __DECC 43 # ifdef __DECC
41 static float 44 static float
42 _NaN () 45 _NaN ()
43 { 46 {
46 } 49 }
47 # define NAN (_NaN()) 50 # define NAN (_NaN())
48 # else 51 # else
49 # define NAN (0.0f / 0.0f) 52 # define NAN (0.0f / 0.0f)
50 # endif 53 # endif
54 #endif
55
56 /* Solaris 10 defines HUGE_VAL, but as a function pointer rather
57 than a floating point constant. */
58 #if @REPLACE_HUGE_VAL@
59 # undef HUGE_VAL
60 # define HUGE_VAL (1.0 / 0.0)
51 #endif 61 #endif
52 62
53 /* Write x as 63 /* Write x as
54 x = mantissa * 2^exp 64 x = mantissa * 2^exp
55 where 65 where