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

## SDL_abs()

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
}

## SDL_acos()

double SDL_acos | ( | double | val | ) |

Definition at line 75 of file SDL_stdlib.c.

{
#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
}

References SDL_atan(), and SDL_sqrt().

Referenced by SDL_acosf(), and SDL_asin().

## SDL_acosf()

float SDL_acosf | ( | float | val | ) |

Definition at line 95 of file SDL_stdlib.c.

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

References SDL_acos().

## SDL_asin()

double SDL_asin | ( | double | val | ) |

Definition at line 105 of file SDL_stdlib.c.

{
#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
}

References SDL_acos().

Referenced by SDL_asinf().

## SDL_asinf()

float SDL_asinf | ( | float | val | ) |

Definition at line 121 of file SDL_stdlib.c.

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

References SDL_asin().

## SDL_atan()

double SDL_atan | ( | double | x | ) |

Definition at line 35 of file SDL_stdlib.c.

{
#if defined(HAVE_ATAN)
return atan(x);
#else
return SDL_uclibc_atan(x);
#endif
}

References atan(), and SDL_uclibc_atan().

Referenced by SDL_acos(), and SDL_atanf().

## SDL_atan2()

double SDL_atan2 | ( | double | x,
|  | double | y
| ) |  |

Definition at line 55 of file SDL_stdlib.c.

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

References SDL_uclibc_atan2().

Referenced by SDL_atan2f().

## SDL_atan2f()

float SDL_atan2f | ( | float | x,
|  | float | y
| ) |  |

Definition at line 65 of file SDL_stdlib.c.

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

References SDL_atan2().

## SDL_atanf()

float SDL_atanf | ( | float | x | ) |

Definition at line 45 of file SDL_stdlib.c.

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

References SDL_atan().

## SDL_ceil()

double SDL_ceil | ( | double | x | ) |

Definition at line 131 of file SDL_stdlib.c.

{
#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 */
}

References SDL_floor().

Referenced by SDL_ceilf().

## SDL_ceilf()

float SDL_ceilf | ( | float | x | ) |

Definition at line 146 of file SDL_stdlib.c.

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

References SDL_ceil().

## SDL_copysign()

double SDL_copysign | ( | double | x,
|  | double | y
| ) |  |

Definition at line 156 of file SDL_stdlib.c.

{
#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
return SDL_uclibc_copysign(x, y);
#endif /* HAVE_COPYSIGN */
}

References copysign(), and SDL_uclibc_copysign().

Referenced by SDL_copysignf().

## SDL_copysignf()

float SDL_copysignf | ( | float | x,
|  | float | y
| ) |  |

Definition at line 174 of file SDL_stdlib.c.

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

References SDL_copysign().

## SDL_cos()

double SDL_cos | ( | double | x | ) |

Definition at line 184 of file SDL_stdlib.c.

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

References cos(), and SDL_uclibc_cos().

Referenced by SDL_cosf().

## SDL_cosf()

float SDL_cosf | ( | float | x | ) |

Definition at line 194 of file SDL_stdlib.c.

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

References SDL_cos().

## SDL_exp()

double SDL_exp | ( | double | x | ) |

Definition at line 204 of file SDL_stdlib.c.

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

References SDL_uclibc_exp().

Referenced by SDL_expf().

## SDL_expf()

float SDL_expf | ( | float | x | ) |

Definition at line 214 of file SDL_stdlib.c.

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

References SDL_exp().

## SDL_fabs()

double SDL_fabs | ( | double | x | ) |

Definition at line 224 of file SDL_stdlib.c.

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

References fabs(), and SDL_uclibc_fabs().

Referenced by SDL_fabsf().

## SDL_fabsf()

float SDL_fabsf | ( | float | x | ) |

Definition at line 234 of file SDL_stdlib.c.

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

References SDL_fabs().

## SDL_floor()

double SDL_floor | ( | double | x | ) |

Definition at line 244 of file SDL_stdlib.c.

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

References floor(), and SDL_uclibc_floor().

Referenced by SDL_ceil(), and SDL_floorf().

## SDL_floorf()

float SDL_floorf | ( | float | x | ) |

Definition at line 254 of file SDL_stdlib.c.

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

References SDL_floor().

## SDL_fmod()

double SDL_fmod | ( | double | x,
|  | double | y
| ) |  |

Definition at line 264 of file SDL_stdlib.c.

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

References SDL_uclibc_fmod().

Referenced by SDL_fmodf().

## SDL_fmodf()

float SDL_fmodf | ( | float | x,
|  | float | y
| ) |  |

Definition at line 274 of file SDL_stdlib.c.

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

References SDL_fmod().

## SDL_isdigit()

int SDL_isdigit | ( | int | x | ) |

Definition at line 444 of file SDL_stdlib.c.

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

## SDL_isspace()

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'); }

## SDL_log()

double SDL_log | ( | double | x | ) |

Definition at line 284 of file SDL_stdlib.c.

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

References SDL_uclibc_log().

Referenced by SDL_logf().

## SDL_log10()

double SDL_log10 | ( | double | x | ) |

Definition at line 304 of file SDL_stdlib.c.

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

References SDL_uclibc_log10().

Referenced by SDL_log10f().

## SDL_log10f()

float SDL_log10f | ( | float | x | ) |

Definition at line 314 of file SDL_stdlib.c.

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

References SDL_log10().

## SDL_logf()

float SDL_logf | ( | float | x | ) |

Definition at line 294 of file SDL_stdlib.c.

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

References SDL_log().

## SDL_pow()

double SDL_pow | ( | double | x,
|  | double | y
| ) |  |

Definition at line 324 of file SDL_stdlib.c.

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

References SDL_uclibc_pow().

