svn commit: r358230 - in stable: 11/lib/libc/quad 12/lib/libc/quad
Dimitry Andric
dim at FreeBSD.org
Fri Feb 21 21:57:27 UTC 2020
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/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)
Changes in other areas also in this revision:
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)
Modified: stable/12/lib/libc/quad/fixdfdi.c
==============================================================================
--- stable/12/lib/libc/quad/fixdfdi.c Fri Feb 21 21:54:03 2020 (r358229)
+++ stable/12/lib/libc/quad/fixdfdi.c Fri Feb 21 21:57:24 2020 (r358230)
@@ -50,12 +50,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/12/lib/libc/quad/fixsfdi.c
==============================================================================
--- stable/12/lib/libc/quad/fixsfdi.c Fri Feb 21 21:54:03 2020 (r358229)
+++ stable/12/lib/libc/quad/fixsfdi.c Fri Feb 21 21:57:24 2020 (r358230)
@@ -51,12 +51,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/12/lib/libc/quad/fixunsdfdi.c
==============================================================================
--- stable/12/lib/libc/quad/fixunsdfdi.c Fri Feb 21 21:54:03 2020 (r358229)
+++ stable/12/lib/libc/quad/fixunsdfdi.c Fri Feb 21 21:57:24 2020 (r358230)
@@ -41,7 +41,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)
@@ -85,11 +85,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/12/lib/libc/quad/fixunssfdi.c
==============================================================================
--- stable/12/lib/libc/quad/fixunssfdi.c Fri Feb 21 21:54:03 2020 (r358229)
+++ stable/12/lib/libc/quad/fixunssfdi.c Fri Feb 21 21:57:24 2020 (r358230)
@@ -41,7 +41,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)
@@ -89,11 +89,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/12/lib/libc/quad/floatdidf.c
==============================================================================
--- stable/12/lib/libc/quad/floatdidf.c Fri Feb 21 21:54:03 2020 (r358229)
+++ stable/12/lib/libc/quad/floatdidf.c Fri Feb 21 21:57:24 2020 (r358230)
@@ -67,7 +67,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/12/lib/libc/quad/floatdisf.c
==============================================================================
--- stable/12/lib/libc/quad/floatdisf.c Fri Feb 21 21:54:03 2020 (r358229)
+++ stable/12/lib/libc/quad/floatdisf.c Fri Feb 21 21:57:24 2020 (r358230)
@@ -69,7 +69,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/12/lib/libc/quad/floatunsdidf.c
==============================================================================
--- stable/12/lib/libc/quad/floatunsdidf.c Fri Feb 21 21:54:03 2020 (r358229)
+++ stable/12/lib/libc/quad/floatunsdidf.c Fri Feb 21 21:57:24 2020 (r358230)
@@ -53,7 +53,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/12/lib/libc/quad/qdivrem.c
==============================================================================
--- stable/12/lib/libc/quad/qdivrem.c Fri Feb 21 21:54:03 2020 (r358229)
+++ stable/12/lib/libc/quad/qdivrem.c Fri Feb 21 21:57:24 2020 (r358230)
@@ -46,7 +46,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/12/lib/libc/quad/quad.h
==============================================================================
--- stable/12/lib/libc/quad/quad.h Fri Feb 21 21:54:03 2020 (r358229)
+++ stable/12/lib/libc/quad/quad.h Fri Feb 21 21:57:24 2020 (r358230)
@@ -91,7 +91,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);
More information about the svn-src-stable-12
mailing list