This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/6] float128: Add conversion from float128 to mpn


On Fri, 26 May 2017 15:35:16 +0000
Joseph Myers <joseph@codesourcery.com> wrote:

> On Fri, 26 May 2017, Gabriel F. T. Gomes wrote:
> >  
> >  /* Macros for min/max.  */
> > -#define MIN(a,b) (((a)<(b))?(a):(b))
> > -#define MAX(a,b) (((a)>(b))?(a):(b))
> > +#ifndef MIN
> > +# define MIN(a,b) (((a)<(b))?(a):(b))
> > +#endif
> > +#ifndef MAX
> > +# define MAX(a,b) (((a)>(b))?(a):(b))
> > +#endif  
> 
> This seems to have nothing to do with the rest of the patch.
> 
> If you have something that has its own conflicting definitions of MIN and 
> MAX that ends up including sys/param.h as well, and those definitions of 
> MIN and MAX are semantically the same as those in sys/param.h, make it 
> include sys/param.h directly instead of having its own definitions.

The file sysdeps/ieee754/ldbl-128/ldbl2mpn.c includes stdlib/gmp-impl.h,
which defines MAX and MIN.  With the changes to ldbl2mpn.c, the inclusion
of float128_private.h will indirectly include sys/param.h, redefining the
macros.

I attached a new patch which replaces the definition of MAX and MIN in
stdlib/gmp-impl.h with an inclusion of sys/param.h.

Is the attached patch OK for master?

> > +#define __FLOAT128_OVERRIDE
> > +
> > +#include "../ldbl-128/ldbl2mpn.c"  
> 
> Is there a reason you need a sepcial __FLOAT128_OVERRIDE macro, instead of 
> the approach used by the other float128 files of including 
> <float128_private.h>, which defines all relevant macros (e.g. defining 
> __mpn_extract_long_double to __mpn_extract_float128, and with the 
> __mpn_extract_long_double definition using _Float128 as the type name and 
> letting math_ldbl.h redefine that back to long double as needed)?

I could not use the same approach, because ldbl2mpn.c includes the header
include/gmp.h, which declares both __mpn_extract_long_double and
__mpn_extract_float128.  I would end up declaring __mpn_extract_float128
twice.
>From 50013e699a36b896287ac95393b345fc85fa5421 Mon Sep 17 00:00:00 2001
From: "Gabriel F. T. Gomes" <gftg@linux.vnet.ibm.com>
Date: Fri, 26 May 2017 19:29:20 -0300
Subject: [PATCH] Include sys/param.h in stdlib/gmp-impl.h instead of
 redefining MAX/MIN

In stdlib/gmp-impl.h, the macros MAX and MIN are defined exactly the same
as in sys/param.h.  This patch removes the redefinition and makes
gmp-impl.h include sys/param.h instead.

Tested for powerpc64le and s390x.

2017-05-25  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>

	* stdlib/gmp-impl.h: Include sys/param.h instead of redefining the
	macros MAX and MIN.
---
 stdlib/gmp-impl.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/stdlib/gmp-impl.h b/stdlib/gmp-impl.h
index a6594ff..89693c4 100644
--- a/stdlib/gmp-impl.h
+++ b/stdlib/gmp-impl.h
@@ -64,12 +64,8 @@ along with the GNU MP Library; see the file COPYING.LIB.  If not, see
 #define inline			/* Empty */
 #endif
 
-#ifndef MIN
-#define MIN(l,o) ((l) < (o) ? (l) : (o))
-#endif
-#ifndef MAX
-#define MAX(h,i) ((h) > (i) ? (h) : (i))
-#endif
+/* Get MAX/MIN macros.  */
+#include <sys/param.h>
 
 /* Field access macros.  */
 #define SIZ(x) ((x)->_mp_size)
-- 
2.4.11


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]