Fix warnings

This change fixes Cosmopolitan so it has fewer opinions about compiler
warnings. The whole repository had to be cleaned up to be buildable in
-Werror -Wall mode. This lets us benefit from things like strict const
checking. Some actual bugs might have been caught too.
This commit is contained in:
Justine Tunney 2023-09-01 20:49:13 -07:00
parent e2b3c3618e
commit 0d748ad58e
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
571 changed files with 1306 additions and 1888 deletions

View file

@ -110,7 +110,7 @@ double acos(double x)
/* |x| >= 1 or nan */
if (ix >= 0x3ff00000) {
lx = u.i;
if ((ix-0x3ff00000 | lx) == 0) {
if (((ix-0x3ff00000) | lx) == 0) {
/* acos(1)=0, acos(-1)=pi */
if (hx >> 31)
return 2*pio2_hi + 0x1p-120f;

View file

@ -119,7 +119,7 @@ double asin(double x)
/* |x| >= 1 or nan */
if (ix >= 0x3ff00000) {
lx = u.i;
if (!(ix-0x3ff00000 | lx))
if (!((ix-0x3ff00000) | lx))
/* asin(1) = +-pi/2 with inexact */
return x*pio2_hi + 0x1p-120f;
return 0/(x-x);

View file

@ -43,7 +43,6 @@ asm(".include \"libc/disclaimer.inc\"");
#elif FLT_EVAL_METHOD==2
#define EPS LDBL_EPSILON
#endif
static const double_t toint = 1/EPS;
/**
* Returns smallest integral value not less than 𝑥.
@ -74,6 +73,7 @@ double ceil(double x)
#else
static const double_t toint = 1/EPS;
union {double f; uint64_t i;} u = {x};
int e = u.i >> 52 & 0x7ff;
double_t y;

View file

@ -5,14 +5,17 @@ COSMOPOLITAN_C_START_
static inline void fevalf(float x) {
volatile float y = x;
(void)y;
}
static inline void feval(double x) {
volatile double y = x;
(void)y;
}
static inline void fevall(long double x) {
volatile long double y = x;
(void)y;
}
COSMOPOLITAN_C_END_

View file

@ -43,7 +43,6 @@ asm(".include \"libc/disclaimer.inc\"");
#elif FLT_EVAL_METHOD==2
#define EPS LDBL_EPSILON
#endif
static const double_t toint = 1/EPS;
/**
* Returns largest integral value not greater than 𝑥.
@ -74,6 +73,7 @@ double floor(double x)
#else
static const double_t toint = 1/EPS;
union {double f; uint64_t i;} u = {x};
int e = u.i >> 52 & 0x7ff;
double_t y;

View file

@ -154,7 +154,7 @@ double fma(double x, double y, double z)
if (d > 0) {
if (d < 64) {
zlo = nz.m<<d;
zhi = nz.m>>64-d;
zhi = nz.m>>(64-d);
} else {
zlo = 0;
zhi = nz.m;
@ -162,7 +162,7 @@ double fma(double x, double y, double z)
d -= 64;
if (d == 0) {
} else if (d < 64) {
rlo = rhi<<64-d | rlo>>d | !!(rlo<<64-d);
rlo = rhi<<(64-d) | rlo>>d | !!(rlo<<(64-d));
rhi = rhi>>d;
} else {
rlo = 1;
@ -175,7 +175,7 @@ double fma(double x, double y, double z)
if (d == 0) {
zlo = nz.m;
} else if (d < 64) {
zlo = nz.m>>d | !!(nz.m<<64-d);
zlo = nz.m>>d | !!(nz.m<<(64-d));
} else {
zlo = 1;
}
@ -207,7 +207,7 @@ double fma(double x, double y, double z)
e += 64;
d = a_clz_64(rhi)-1;
/* note: d > 0 */
rhi = rhi<<d | rlo>>64-d | !!(rlo<<d);
rhi = rhi<<d | rlo>>(64-d) | !!(rlo<<d);
} else if (rlo) {
d = a_clz_64(rlo)-1;
if (d < 0)
@ -258,7 +258,7 @@ double fma(double x, double y, double z)
} else {
/* only round once when scaled */
d = 10;
i = ( rhi>>d | !!(rhi<<64-d) ) << d;
i = ( rhi>>d | !!(rhi<<(64-d)) ) << d;
if (sign)
i = -i;
r = i;