From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109849 invoked by alias); 15 May 2018 18:22:27 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 109840 invoked by uid 89); 15 May 2018 18:22:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Subject: Re: [PATCH] math: Merge strtod_nam_*.h into math-type-macros-*.h To: Joseph Myers Cc: libc-alpha@sourceware.org References: <20180513203019.C0C2A4016D681@oldenburg.str.redhat.com> From: Florian Weimer Message-ID: <7907a5ac-fa11-579a-85b1-ca0a594393cc@redhat.com> Date: Tue, 15 May 2018 18:22:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------CAB5F3602461622D94D6F1DA" X-SW-Source: 2018-05/txt/msg00589.txt.bz2 This is a multi-part message in MIME format. --------------CAB5F3602461622D94D6F1DA Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1234 On 05/15/2018 05:04 PM, Joseph Myers wrote: > On Sun, 13 May 2018, Florian Weimer wrote: > >> + SET_MANTISSA(flt, mant) >> + Set the variable FLT of type FLOAT to the mantissa MANT. */ > > It's specifically setting the *NaN payload* to MANT, not the value of the > variable. SET_MANTISSA is using the ieee_nan union member, which > separates the NaN payload bits from the quiet NaN bit. > > Given that it's specific to NaNs, and would do the wrong thing if you > expected to be able to set the whole mantissa of other floating-point > values, I don't think this should be called SET_MANTISSA in a > non-NaN-specific header. What that indicates to me is renaming the macro > to e.g. SET_NAN_MANTISSA or SET_NAN_PAYLOAD, and calling the > math-mantissa-*.h headers something with "nan" in their name to reflect > that they are specific to NaNs. Okay. I thought that macro had a strange name, but it was probably okay based on context, which is now gone. I've made some further adjustments. I didn't do any binary diffing for this one yet, only tested it on ppc64 (big endian) and x86-64, with no test suite failures (except intl/gettext, but that's totally unrelated and due to my locale settings). Thanks, Florian --------------CAB5F3602461622D94D6F1DA Content-Type: text/x-patch; name="math-nan-payload.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="math-nan-payload.patch" Content-length: 15387 Subject: [PATCH] math: Merge strtod_nan_*.h into math-type-macros-*.h To: libc-alpha@sourceware.org This change will eventually make it possible to compile stdlib/strtod_nan_main.c as part of math/s_nan_template.c. 2018-05-15 Florian Weimer * stdlib/strtod_nan.c: Include instead of . * stdlib/strtod_nan_main.c (STRTOD_NAN): Use SET_NAN_PAYLOAD instead of SET_MANTISSA. * stdlib/strtof_nan.c: Include instead of include . * stdlib/strtold_nan.c: Include instead of . * stdlib/strtod_nan_double.h: Move to ... * sysdeps/generic/math-nan-payload-double.h: ... here. (FLOAT): Remove definition. (SET_MANTISSA): Rename to ... (SET_NAN_PAYLOAD): ... this. * stdlib/strtod_nan_float.h: Move to ... * sysdeps/generic/math-nan-payload-float.h: ... here. (FLOAT): Remove definition. (SET_MANTISSA): Rename to ... (SET_NAN_PAYLOAD): ... this. * sysdeps/generic/math-type-macros-double.h: Include . Include instead of . * sysdeps/generic/math-type-macros-float.h: Include . Include instead of . * sysdeps/generic/math-type-macros-float128.h: Include . * sysdeps/generic/math-type-macros-ldouble.h: Include . Include instead of . * sysdeps/generic/math-type-macros.h: Document SET_NAN_PAYLOAD and check for definition. * sysdeps/ieee754/float128/strtod_nan_float128.h: Move to ... * sysdeps/ieee754/float128/math-nan-payload-float128.h: ... here. Include . (FLOAT): Remove definition. (SET_MANTISSA): Rename to ... (SET_NAN_PAYLOAD): ... this. * sysdeps/ieee754/float128/strtof128_nan.c: Include instead of . Do not include . * sysdeps/ieee754/float128/wcstof128_nan.c: Likewise. * sysdeps/ieee754/ldbl-128/strtod_nan_ldouble.h: Move to ... * sysdeps/ieee754/ldbl-128/math-nan-payload-ldouble.h: ... here. (FLOAT): Remove definition. (SET_MANTISSA): Rename to ... (SET_NAN_PAYLOAD): ... this. * sysdeps/ieee754/ldbl-128ibm/strtod_nan_ldouble.h: Move to ... * sysdeps/ieee754/ldbl-128ibm/math-nan-payload-ldouble.h: ... here. (FLOAT): Remove definition. (SET_MANTISSA): Rename to ... (SET_NAN_PAYLOAD): ... this. * sysdeps/ieee754/ldbl-96/strtod_nan_ldouble.h: Move to ... * sysdeps/ieee754/ldbl-96/math-nan-payload-ldouble.h: ... here. (FLOAT): Remove definition. (SET_MANTISSA): Rename to ... (SET_NAN_PAYLOAD): ... this. * wcsmbs/wcstod_nan.c: Include instead of "../stdlib/strtod_nan_double.h". * wcsmbs/wcstof_nan.c: Include instead of "../stdlib/strtod_nan_float.h". * wcsmbs/wcstold_nan.c: Include instead of "../stdlib/strtod_nan_ldouble.h". * manual/arith.texi (Parsing of Floats): Adjust comment. diff --git a/manual/arith.texi b/manual/arith.texi index 116788ba9a..fb1e773074 100644 --- a/manual/arith.texi +++ b/manual/arith.texi @@ -2765,7 +2765,7 @@ as well. @c mpn_lshift_1 -> mpn_lshift ok @c STRTOF_INTERNAL @c MPN_VAR ok -@c SET_MANTISSA ok +@c SET_NAN_PAYLOAD ok @c STRNCASECMP ok, wide and narrow @c round_and_return ok @c mpn_mul ok diff --git a/stdlib/strtod_nan.c b/stdlib/strtod_nan.c index f64fec1897..c5876b59a0 100644 --- a/stdlib/strtod_nan.c +++ b/stdlib/strtod_nan.c @@ -18,7 +18,7 @@ . */ #include -#include +#include #define STRTOD_NAN __strtod_nan #include diff --git a/stdlib/strtod_nan_main.c b/stdlib/strtod_nan_main.c index 12f6e7383d..80ecb78572 100644 --- a/stdlib/strtod_nan_main.c +++ b/stdlib/strtod_nan_main.c @@ -52,7 +52,7 @@ STRTOD_NAN (const STRING_TYPE *str, STRING_TYPE **endptr, STRING_TYPE endc) mant = STRTOULL (str, &endp, 0); if (endp == cp) - SET_MANTISSA (retval, mant); + SET_NAN_PAYLOAD (retval, mant); out: if (endptr != NULL) diff --git a/stdlib/strtof_nan.c b/stdlib/strtof_nan.c index ea3decb729..f085c5b4fb 100644 --- a/stdlib/strtof_nan.c +++ b/stdlib/strtof_nan.c @@ -18,7 +18,7 @@ . */ #include -#include +#include #define STRTOD_NAN __strtof_nan #include diff --git a/stdlib/strtold_nan.c b/stdlib/strtold_nan.c index d4bbcc0a8b..eadfe546e2 100644 --- a/stdlib/strtold_nan.c +++ b/stdlib/strtold_nan.c @@ -23,7 +23,7 @@ representation. */ #ifndef __NO_LONG_DOUBLE_MATH # include -# include +# include # define STRTOD_NAN __strtold_nan # include diff --git a/stdlib/strtod_nan_double.h b/sysdeps/generic/math-nan-payload-double.h similarity index 89% rename from stdlib/strtod_nan_double.h rename to sysdeps/generic/math-nan-payload-double.h +++ b/sysdeps/generic/math-nan-payload-double.h @@ -1,4 +1,4 @@ -/* Convert string for NaN payload to corresponding NaN. For double. +/* NaN payload handling for double. Copyright (C) 1997-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -16,8 +16,7 @@ License along with the GNU C Library; if not, see . */ -#define FLOAT double -#define SET_MANTISSA(flt, mant) \ +#define SET_NAN_PAYLOAD(flt, mant) \ do \ { \ union ieee754_double u; \ diff --git a/stdlib/strtod_nan_float.h b/sysdeps/generic/math-nan-payload-float.h similarity index 88% rename from stdlib/strtod_nan_float.h rename to sysdeps/generic/math-nan-payload-float.h +++ b/sysdeps/generic/math-nan-payload-float.h @@ -1,4 +1,4 @@ -/* Convert string for NaN payload to corresponding NaN. For float. +/* NaN payload handling for float. Copyright (C) 1997-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -16,8 +16,7 @@ License along with the GNU C Library; if not, see . */ -#define FLOAT float -#define SET_MANTISSA(flt, mant) \ +#define SET_NAN_PAYLOAD(flt, mant) \ do \ { \ union ieee754_float u; \ diff --git a/sysdeps/generic/math-type-macros-double.h b/sysdeps/generic/math-type-macros-double.h index 1af4c74e4b..156418221d 100644 --- a/sysdeps/generic/math-type-macros-double.h +++ b/sysdeps/generic/math-type-macros-double.h @@ -27,6 +27,7 @@ #define CFLOAT _Complex double #define M_STRTO_NAN __strtod_nan +#include #include #ifndef declare_mgen_alias @@ -42,7 +43,7 @@ /* Do not use the type-generic wrapper templates if compatibility with SVID error handling is needed. */ -#include +#include #define __USE_WRAPPER_TEMPLATE !LIBM_SVID_COMPAT #endif diff --git a/sysdeps/generic/math-type-macros-float.h b/sysdeps/generic/math-type-macros-float.h index 9273bdee0e..7dd0b74e24 100644 --- a/sysdeps/generic/math-type-macros-float.h +++ b/sysdeps/generic/math-type-macros-float.h @@ -30,6 +30,7 @@ the double macro constants. */ #define M_MLIT(c) c +#include #include #ifndef declare_mgen_alias @@ -45,7 +46,7 @@ /* Do not use the type-generic wrapper templates if compatibility with SVID error handling is needed. */ -#include +#include #define __USE_WRAPPER_TEMPLATE !LIBM_SVID_COMPAT #endif diff --git a/sysdeps/generic/math-type-macros-float128.h b/sysdeps/generic/math-type-macros-float128.h index 485c13bb88..6144bc047a 100644 --- a/sysdeps/generic/math-type-macros-float128.h +++ b/sysdeps/generic/math-type-macros-float128.h @@ -29,6 +29,7 @@ #define M_MLIT(c) c ## f128 +#include #include #ifndef declare_mgen_alias diff --git a/sysdeps/generic/math-type-macros-ldouble.h b/sysdeps/generic/math-type-macros-ldouble.h index 5fe1600231..db411998eb 100644 --- a/sysdeps/generic/math-type-macros-ldouble.h +++ b/sysdeps/generic/math-type-macros-ldouble.h @@ -27,6 +27,7 @@ #define CFLOAT _Complex long double #define M_STRTO_NAN __strtold_nan +#include #include #ifndef declare_mgen_alias @@ -42,7 +43,7 @@ /* Do not use the type-generic wrapper templates if compatibility with SVID error handling is needed. */ -#include +#include #define __USE_WRAPPER_TEMPLATE !LIBM_SVID_COMPAT #endif diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h index ffcf7b80b6..0e8ef16d7a 100644 --- a/sysdeps/generic/math-type-macros.h +++ b/sysdeps/generic/math-type-macros.h @@ -40,7 +40,11 @@ declare_mgen_alias_r(from,to) This exposes the appropriate symbol(s) for a - function f_r of type FLOAT. */ + function f_r of type FLOAT. + + SET_NAN_PAYLOAD(flt, mant) + Set the NaN payload bits of the variable FLT of type FLOAT to + the mantissa MANT. */ #ifndef M_PFX # error "M_PFX must be defined." @@ -66,6 +70,9 @@ #ifndef declare_mgen_alias_r # error "declare_mgen_alias_r must be defined." #endif +#ifndef SET_NAN_PAYLOAD +# error "SET_NAN_PAYLOAD must be defined." +#endif #define __M_CONCAT(a,b) a ## b #define __M_CONCATX(a,b) __M_CONCAT(a,b) diff --git a/sysdeps/ieee754/float128/strtod_nan_float128.h b/sysdeps/ieee754/float128/math-nan-payload-float128.h similarity index 89% rename from sysdeps/ieee754/float128/strtod_nan_float128.h rename to sysdeps/ieee754/float128/math-nan-payload-float128.h +++ b/sysdeps/ieee754/float128/math-nan-payload-float128.h @@ -1,4 +1,4 @@ -/* Convert string for NaN payload to corresponding NaN. For _Float128. +/* NaN payload handling for _Float128. Copyright (C) 2017-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -16,8 +16,9 @@ License along with the GNU C Library; if not, see . */ -#define FLOAT _Float128 -#define SET_MANTISSA(flt, mant) \ +#include + +#define SET_NAN_PAYLOAD(flt, mant) \ do \ { \ union ieee854_float128 u; \ diff --git a/sysdeps/ieee754/float128/strtof128_nan.c b/sysdeps/ieee754/float128/strtof128_nan.c index 36a9bfffed..37a7f4e02e 100644 --- a/sysdeps/ieee754/float128/strtof128_nan.c +++ b/sysdeps/ieee754/float128/strtof128_nan.c @@ -19,10 +19,8 @@ #include -#include - #include -#include +#include #define STRTOD_NAN __strtof128_nan #include diff --git a/sysdeps/ieee754/float128/wcstof128_nan.c b/sysdeps/ieee754/float128/wcstof128_nan.c index ffc72a016a..f504809dcf 100644 --- a/sysdeps/ieee754/float128/wcstof128_nan.c +++ b/sysdeps/ieee754/float128/wcstof128_nan.c @@ -18,7 +18,6 @@ . */ #include -#include -#include +#include #define STRTOD_NAN __wcstof128_nan #include diff --git a/sysdeps/ieee754/ldbl-128/strtod_nan_ldouble.h b/sysdeps/ieee754/ldbl-128/math-nan-payload-ldouble.h similarity index 89% rename from sysdeps/ieee754/ldbl-128/strtod_nan_ldouble.h rename to sysdeps/ieee754/ldbl-128/math-nan-payload-ldouble.h +++ b/sysdeps/ieee754/ldbl-128/math-nan-payload-ldouble.h @@ -1,4 +1,4 @@ -/* Convert string for NaN payload to corresponding NaN. For ldbl-128. +/* NaN payload handling for ldbl-128. Copyright (C) 1997-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -16,8 +16,7 @@ License along with the GNU C Library; if not, see . */ -#define FLOAT long double -#define SET_MANTISSA(flt, mant) \ +#define SET_NAN_PAYLOAD(flt, mant) \ do \ { \ union ieee854_long_double u; \ diff --git a/sysdeps/ieee754/ldbl-128ibm/strtod_nan_ldouble.h b/sysdeps/ieee754/ldbl-128ibm/math-nan-payload-ldouble.h similarity index 88% rename from sysdeps/ieee754/ldbl-128ibm/strtod_nan_ldouble.h rename to sysdeps/ieee754/ldbl-128ibm/math-nan-payload-ldouble.h +++ b/sysdeps/ieee754/ldbl-128ibm/math-nan-payload-ldouble.h @@ -1,4 +1,4 @@ -/* Convert string for NaN payload to corresponding NaN. For ldbl-128ibm. +/* NaN payload handling or ldbl-128ibm. Copyright (C) 1997-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -16,8 +16,7 @@ License along with the GNU C Library; if not, see . */ -#define FLOAT long double -#define SET_MANTISSA(flt, mant) \ +#define SET_NAN_PAYLOAD(flt, mant) \ do \ { \ union ibm_extended_long_double u; \ diff --git a/sysdeps/ieee754/ldbl-96/strtod_nan_ldouble.h b/sysdeps/ieee754/ldbl-96/math-nan-payload-ldouble.h similarity index 88% rename from sysdeps/ieee754/ldbl-96/strtod_nan_ldouble.h rename to sysdeps/ieee754/ldbl-96/math-nan-payload-ldouble.h +++ b/sysdeps/ieee754/ldbl-96/math-nan-payload-ldouble.h @@ -1,4 +1,4 @@ -/* Convert string for NaN payload to corresponding NaN. For ldbl-96. +/* NaN payload handling for ldbl-96. Copyright (C) 1997-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -16,8 +16,7 @@ License along with the GNU C Library; if not, see . */ -#define FLOAT long double -#define SET_MANTISSA(flt, mant) \ +#define SET_NAN_PAYLOAD(flt, mant) \ do \ { \ union ieee854_long_double u; \ diff --git a/wcsmbs/wcstod_nan.c b/wcsmbs/wcstod_nan.c index 1aee82d844..1423f3e8aa 100644 --- a/wcsmbs/wcstod_nan.c +++ b/wcsmbs/wcstod_nan.c @@ -17,7 +17,7 @@ . */ #include "../stdlib/strtod_nan_wide.h" -#include "../stdlib/strtod_nan_double.h" +#include #define STRTOD_NAN __wcstod_nan #include "../stdlib/strtod_nan_main.c" diff --git a/wcsmbs/wcstof_nan.c b/wcsmbs/wcstof_nan.c index 9c89e24370..96f2198667 100644 --- a/wcsmbs/wcstof_nan.c +++ b/wcsmbs/wcstof_nan.c @@ -17,7 +17,7 @@ . */ #include "../stdlib/strtod_nan_wide.h" -#include "../stdlib/strtod_nan_float.h" +#include #define STRTOD_NAN __wcstof_nan #include "../stdlib/strtod_nan_main.c" diff --git a/wcsmbs/wcstold_nan.c b/wcsmbs/wcstold_nan.c index a4d274f37f..66793ec459 100644 --- a/wcsmbs/wcstold_nan.c +++ b/wcsmbs/wcstold_nan.c @@ -23,7 +23,7 @@ representation. */ #ifndef __NO_LONG_DOUBLE_MATH # include "../stdlib/strtod_nan_wide.h" -# include +# include # define STRTOD_NAN __wcstold_nan # include "../stdlib/strtod_nan_main.c" --------------CAB5F3602461622D94D6F1DA--