improve math.h
Patrick Mansfield
patmans@us.ibm.com
Wed May 16 15:58:00 GMT 2007
On Wed, May 16, 2007 at 06:31:06AM -0600, Eric Blake wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I still don't have frexpl working, but thought I would ask if I can commit
> this in the meantime.
>
> 2007-05-16 Eric Blake <ebb9@byu.net>
>
> * libc/include/math.h (INFINITY, NAN, FP_ILOGB0, FP_ILOGBNAN)
> (MATH_ERRNO, MATH_ERREXCEPT, math_errhandling): Add macros
> required by POSIX.
Are you going to add usage of FP_ILOGB in s_ilogb.c and sf_ilogb.c?
> Index: libc/include/math.h
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/include/math.h,v
> retrieving revision 1.25
> diff -u -p -b -r1.25 math.h
> --- libc/include/math.h 26 Apr 2007 19:23:37 -0000 1.25
> +++ libc/include/math.h 16 May 2007 12:28:29 -0000
> @@ -1,4 +1,3 @@
> -
> #ifndef _MATH_H_
> #define _MATH_H_
>
> @@ -32,17 +31,25 @@ union __ldmath
>
> /* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */
>
> - #ifndef HUGE_VAL
> - #define HUGE_VAL (__builtin_huge_val())
> - #endif
> -
> - #ifndef HUGE_VALF
> - #define HUGE_VALF (__builtin_huge_valf())
> - #endif
> -
> - #ifndef HUGE_VALL
> - #define HUGE_VALL (__builtin_huge_vall())
> - #endif
> +# ifndef HUGE_VAL
> +# define HUGE_VAL (__builtin_huge_val())
> +# endif
> +
> +# ifndef HUGE_VALF
> +# define HUGE_VALF (__builtin_huge_valf())
> +# endif
> +
> +# ifndef HUGE_VALL
> +# define HUGE_VALL (__builtin_huge_vall())
> +# endif
> +
> +# ifndef INFINITY
> +# define INFINITY (__builtin_inff())
> +# endif
> +
> +# ifndef NAN
> +# define NAN (__builtin_nanf(""))
> +# endif
Is the white space "#<space>directive" intentional (above and below)? I
don't see that anywhere else in math.h. I am not sure what coding standard
is supposed to be followed in newlib, and don't care as long as we are
consistent.
>
> #else /* !gcc >= 3.3 */
>
> @@ -118,6 +125,23 @@ typedef double double_t;
> #define FP_SUBNORMAL 3
> #define FP_NORMAL 4
>
> +#ifndef FP_ILOGB0
> +# define FP_ILOGB0 (-INT_MAX)
> +#endif
> +#ifndef FP_ILOGBNAN
> +# define FP_ILOGBNAN INT_MAX
> +#endif
> +
> +#ifndef MATH_ERRNO
> +# define MATH_ERRNO 1
> +#endif
> +#ifndef MATH_ERREXCEPT
> +# define MATH_ERREXCEPT 2
> +#endif
> +#ifndef math_errhandling
> +# define math_errhandling MATH_ERRNO
> +#endif
> +
> extern int __isinff (float x);
> extern int __isinfd (double x);
> extern int __isnanf (float x);
-- Patrick Mansfield
More information about the Newlib
mailing list