Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Feb 2020 21:57:26 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r358230 - in stable: 11/lib/libc/quad 12/lib/libc/quad
Message-ID:  <202002212157.01LLvQVu003436@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Fri Feb 21 21:57:24 2020
New Revision: 358230
URL: https://svnweb.freebsd.org/changeset/base/358230

Log:
  MFC r358046:
  
  Merge r358042 from the clang1000-import branch:
  
  Add casts and L suffixes to libc quad support, to work around various
  -Werror warnings from clang 10.0.0, such as:
  
  lib/libc/quad/fixdfdi.c:57:12: error: implicit conversion from 'long long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-int-float-conversion]
                  if (x >= QUAD_MAX)
                        ~~ ^~~~~~~~
  /usr/obj/usr/src/powerpc.powerpc/tmp/usr/include/sys/limits.h:89:19: note: expanded from macro 'QUAD_MAX'
  #define QUAD_MAX        (__QUAD_MAX)    /* max value for a quad_t */
                           ^~~~~~~~~~
  /usr/obj/usr/src/powerpc.powerpc/tmp/usr/include/machine/_limits.h:91:20: note: expanded from macro '__QUAD_MAX'
  #define __QUAD_MAX      __LLONG_MAX     /* max value for a quad_t */
                          ^~~~~~~~~~~
  /usr/obj/usr/src/powerpc.powerpc/tmp/usr/include/machine/_limits.h:75:21: note: expanded from macro '__LLONG_MAX'
  #define __LLONG_MAX     0x7fffffffffffffffLL    /* max value for a long long */
                          ^~~~~~~~~~~~~~~~~~~~
  
  and many instances of:
  
  lib/libc/quad/fixunsdfdi.c:73:17: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
          toppart = (x - ONE_HALF) / ONE;
                         ^~~~~~~~
  lib/libc/quad/fixunsdfdi.c:45:19: note: expanded from macro 'ONE_HALF'
  #define ONE_HALF        (ONE_FOURTH * 2.0)
                           ^~~~~~~~~~
  lib/libc/quad/fixunsdfdi.c:44:23: note: expanded from macro 'ONE_FOURTH'
  #define ONE_FOURTH      (1 << (LONG_BITS - 2))
                             ^  ~~~~~~~~~~~~~~~
  lib/libc/quad/fixunsdfdi.c:73:29: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
          toppart = (x - ONE_HALF) / ONE;
                                     ^~~
  lib/libc/quad/fixunsdfdi.c:46:15: note: expanded from macro 'ONE'
  #define ONE             (ONE_FOURTH * 4.0)
                           ^~~~~~~~~~
  lib/libc/quad/fixunsdfdi.c:44:23: note: expanded from macro 'ONE_FOURTH'
  #define ONE_FOURTH      (1 << (LONG_BITS - 2))
                             ^  ~~~~~~~~~~~~~~~

Modified:
  stable/11/lib/libc/quad/fixdfdi.c
  stable/11/lib/libc/quad/fixsfdi.c
  stable/11/lib/libc/quad/fixunsdfdi.c
  stable/11/lib/libc/quad/fixunssfdi.c
  stable/11/lib/libc/quad/floatdidf.c
  stable/11/lib/libc/quad/floatdisf.c
  stable/11/lib/libc/quad/floatunsdidf.c
  stable/11/lib/libc/quad/qdivrem.c
  stable/11/lib/libc/quad/quad.h
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/lib/libc/quad/fixdfdi.c
  stable/12/lib/libc/quad/fixsfdi.c
  stable/12/lib/libc/quad/fixunsdfdi.c
  stable/12/lib/libc/quad/fixunssfdi.c
  stable/12/lib/libc/quad/floatdidf.c
  stable/12/lib/libc/quad/floatdisf.c
  stable/12/lib/libc/quad/floatunsdidf.c
  stable/12/lib/libc/quad/qdivrem.c
  stable/12/lib/libc/quad/quad.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/lib/libc/quad/fixdfdi.c
