SDL  2.0
SDL_stdlib.c File Reference
#include "../SDL_internal.h"
#include "SDL_stdinc.h"
#include "../libm/math_libm.h"
+ Include dependency graph for SDL_stdlib.c:

Go to the source code of this file.

Functions

double SDL_atan (double x)
float SDL_atanf (float x)
double SDL_atan2 (double x, double y)
float SDL_atan2f (float x, float y)
double SDL_acos (double val)
float SDL_acosf (float val)
double SDL_asin (double val)
float SDL_asinf (float val)
double SDL_ceil (double x)
float SDL_ceilf (float x)
double SDL_copysign (double x, double y)
float SDL_copysignf (float x, float y)
double SDL_cos (double x)
float SDL_cosf (float x)
double SDL_exp (double x)
float SDL_expf (float x)
double SDL_fabs (double x)
float SDL_fabsf (float x)
double SDL_floor (double x)
float SDL_floorf (float x)
double SDL_fmod (double x, double y)
float SDL_fmodf (float x, float y)
double SDL_log (double x)
float SDL_logf (float x)
double SDL_log10 (double x)
float SDL_log10f (float x)
double SDL_pow (double x, double y)
float SDL_powf (float x, float y)
double SDL_scalbn (double x, int n)
float SDL_scalbnf (float x, int n)
double SDL_sin (double x)
float SDL_sinf (float x)
double SDL_sqrt (double x)
float SDL_sqrtf (float x)
double SDL_tan (double x)
float SDL_tanf (float x)
int SDL_abs (int x)
int SDL_isdigit (int x)
int SDL_isspace (int x)
int SDL_toupper (int x)
int SDL_tolower (int x)

Function Documentation

int SDL_abs ( int  x)

Definition at line 429 of file SDL_stdlib.c.

{
#if defined(HAVE_ABS)
return abs(x);
#else
return ((x) < 0 ? -(x) : (x));
#endif
}
double SDL_acos ( double  val)

Definition at line 75 of file SDL_stdlib.c.

References SDL_atan, and SDL_sqrt.

{
#if defined(HAVE_ACOS)
return acos(val);
#else
double result;
if (val == -1.0) {
result = M_PI;
} else {
result = SDL_atan(SDL_sqrt(1.0 - val * val) / val);
if (result < 0.0)
{
result += M_PI;
}
}
return result;
#endif
}
float SDL_acosf ( float  val)

Definition at line 95 of file SDL_stdlib.c.

References SDL_acos.

{
#if defined(HAVE_ACOSF)
return acosf(val);
#else
return (float)SDL_acos((double)val);
#endif
}
double SDL_asin ( double  val)

Definition at line 105 of file SDL_stdlib.c.

References SDL_acos.

{
#if defined(HAVE_ASIN)
return asin(val);
#else
double result;
if (val == -1.0) {
result = -(M_PI / 2.0);
} else {
result = (M_PI / 2.0) - SDL_acos(val);
}
return result;
#endif
}
float SDL_asinf ( float  val)

Definition at line 121 of file SDL_stdlib.c.

References SDL_asin.

{
#if defined(HAVE_ASINF)
return asinf(val);
#else
return (float)SDL_asin((double)val);
#endif
}
double SDL_atan ( double  x)

Definition at line 35 of file SDL_stdlib.c.

References atan(), and SDL_uclibc_atan().

{
#if defined(HAVE_ATAN)
return atan(x);
#else
return SDL_uclibc_atan(x);
#endif
}
double SDL_atan2 ( double  x,
double  y 
)

Definition at line 55 of file SDL_stdlib.c.

References SDL_uclibc_atan2().

{
#if defined(HAVE_ATAN2)
return atan2(x, y);
#else
return SDL_uclibc_atan2(x, y);
#endif
}
float SDL_atan2f ( float  x,
float  y 
)

Definition at line 65 of file SDL_stdlib.c.

References SDL_atan2.

{
#if defined(HAVE_ATAN2F)
return atan2f(x, y);
#else
return (float)SDL_atan2((double)x, (double)y);
#endif
}
float SDL_atanf ( float  x)

Definition at line 45 of file SDL_stdlib.c.

References SDL_atan.

{
#if defined(HAVE_ATANF)
return atanf(x);
#else
return (float)SDL_atan((double)x);
#endif
}
double SDL_ceil ( double  x)