Referenced by SDL_powf().

## SDL_powf()

float SDL_powf | ( | float | x,
|  | float | y
| ) |  |

Definition at line 334 of file SDL_stdlib.c.

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

References SDL_pow().

## SDL_scalbn()

double SDL_scalbn | ( | double | x,
|  | int | n
| ) |  |

Definition at line 344 of file SDL_stdlib.c.

{
#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
}

References scalbn, and SDL_uclibc_scalbn().

Referenced by SDL_scalbnf().

## SDL_scalbnf()

float SDL_scalbnf | ( | float | x,
|  | int | n
| ) |  |

Definition at line 360 of file SDL_stdlib.c.

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

References SDL_scalbn().

## SDL_sin()

double SDL_sin | ( | double | x | ) |

Definition at line 370 of file SDL_stdlib.c.

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

References SDL_uclibc_sin(), and sin().

Referenced by SDL_sinf().

## SDL_sinf()

float SDL_sinf | ( | float | x | ) |

Definition at line 380 of file SDL_stdlib.c.

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

References SDL_sin().

## SDL_sqrt()

double SDL_sqrt | ( | double | x | ) |

Definition at line 390 of file SDL_stdlib.c.

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

References SDL_uclibc_sqrt().

Referenced by SDL_acos(), and SDL_sqrtf().

## SDL_sqrtf()

float SDL_sqrtf | ( | float | x | ) |

Definition at line 400 of file SDL_stdlib.c.

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

References SDL_sqrt().

## SDL_tan()

double SDL_tan | ( | double | x | ) |

Definition at line 410 of file SDL_stdlib.c.

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

References SDL_uclibc_tan(), and tan().

Referenced by SDL_tanf().

## SDL_tanf()

float SDL_tanf | ( | float | x | ) |

Definition at line 420 of file SDL_stdlib.c.

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

References SDL_tan().

## SDL_tolower()

int SDL_tolower | ( | int | x | ) |

Definition at line 447 of file SDL_stdlib.c.

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

## SDL_toupper()

int SDL_toupper | ( | int | x | ) |

Definition at line 446 of file SDL_stdlib.c.

{ return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); }
SDL_floor
double SDL_floor(double x)
Definition: SDL_stdlib.c:244
fabs
double fabs(double x)
Definition: s_fabs.c:22
SDL_log10
double SDL_log10(double x)
Definition: SDL_stdlib.c:304
SDL_scalbn
double SDL_scalbn(double x, int n)
Definition: SDL_stdlib.c:344
cos
double cos(double x)
Definition: s_cos.c:46
SDL_uclibc_floor
double SDL_uclibc_floor(double x)
SDL_uclibc_fmod
double SDL_uclibc_fmod(double x, double y)
SDL_sqrt
double SDL_sqrt(double x)
Definition: SDL_stdlib.c:390
SDL_uclibc_sqrt
double SDL_uclibc_sqrt(double x)
SDL_uclibc_scalbn
double SDL_uclibc_scalbn(double x, int n)
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9432
SDL_uclibc_cos
double SDL_uclibc_cos(double x)
SDL_fmod
double SDL_fmod(double x, double y)
Definition: SDL_stdlib.c:264
n
GLdouble n
Definition: SDL_opengl_glext.h:1952
SDL_uclibc_exp
double SDL_uclibc_exp(double x)
SDL_sin
double SDL_sin(double x)
Definition: SDL_stdlib.c:370
scalbn
#define scalbn
Definition: math_private.h:46
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
SDL_uclibc_fabs
double SDL_uclibc_fabs(double x)
SDL_uclibc_atan2
double SDL_uclibc_atan2(double y, double x)
SDL_copysign
double SDL_copysign(double x, double y)
Definition: SDL_stdlib.c:156
SDL_uclibc_copysign
double SDL_uclibc_copysign(double x, double y)
SDL_asin
double SDL_asin(double val)
Definition: SDL_stdlib.c:105
SDL_uclibc_pow
double SDL_uclibc_pow(double x, double y)
tan
double tan(double x)
Definition: s_tan.c:45
SDL_atan
double SDL_atan(double x)
Definition: SDL_stdlib.c:35
copysign
double copysign(double x, double y)
Definition: s_copysign.c:21
SDL_tan
double SDL_tan(double x)
Definition: SDL_stdlib.c:410
SDL_uclibc_atan
double SDL_uclibc_atan(double x)
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
SDL_pow
double SDL_pow(double x, double y)
Definition: SDL_stdlib.c:324
atan
double atan(double x)
Definition: s_atan.c:71
SDL_fabs
double SDL_fabs(double x)
Definition: SDL_stdlib.c:224
val
GLuint GLfloat * val
Definition: SDL_opengl_glext.h:1492
SDL_ceil
double SDL_ceil(double x)
Definition: SDL_stdlib.c:131
SDL_acos
double SDL_acos(double val)
Definition: SDL_stdlib.c:75
SDL_uclibc_sin
double SDL_uclibc_sin(double x)
SDL_uclibc_log
double SDL_uclibc_log(double x)
floor
double floor(double x)
Definition: s_floor.c:33
SDL_uclibc_log10
double SDL_uclibc_log10(double x)
SDL_exp
double SDL_exp(double x)
Definition: SDL_stdlib.c:204
sin
double sin(double x)
Definition: s_sin.c:46
SDL_atan2
double SDL_atan2(double x, double y)
Definition: SDL_stdlib.c:55
SDL_cos
double SDL_cos(double x)
Definition: SDL_stdlib.c:184
SDL_log
double SDL_log(double x)
Definition: SDL_stdlib.c:284
SDL_uclibc_tan
double SDL_uclibc_tan(double x)