==============================================================================
--- stable/11/lib/libc/quad/fixdfdi.c	Fri Feb 21 21:54:03 2020	(r358229)
+++ stable/11/lib/libc/quad/fixdfdi.c	Fri Feb 21 21:57:24 2020	(r358230)
@@ -48,12 +48,12 @@ __fixdfdi(x)
 	double x;
 {
 	if (x < 0)
-		if (x <= QUAD_MIN)
+		if (x <= (double)QUAD_MIN)
 			return (QUAD_MIN);
 		else
 			return ((quad_t)-(u_quad_t)-x);
 	else
-		if (x >= QUAD_MAX)
+		if (x >= (double)QUAD_MAX)
 			return (QUAD_MAX);
 		else
 			return ((quad_t)(u_quad_t)x);

Modified: stable/11/lib/libc/quad/fixsfdi.c
==============================================================================
--- stable/11/lib/libc/quad/fixsfdi.c	Fri Feb 21 21:54:03 2020	(r358229)
+++ stable/11/lib/libc/quad/fixsfdi.c	Fri Feb 21 21:57:24 2020	(r358230)
@@ -49,12 +49,12 @@ long long
 __fixsfdi(float x)
 {
 	if (x < 0)
-		if (x <= QUAD_MIN)
+		if (x <= (float)QUAD_MIN)
 			return (QUAD_MIN);
 		else
 			return ((quad_t)-(u_quad_t)-x);
 	else
-		if (x >= QUAD_MAX)
+		if (x >= (float)QUAD_MAX)
 			return (QUAD_MAX);
 		else
 			return ((quad_t)(u_quad_t)x);

Modified: stable/11/lib/libc/quad/fixunsdfdi.c
==============================================================================
--- stable/11/lib/libc/quad/fixunsdfdi.c	Fri Feb 21 21:54:03 2020	(r358229)
+++ stable/11/lib/libc/quad/fixunsdfdi.c	Fri Feb 21 21:57:24 2020	(r358230)
@@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$");
 
 #include "quad.h"
 
-#define	ONE_FOURTH	(1 << (LONG_BITS - 2))
+#define	ONE_FOURTH	(1L << (LONG_BITS - 2))
 #define	ONE_HALF	(ONE_FOURTH * 2.0)
 #define	ONE		(ONE_FOURTH * 4.0)
 
@@ -83,11 +83,11 @@ __fixunsdfdi(x)
 	x -= (double)t.uq;
 	if (x < 0) {
 		t.ul[H]--;
-		x += ULONG_MAX;
+		x += (double)ULONG_MAX;
 	}
-	if (x > ULONG_MAX) {
+	if (x > (double)ULONG_MAX) {
 		t.ul[H]++;
-		x -= ULONG_MAX;
+		x -= (double)ULONG_MAX;
 	}
 	t.ul[L] = (u_long)x;
 	return (t.uq);

Modified: stable/11/lib/libc/quad/fixunssfdi.c
==============================================================================
--- stable/11/lib/libc/quad/fixunssfdi.c	Fri Feb 21 21:54:03 2020	(r358229)
+++ stable/11/lib/libc/quad/fixunssfdi.c	Fri Feb 21 21:57:24 2020	(r358230)
@@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$");
 
 #include "quad.h"
 
-#define	ONE_FOURTH	(1 << (LONG_BITS - 2))
+#define	ONE_FOURTH	(1L << (LONG_BITS - 2))
 #define	ONE_HALF	(ONE_FOURTH * 2.0)
 #define	ONE		(ONE_FOURTH * 4.0)
 
@@ -87,11 +87,11 @@ __fixunssfdi(float f)
 	x -= (double)t.uq;
 	if (x < 0) {
 		t.ul[H]--;
-		x += ULONG_MAX;
+		x += (double)ULONG_MAX;
 	}
-	if (x > ULONG_MAX) {
+	if (x > (double)ULONG_MAX) {
 		t.ul[H]++;
-		x -= ULONG_MAX;
+		x -= (double)ULONG_MAX;
 	}
 	t.ul[L] = (u_long)x;
 	return (t.uq);

Modified: stable/11/lib/libc/quad/floatdidf.c
==============================================================================
--- stable/11/lib/libc/quad/floatdidf.c	Fri Feb 21 21:54:03 2020	(r358229)
+++ stable/11/lib/libc/quad/floatdidf.c	Fri Feb 21 21:57:24 2020	(r358230)
@@ -65,7 +65,7 @@ __floatdidf(x)
 	 * code and does not know how to get at an exponent.  Machine-
 	 * specific code may be able to do this more efficiently.
 	 */
-	d = (double)u.ul[H] * ((1 << (LONG_BITS - 2)) * 4.0);
+	d = (double)u.ul[H] * ((1L << (LONG_BITS - 2)) * 4.0);
 	d += u.ul[L];
 
 	return (neg ? -d : d);

Modified: stable/11/lib/libc/quad/floatdisf.c
==============================================================================
--- stable/11/lib/libc/quad/floatdisf.c	Fri Feb 21 21:54:03 2020	(r358229)
+++ stable/11/lib/libc/quad/floatdisf.c	Fri Feb 21 21:57:24 2020	(r358230)
@@ -67,7 +67,7 @@ __floatdisf(x)
 	 *
 	 * Using double here may be excessive paranoia.
 	 */
-	f = (double)u.ul[H] * ((1 << (LONG_BITS - 2)) * 4.0);
+	f = (double)u.ul[H] * ((1L << (LONG_BITS - 2)) * 4.0);
 	f += u.ul[L];
 
 	return (neg ? -f : f);

Modified: stable/11/lib/libc/quad/floatunsdidf.c
==============================================================================
--- stable/11/lib/libc/quad/floatunsdidf.c	Fri Feb 21 21:54:03 2020	(r358229)
+++ stable/11/lib/libc/quad/floatunsdidf.c	Fri Feb 21 21:57:24 2020	(r358230)
@@ -51,7 +51,7 @@ __floatunsdidf(x)
 	union uu u;
 
 	u.uq = x;
-	d = (double)u.ul[H] * ((1 << (LONG_BITS - 2)) * 4.0);
+	d = (double)u.ul[H] * ((1L << (LONG_BITS - 2)) * 4.0);
 	d += u.ul[L];
 	return (d);
 }

Modified: stable/11/lib/libc/quad/qdivrem.c
==============================================================================
--- stable/11/lib/libc/quad/qdivrem.c	Fri Feb 21 21:54:03 2020	(r358229)
+++ stable/11/lib/libc/quad/qdivrem.c	Fri Feb 21 21:57:24 2020	(r358230)
@@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
 
 #include "quad.h"
 
-#define	B	(1 << HALF_BITS)	/* digit base */
+#define	B	(1L << HALF_BITS)	/* digit base */
 
 /* Combine two `digits' to make a single two-digit number. */
 #define	COMBINE(a, b) (((u_long)(a) << HALF_BITS) | (b))

Modified: stable/11/lib/libc/quad/quad.h
==============================================================================
--- stable/11/lib/libc/quad/quad.h	Fri Feb 21 21:54:03 2020	(r358229)
+++ stable/11/lib/libc/quad/quad.h	Fri Feb 21 21:57:24 2020	(r358230)
@@ -89,7 +89,7 @@ union uu {
  * (sizeof(long)*CHAR_BIT/2).
  */
 #define	HHALF(x)	((x) >> HALF_BITS)
-#define	LHALF(x)	((x) & ((1 << HALF_BITS) - 1))
+#define	LHALF(x)	((x) & ((1L << HALF_BITS) - 1))
 #define	LHUP(x)		((x) << HALF_BITS)
 
 int		__cmpdi2(quad_t a, quad_t b);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002212157.01LLvQVu003436>