Definition at line 131 of file SDL_stdlib.c.

References SDL_floor.

{
#if defined(HAVE_CEIL)
return ceil(x);
#else
double integer = SDL_floor(x);
double fraction = x - integer;
if (fraction > 0.0) {
integer += 1.0;
}
return integer;
#endif /* HAVE_CEIL */
}
float SDL_ceilf ( float  x)

Definition at line 146 of file SDL_stdlib.c.

References SDL_ceil.

{
#if defined(HAVE_CEILF)
return ceilf(x);
#else
return (float)SDL_ceil((float)x);
#endif
}
double SDL_copysign ( double  x,
double  y 
)

Definition at line 156 of file SDL_stdlib.c.

References copysign(), and SDL_uclibc_copysign().

{
#if defined(HAVE_COPYSIGN)
return copysign(x, y);
#elif defined(HAVE__COPYSIGN)
return _copysign(x, y);
#elif defined(__WATCOMC__) && defined(__386__)
/* this is nasty as hell, but it works.. */
unsigned int *xi = (unsigned int *) &x,
*yi = (unsigned int *) &y;
xi[1] = (yi[1] & 0x80000000) | (xi[1] & 0x7fffffff);
return x;
#else
#endif /* HAVE_COPYSIGN */
}
float SDL_copysignf ( float  x,
float  y 
)

Definition at line 174 of file SDL_stdlib.c.

References SDL_copysign.

{
#if defined(HAVE_COPYSIGNF)
return copysignf(x, y);
#else
return (float)SDL_copysign((double)x, (double)y);
#endif
}
double SDL_cos ( double  x)

Definition at line 184 of file SDL_stdlib.c.

References cos(), and SDL_uclibc_cos().

{
#if defined(HAVE_COS)
return cos(x);
#else
return SDL_uclibc_cos(x);
#endif
}
float SDL_cosf ( float  x)

Definition at line 194 of file SDL_stdlib.c.

References SDL_cos.

{
#if defined(HAVE_COSF)
return cosf(x);
#else
return (float)SDL_cos((double)x);
#endif
}
double SDL_exp ( double  x)

Definition at line 204 of file SDL_stdlib.c.

References SDL_uclibc_exp().

{
#if defined(HAVE_EXP)
return exp(x);
#else
return SDL_uclibc_exp(x);
#endif
}
float SDL_expf ( float  x)

Definition at line 214 of file SDL_stdlib.c.

References SDL_exp.

{
#if defined(HAVE_EXPF)
return expf(x);
#else
return (float)SDL_exp((double)x);
#endif
}
double SDL_fabs ( double  x)

Definition at line 224 of file SDL_stdlib.c.

References fabs(), and SDL_uclibc_fabs().

{
#if defined(HAVE_FABS)
return fabs(x);
#else
return SDL_uclibc_fabs(x);
#endif
}
float SDL_fabsf ( float  x)

Definition at line 234 of file SDL_stdlib.c.

References SDL_fabs.

{
#if defined(HAVE_FABSF)
return fabsf(x);
#else
return (float)SDL_fabs((double)x);
#endif
}
double SDL_floor ( double  x)

Definition at line 244 of file SDL_stdlib.c.

References floor(), and SDL_uclibc_floor().

{
#if defined(HAVE_FLOOR)
return floor(x);
#else
#endif
}
float SDL_floorf ( float  x)

Definition at line 254 of file SDL_stdlib.c.

References SDL_floor.

{
#if defined(HAVE_FLOORF)
return floorf(x);
#else
return (float)SDL_floor((double)x);
#endif
}
double SDL_fmod ( double  x,
double  y 
)

Definition at line 264 of file SDL_stdlib.c.

References SDL_uclibc_fmod().

{
#if defined(HAVE_FMOD)
return fmod(x, y);
#else
return SDL_uclibc_fmod(x, y);
#endif
}
float SDL_fmodf ( float  x,
float  y 
)

Definition at line 274 of file SDL_stdlib.c.

References SDL_fmod.

{
#if defined(HAVE_FMODF)
return fmodf(x, y);
#else
return (float)SDL_fmod((double)x, (double)y);
#endif
}
int SDL_isdigit ( int  x)

Definition at line 444 of file SDL_stdlib.c.

{ return ((x) >= '0') && ((x) <= '9'); }
int SDL_isspace ( int  x)

Definition at line 445 of file SDL_stdlib.c.

