Added float versions of SDL's math functions

This commit is contained in:
Sam Lantinga 2017-11-04 15:34:14 -07:00
parent bba90a6562
commit 34502143d9
9 changed files with 203 additions and 29 deletions

View file

@ -38,7 +38,17 @@ SDL_atan(double x)
return atan(x);
#else
return SDL_uclibc_atan(x);
#endif /* HAVE_ATAN */
#endif
}
float
SDL_atanf(float x)
{
#if defined(HAVE_ATANF)
return atanf(x);
#else
return (float)SDL_atan((double)x);
#endif
}
double
@ -48,7 +58,17 @@ SDL_atan2(double x, double y)
return atan2(x, y);
#else
return SDL_uclibc_atan2(x, y);
#endif /* HAVE_ATAN2 */
#endif
}
float
SDL_atan2f(float x, float y)
{
#if defined(HAVE_ATAN2F)
return atan2f(x, y);
#else
return (float)SDL_atan2((double)x, (double)y);
#endif
}
double
@ -71,6 +91,16 @@ SDL_acos(double val)
#endif
}
float
SDL_acosf(float val)
{
#if defined(HAVE_ACOSF)
return acosf(val);
#else
return (float)SDL_acos((double)val);
#endif
}
double
SDL_asin(double val)
{
@ -87,6 +117,16 @@ SDL_asin(double val)
#endif
}
float
SDL_asinf(float val)
{
#if defined(HAVE_ASINF)
return asinf(val);
#else
return (float)SDL_asin((double)val);
#endif
}
double
SDL_ceil(double x)
{
@ -102,6 +142,16 @@ SDL_ceil(double x)
#endif /* HAVE_CEIL */
}
float
SDL_ceilf(float x)
{
#if defined(HAVE_CEILF)
return ceilf(x);
#else
return (float)ceil((float)x);
#endif
}
double
SDL_copysign(double x, double y)
{
@ -120,6 +170,16 @@ SDL_copysign(double x, double y)
#endif /* HAVE_COPYSIGN */
}
float
SDL_copysignf(float x, float y)
{
#if defined(HAVE_COPYSIGNF)
return copysignf(x, y);
#else
return (float)SDL_copysign((double)x, (double)y);
#endif
}
double
SDL_cos(double x)
{
@ -127,7 +187,7 @@ SDL_cos(double x)
return cos(x);
#else
return SDL_uclibc_cos(x);
#endif /* HAVE_COS */
#endif
}
float
@ -147,7 +207,17 @@ SDL_fabs(double x)
return fabs(x);
#else
return SDL_uclibc_fabs(x);
#endif /* HAVE_FABS */
#endif
}
float
SDL_fabsf(float x)
{
#if defined(HAVE_FABSF)
return fabsf(x);
#else
return (float)SDL_fabs((double)x);
#endif
}
double
@ -157,7 +227,17 @@ SDL_floor(double x)
return floor(x);
#else
return SDL_uclibc_floor(x);
#endif /* HAVE_FLOOR */
#endif
}
float
SDL_floorf(float x)
{
#if defined(HAVE_FLOORF)
return floorf(x);
#else
return (float)SDL_floor((double)x);
#endif
}
double
@ -167,7 +247,17 @@ SDL_log(double x)
return log(x);
#else
return SDL_uclibc_log(x);
#endif /* HAVE_LOG */
#endif
}
float
SDL_logf(float x)
{
#if defined(HAVE_LOGF)
return logf(x);
#else
return (float)SDL_log((double)x);
#endif
}
double
@ -177,7 +267,17 @@ SDL_pow(double x, double y)
return pow(x, y);
#else
return SDL_uclibc_pow(x, y);
#endif /* HAVE_POW */
#endif
}
float
SDL_powf(float x, float y)
{
#if defined(HAVE_POWF)
return powf(x, y);
#else
return (float)SDL_pow((double)x, (double)y);
#endif
}
double
@ -193,7 +293,17 @@ SDL_scalbn(double x, int n)
return ldexp(x, n);
#else
return SDL_uclibc_scalbn(x, n);
#endif /* HAVE_SCALBN */
#endif
}
float
SDL_scalbnf(float x, int n)
{
#if defined(HAVE_SCALBNF)
return scalbnf(x, n);
#else
return (float)SDL_scalbn((double)x, n);
#endif
}
double
@ -203,7 +313,7 @@ SDL_sin(double x)
return sin(x);
#else
return SDL_uclibc_sin(x);
#endif /* HAVE_SIN */
#endif
}
float
@ -213,7 +323,7 @@ SDL_sinf(float x)
return sinf(x);
#else
return (float)SDL_sin((double)x);
#endif /* HAVE_SINF */
#endif
}
double