mirror of https://github.com/encounter/SDL.git
libm: Fixed all static analysis warnings.
This commit is contained in:
parent
c0aa626ba3
commit
550437edbe
|
@ -154,7 +154,7 @@ int32_t attribute_hidden __ieee754_rem_pio2(double x, double *y)
|
||||||
}
|
}
|
||||||
tx[2] = z;
|
tx[2] = z;
|
||||||
nx = 3;
|
nx = 3;
|
||||||
while(tx[nx-1]==zero) nx--; /* skip zero term */
|
while((nx > 0) && tx[nx-1]==zero) nx--; /* skip zero term */
|
||||||
n = __kernel_rem_pio2(tx,y,e0,nx,2,two_over_pi);
|
n = __kernel_rem_pio2(tx,y,e0,nx,2,two_over_pi);
|
||||||
if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;}
|
if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;}
|
||||||
return n;
|
return n;
|
||||||
|
|
|
@ -128,6 +128,8 @@
|
||||||
#include "math_libm.h"
|
#include "math_libm.h"
|
||||||
#include "math_private.h"
|
#include "math_private.h"
|
||||||
|
|
||||||
|
#include "SDL_assert.h"
|
||||||
|
|
||||||
static const int init_jk[] = {2,3,4,6}; /* initial value for jk */
|
static const int init_jk[] = {2,3,4,6}; /* initial value for jk */
|
||||||
|
|
||||||
static const double PIo2[] = {
|
static const double PIo2[] = {
|
||||||
|
@ -147,13 +149,19 @@ one = 1.0,
|
||||||
two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
|
two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
|
||||||
twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */
|
twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */
|
||||||
|
|
||||||
int32_t attribute_hidden __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2)
|
int32_t attribute_hidden __kernel_rem_pio2(double *x, double *y, int e0, int nx, const unsigned int prec, const int32_t *ipio2)
|
||||||
{
|
{
|
||||||
int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
|
int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
|
||||||
double z,fw,f[20],fq[20],q[20];
|
double z,fw,f[20],fq[20],q[20];
|
||||||
|
|
||||||
|
if (nx < 1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* initialize jk*/
|
/* initialize jk*/
|
||||||
|
SDL_assert(prec < SDL_arraysize(init_jk));
|
||||||
jk = init_jk[prec];
|
jk = init_jk[prec];
|
||||||
|
SDL_assert(jk > 0);
|
||||||
jp = jk;
|
jp = jk;
|
||||||
|
|
||||||
/* determine jx,jv,q0, note that 3>q0 */
|
/* determine jx,jv,q0, note that 3>q0 */
|
||||||
|
@ -164,6 +172,7 @@ int32_t attribute_hidden __kernel_rem_pio2(double *x, double *y, int e0, int nx,
|
||||||
/* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */
|
/* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */
|
||||||
j = jv-jx; m = jx+jk;
|
j = jv-jx; m = jx+jk;
|
||||||
for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (double) ipio2[j];
|
for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (double) ipio2[j];
|
||||||
|
for(i=m+1;i<SDL_arraysize(f);i++) f[i] = zero;
|
||||||
|
|
||||||
/* compute q[0],q[1],...q[jk] */
|
/* compute q[0],q[1],...q[jk] */
|
||||||
for (i=0;i<=jk;i++) {
|
for (i=0;i<=jk;i++) {
|
||||||
|
@ -179,6 +188,7 @@ recompute:
|
||||||
iq[i] = (int32_t)(z-two24*fw);
|
iq[i] = (int32_t)(z-two24*fw);
|
||||||
z = q[j-1]+fw;
|
z = q[j-1]+fw;
|
||||||
}
|
}
|
||||||
|
iq[jz] = 0;
|
||||||
|
|
||||||
/* compute n */
|
/* compute n */
|
||||||
z = scalbn(z,q0); /* actual value of z */
|
z = scalbn(z,q0); /* actual value of z */
|
||||||
|
@ -238,7 +248,8 @@ recompute:
|
||||||
/* chop off zero terms */
|
/* chop off zero terms */
|
||||||
if(z==0.0) {
|
if(z==0.0) {
|
||||||
jz -= 1; q0 -= 24;
|
jz -= 1; q0 -= 24;
|
||||||
while(iq[jz]==0) { jz--; q0-=24;}
|
SDL_assert(jz >= 0);
|
||||||
|
while(iq[jz]==0) { jz--; SDL_assert(jz >= 0); q0-=24;}
|
||||||
} else { /* break z into 24-bit if necessary */
|
} else { /* break z into 24-bit if necessary */
|
||||||
z = scalbn(z,-q0);
|
z = scalbn(z,-q0);
|
||||||
if(z>=two24) {
|
if(z>=two24) {
|
||||||
|
|
|
@ -221,7 +221,7 @@ __ieee754_sqrt(double)
|
||||||
extern double __kernel_sin(double, double, int) attribute_hidden;
|
extern double __kernel_sin(double, double, int) attribute_hidden;
|
||||||
extern double __kernel_cos(double, double) attribute_hidden;
|
extern double __kernel_cos(double, double) attribute_hidden;
|
||||||
extern double __kernel_tan(double, double, int) attribute_hidden;
|
extern double __kernel_tan(double, double, int) attribute_hidden;
|
||||||
extern int32_t __kernel_rem_pio2(double *, double *, int, int, int,
|
extern int32_t __kernel_rem_pio2(double *, double *, int, int, const unsigned int,
|
||||||
const int32_t *) attribute_hidden;
|
const int32_t *) attribute_hidden;
|
||||||
|
|
||||||
#endif /* _MATH_PRIVATE_H_ */
|
#endif /* _MATH_PRIVATE_H_ */
|
||||||
|
|
Loading…
Reference in New Issue