From 63b481b9190a4e9eac012ce7222e23c0fef1bac0 Mon Sep 17 00:00:00 2001 From: Aaron Crane Date: Fri, 13 Oct 2017 15:34:03 +0200 Subject: [PATCH] Simplify perl.h floating-point limits defines - Always include and - Assume that the DBL_* constants are always available in (though we still check for each LDBL_* constant individually) - Drop support for the undocumented OVR_DBL_DIG and OVR_LDBL_DIG preprocessor symbols - Use cpp "#elif" --- perl.h | 104 ++++++++++++----------------------------------------------------- 1 file changed, 19 insertions(+), 85 deletions(-) diff --git a/perl.h b/perl.h index 0091b8d..b63b764 100644 --- a/perl.h +++ b/perl.h @@ -710,6 +710,8 @@ #endif #include +#include +#include #ifdef METHOD /* Defined by OSF/1 v3.0 by ctype.h */ #undef METHOD @@ -1676,64 +1678,22 @@ typedef UVTYPE UV; # endif #endif -#ifdef OVR_DBL_DIG -/* Use an overridden DBL_DIG */ -# ifdef DBL_DIG -# undef DBL_DIG -# endif -# define DBL_DIG OVR_DBL_DIG -#else -/* The following is all to get DBL_DIG, in order to pick a nice - default value for printing floating point numbers in Gconvert - (see config.h). (It also has other uses, such as figuring out if - a given precision of printing can be done with a double instead of - a long double - Allen). -*/ -#include -#include -#endif - -#ifdef OVR_LDBL_DIG -/* Use an overridden LDBL_DIG */ -# ifdef LDBL_DIG -# undef LDBL_DIG -# endif -# define LDBL_DIG OVR_LDBL_DIG -#else /* The following is all to get LDBL_DIG, in order to pick a nice default value for printing floating point numbers in Gconvert. (see config.h) */ -# include -# include -# ifndef HAS_LDBL_DIG +#ifndef HAS_LDBL_DIG # if LONG_DOUBLESIZE == 10 -# define LDBL_DIG 18 /* assume IEEE */ -# else -# if LONG_DOUBLESIZE == 12 +# define LDBL_DIG 18 /* assume IEEE */ +# elif LONG_DOUBLESIZE == 12 # define LDBL_DIG 18 /* gcc? */ -# else -# if LONG_DOUBLESIZE == 16 -# define LDBL_DIG 33 /* assume IEEE */ -# else -# if LONG_DOUBLESIZE == DOUBLESIZE -# define LDBL_DIG DBL_DIG /* bummer */ -# endif -# endif -# endif +# elif LONG_DOUBLESIZE == 16 +# define LDBL_DIG 33 /* assume IEEE */ +# elif LONG_DOUBLESIZE == DOUBLESIZE +# define LDBL_DIG DBL_DIG /* bummer */ # endif -# endif #endif -/* - * This is for making sure we have a good DBL_MAX value, if possible, - * either for usage as NV_MAX or for usage in figuring out if we can - * fit a given long double into a double, if bug-fixing makes it - * necessary to do so. - Allen - */ - -#include - typedef NVTYPE NV; #ifdef I_IEEEFP @@ -1909,38 +1869,16 @@ extern long double Perl_my_frexpl(long double x, int *e); # define Perl_fp_class_zero(x) (Perl_fp_class(x) == 0) #else # define NV_DIG DBL_DIG -# ifdef DBL_MANT_DIG -# define NV_MANT_DIG DBL_MANT_DIG -# endif -# ifdef DBL_MIN -# define NV_MIN DBL_MIN -# endif -# ifdef DBL_MAX -# define NV_MAX DBL_MAX -# endif -# ifdef DBL_MIN_EXP -# define NV_MIN_EXP DBL_MIN_EXP -# endif -# ifdef DBL_MAX_EXP -# define NV_MAX_EXP DBL_MAX_EXP -# endif -# ifdef DBL_MIN_10_EXP -# define NV_MIN_10_EXP DBL_MIN_10_EXP -# endif -# ifdef DBL_MAX_10_EXP -# define NV_MAX_10_EXP DBL_MAX_10_EXP -# endif -# ifdef DBL_EPSILON -# define NV_EPSILON DBL_EPSILON -# endif -# ifdef DBL_MAX /* XXX Does DBL_MAX imply having DBL_MIN? */ -# define NV_MAX DBL_MAX -# define NV_MIN DBL_MIN -# else -# ifdef HUGE_VAL -# define NV_MAX HUGE_VAL -# endif -# endif +# define NV_MANT_DIG DBL_MANT_DIG +# define NV_MIN DBL_MIN +# define NV_MAX DBL_MAX +# define NV_MIN_EXP DBL_MIN_EXP +# define NV_MAX_EXP DBL_MAX_EXP +# define NV_MIN_10_EXP DBL_MIN_10_EXP +# define NV_MAX_10_EXP DBL_MAX_10_EXP +# define NV_EPSILON DBL_EPSILON +# define NV_MAX DBL_MAX +# define NV_MIN DBL_MIN /* These math interfaces are C89. */ # define Perl_acos acos @@ -2315,10 +2253,6 @@ int isnan(double d); * define PERL ULONG_MAX 4294967295L */ -#include /* Needed for cast_xxx() functions below. */ -/* Included values.h above if necessary; still including limits.h down here, - * despite doing above, because math.h might have overridden... XXX - Allen */ - /* * Try to figure out max and min values for the integral types. THE CORRECT * SOLUTION TO THIS MESS: ADAPT enquire.c FROM GCC INTO CONFIGURE. The -- 1.8.3.1