{ return ((x) == ' ') || ((x) == '\t') || ((x) == '\r') || ((x) == '\n') || ((x) == '\f') || ((x) == '\v'); }
double SDL_log ( double  x)

Definition at line 284 of file SDL_stdlib.c.

References SDL_uclibc_log().

{
#if defined(HAVE_LOG)
return log(x);
#else
return SDL_uclibc_log(x);
#endif
}
double SDL_log10 ( double  x)

Definition at line 304 of file SDL_stdlib.c.

References SDL_uclibc_log10().

{
#if defined(HAVE_LOG10)
return log10(x);
#else
#endif
}
float SDL_log10f ( float  x)

Definition at line 314 of file SDL_stdlib.c.

References SDL_log10.

{
#if defined(HAVE_LOG10F)
return log10f(x);
#else
return (float)SDL_log10((double)x);
#endif
}
float SDL_logf ( float  x)

Definition at line 294 of file SDL_stdlib.c.

References SDL_log.

{
#if defined(HAVE_LOGF)
return logf(x);
#else
return (float)SDL_log((double)x);
#endif
}
double SDL_pow ( double  x,
double  y 
)

Definition at line 324 of file SDL_stdlib.c.

References SDL_uclibc_pow().

{
#if defined(HAVE_POW)
return pow(x, y);
#else
return SDL_uclibc_pow(x, y);
#endif
}
float SDL_powf ( float  x,
float  y 
)

Definition at line 334 of file SDL_stdlib.c.

References SDL_pow.

{
#if defined(HAVE_POWF)
return powf(x, y);
#else
return (float)SDL_pow((double)x, (double)y);
#endif
}
double SDL_scalbn ( double  x,
int  n 
)

Definition at line 344 of file SDL_stdlib.c.

References scalbn, and SDL_uclibc_scalbn().

{
#if defined(HAVE_SCALBN)
return scalbn(x, n);
#elif defined(HAVE__SCALB)
return _scalb(x, n);
#elif defined(HAVE_LIBC) && defined(HAVE_FLOAT_H) && (FLT_RADIX == 2)
/* from scalbn(3): If FLT_RADIX equals 2 (which is
* usual), then scalbn() is equivalent to ldexp(3). */
return ldexp(x, n);
#else
return SDL_uclibc_scalbn(x, n);
#endif
}
float SDL_scalbnf ( float  x,
int  n 
)

Definition at line 360 of file SDL_stdlib.c.

References SDL_scalbn.

{
#if defined(HAVE_SCALBNF)
return scalbnf(x, n);
#else
return (float)SDL_scalbn((double)x, n);
#endif
}
double SDL_sin ( double  x)

Definition at line 370 of file SDL_stdlib.c.

References SDL_uclibc_sin(), and sin().

{
#if defined(HAVE_SIN)
return sin(x);
#else
return SDL_uclibc_sin(x);
#endif
}
float SDL_sinf ( float  x)

Definition at line 380 of file SDL_stdlib.c.

References SDL_sin.

{
#if defined(HAVE_SINF)
return sinf(x);
#else
return (float)SDL_sin((double)x);
#endif
}
double SDL_sqrt ( double  x)

Definition at line 390 of file SDL_stdlib.c.

References SDL_uclibc_sqrt().

{
#if defined(HAVE_SQRT)
return sqrt(x);
#else
return SDL_uclibc_sqrt(x);
#endif
}
float SDL_sqrtf ( float  x)

Definition at line 400 of file SDL_stdlib.c.

References SDL_sqrt.

{
#if defined(HAVE_SQRTF)
return sqrtf(x);
#else
return (float)SDL_sqrt((double)x);
#endif
}
double SDL_tan ( double  x)

Definition at line 410 of file SDL_stdlib.c.

References SDL_uclibc_tan(), and tan().

{
#if defined(HAVE_TAN)
return tan(x);
#else
return SDL_uclibc_tan(x);
#endif
}
float SDL_tanf ( float  x)

Definition at line 420 of file SDL_stdlib.c.

References SDL_tan.

{
#if defined(HAVE_TANF)
return tanf(x);
#else
return (float)SDL_tan((double)x);
#endif
}
int SDL_tolower ( int  x)

Definition at line 447 of file SDL_stdlib.c.

{ return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); }
int SDL_toupper ( int  x)

Definition at line 446 of file SDL_stdlib.c.

{ return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); }