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_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 409 of file SDL_stdlib.c.

References SDL_isdigit(), SDL_isspace(), SDL_tolower(), and SDL_toupper().

410 {
411 #if defined(HAVE_ABS)
412  return abs(x);
413 #else
414  return ((x) < 0 ? -(x) : (x));
415 #endif
416 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_acos()

double SDL_acos ( double  val)

Definition at line 75 of file SDL_stdlib.c.

References SDL_atan(), and SDL_sqrt().

Referenced by SDL_acosf(), SDL_asin(), and SDL_memset4().

76 {
77 #if defined(HAVE_ACOS)
78  return acos(val);
79 #else
80  double result;
81  if (val == -1.0) {
82  result = M_PI;
83  } else {
84  result = SDL_atan(SDL_sqrt(1.0 - val * val) / val);
85  if (result < 0.0)
86  {
87  result += M_PI;
88  }
89  }
90  return result;
91 #endif
92 }
GLuint64EXT * result
double SDL_sqrt(double x)
Definition: SDL_stdlib.c:370
double SDL_atan(double x)
Definition: SDL_stdlib.c:35
GLuint GLfloat * val

◆ SDL_acosf()

float SDL_acosf ( float  val)

Definition at line 95 of file SDL_stdlib.c.

References SDL_acos().

Referenced by SDL_memset4().

96 {
97 #if defined(HAVE_ACOSF)
98  return acosf(val);
99 #else
100  return (float)SDL_acos((double)val);
101 #endif
102 }
double SDL_acos(double val)
Definition: SDL_stdlib.c:75
GLuint GLfloat * val

◆ SDL_asin()

double SDL_asin ( double  val)

Definition at line 105 of file SDL_stdlib.c.

References SDL_acos().

Referenced by SDL_asinf(), and SDL_memset4().

106 {
107 #if defined(HAVE_ASIN)
108  return asin(val);
109 #else
110  double result;
111  if (val == -1.0) {
112  result = -(M_PI / 2.0);
113  } else {
114  result = (M_PI / 2.0) - SDL_acos(val);
115  }
116  return result;
117 #endif
118 }
GLuint64EXT * result
double SDL_acos(double val)
Definition: SDL_stdlib.c:75
GLuint GLfloat * val

◆ SDL_asinf()

float SDL_asinf ( float  val)

Definition at line 121 of file SDL_stdlib.c.

References SDL_asin().

Referenced by SDL_memset4().

122 {
123 #if defined(HAVE_ASINF)
124  return asinf(val);
125 #else
126  return (float)SDL_asin((double)val);
127 #endif
128 }
GLuint GLfloat * val
double SDL_asin(double val)
Definition: SDL_stdlib.c:105

◆ SDL_atan()

double SDL_atan ( double  x)

Definition at line 35 of file SDL_stdlib.c.

References atan(), and SDL_uclibc_atan().

Referenced by SDL_acos(), SDL_atanf(), and SDL_memset4().

36 {
37 #if defined(HAVE_ATAN)
38  return atan(x);
39 #else
40  return SDL_uclibc_atan(x);
41 #endif
42 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_atan(double x)
double atan(double x)
Definition: s_atan.c:67

◆ SDL_atan2()

double SDL_atan2 ( double  x,
double  y 
)

Definition at line 55 of file SDL_stdlib.c.

References SDL_uclibc_atan2().

Referenced by SDL_atan2f(), and SDL_memset4().

56 {
57 #if defined(HAVE_ATAN2)
58  return atan2(x, y);
59 #else
60  return SDL_uclibc_atan2(x, y);
61 #endif
62 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_atan2(double y, double x)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574

◆ SDL_atan2f()

float SDL_atan2f ( float  x,
float  y 
)

Definition at line 65 of file SDL_stdlib.c.

References SDL_atan2().

Referenced by SDL_memset4().

66 {
67 #if defined(HAVE_ATAN2F)
68  return atan2f(x, y);
69 #else
70  return (float)SDL_atan2((double)x, (double)y);
71 #endif
72 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
double SDL_atan2(double x, double y)
Definition: SDL_stdlib.c:55

◆ SDL_atanf()

float SDL_atanf ( float  x)

Definition at line 45 of file SDL_stdlib.c.

References SDL_atan().

Referenced by SDL_memset4().

46 {
47 #if defined(HAVE_ATANF)
48  return atanf(x);
49 #else
50  return (float)SDL_atan((double)x);
51 #endif
52 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_atan(double x)
Definition: SDL_stdlib.c:35

◆ SDL_ceil()

double SDL_ceil ( double  x)

Definition at line 131 of file SDL_stdlib.c.

References SDL_floor().

Referenced by SDL_ceilf(), and SDL_memset4().

132 {
133 #if defined(HAVE_CEIL)
134  return ceil(x);
135 #else
136  double integer = SDL_floor(x);
137  double fraction = x - integer;
138  if (fraction > 0.0) {
139  integer += 1.0;
140  }
141  return integer;
142 #endif /* HAVE_CEIL */
143 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_floor(double x)
Definition: SDL_stdlib.c:224

◆ SDL_ceilf()

float SDL_ceilf ( float  x)

Definition at line 146 of file SDL_stdlib.c.

References SDL_ceil().

Referenced by SDL_memset4().

147 {
148 #if defined(HAVE_CEILF)
149  return ceilf(x);
150 #else
151  return (float)SDL_ceil((float)x);
152 #endif
153 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_ceil(double x)
Definition: SDL_stdlib.c:131

◆ SDL_copysign()

double SDL_copysign ( double  x,
double  y 
)

Definition at line 156 of file SDL_stdlib.c.

References copysign(), and SDL_uclibc_copysign().

Referenced by SDL_copysignf(), and SDL_memset4().

157 {
158 #if defined(HAVE_COPYSIGN)
159  return copysign(x, y);
160 #elif defined(HAVE__COPYSIGN)
161  return _copysign(x, y);
162 #elif defined(__WATCOMC__) && defined(__386__)
163  /* this is nasty as hell, but it works.. */
164  unsigned int *xi = (unsigned int *) &x,
165  *yi = (unsigned int *) &y;
166  xi[1] = (yi[1] & 0x80000000) | (xi[1] & 0x7fffffff);
167  return x;
168 #else
169  return SDL_uclibc_copysign(x, y);
170 #endif /* HAVE_COPYSIGN */
171 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_copysign(double x, double y)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
double copysign(double x, double y)
Definition: s_copysign.c:21

◆ SDL_copysignf()

float SDL_copysignf ( float  x,
float  y 
)

Definition at line 174 of file SDL_stdlib.c.

References SDL_copysign().

Referenced by SDL_memset4().

175 {
176 #if defined(HAVE_COPYSIGNF)
177  return copysignf(x, y);
178 #else
179  return (float)SDL_copysign((double)x, (double)y);
180 #endif
181 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
double SDL_copysign(double x, double y)
Definition: SDL_stdlib.c:156

◆ SDL_cos()

double SDL_cos ( double  x)

Definition at line 184 of file SDL_stdlib.c.

References cos(), and SDL_uclibc_cos().

Referenced by SDL_cosf(), and SDL_memset4().

185 {
186 #if defined(HAVE_COS)
187  return cos(x);
188 #else
189  return SDL_uclibc_cos(x);
190 #endif
191 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_cos(double x)
double cos(double x)
Definition: s_cos.c:46

◆ SDL_cosf()

float SDL_cosf ( float  x)

Definition at line 194 of file SDL_stdlib.c.

References SDL_cos().

Referenced by SDL_memset4().

195 {
196 #if defined(HAVE_COSF)
197  return cosf(x);
198 #else
199  return (float)SDL_cos((double)x);
200 #endif
201 }
double SDL_cos(double x)
Definition: SDL_stdlib.c:184
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_fabs()

double SDL_fabs ( double  x)

Definition at line 204 of file SDL_stdlib.c.

References fabs(), and SDL_uclibc_fabs().

Referenced by SDL_fabsf(), and SDL_memset4().

205 {
206 #if defined(HAVE_FABS)
207  return fabs(x);
208 #else
209  return SDL_uclibc_fabs(x);
210 #endif
211 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_fabs(double x)
double fabs(double x)
Definition: s_fabs.c:22

◆ SDL_fabsf()

float SDL_fabsf ( float  x)

Definition at line 214 of file SDL_stdlib.c.

References SDL_fabs().

Referenced by SDL_memset4().

215 {
216 #if defined(HAVE_FABSF)
217  return fabsf(x);
218 #else
219  return (float)SDL_fabs((double)x);
220 #endif
221 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_fabs(double x)
Definition: SDL_stdlib.c:204

◆ SDL_floor()

double SDL_floor ( double  x)

Definition at line 224 of file SDL_stdlib.c.

References floor(), and SDL_uclibc_floor().

Referenced by SDL_ceil(), SDL_floorf(), and SDL_memset4().

225 {
226 #if defined(HAVE_FLOOR)
227  return floor(x);
228 #else
229  return SDL_uclibc_floor(x);
230 #endif
231 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_floor(double x)
double floor(double x)
Definition: s_floor.c:29

◆ SDL_floorf()

float SDL_floorf ( float  x)

Definition at line 234 of file SDL_stdlib.c.

References SDL_floor().

Referenced by SDL_memset4().

235 {
236 #if defined(HAVE_FLOORF)
237  return floorf(x);
238 #else
239  return (float)SDL_floor((double)x);
240 #endif
241 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_floor(double x)
Definition: SDL_stdlib.c:224

◆ SDL_fmod()

double SDL_fmod ( double  x,
double  y 
)

Definition at line 244 of file SDL_stdlib.c.

References SDL_uclibc_fmod().

Referenced by SDL_fmodf(), and SDL_memset4().

245 {
246 #if defined(HAVE_FMOD)
247  return fmod(x, y);
248 #else
249  return SDL_uclibc_fmod(x, y);
250 #endif
251 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
double SDL_uclibc_fmod(double x, double y)

◆ SDL_fmodf()

float SDL_fmodf ( float  x,
float  y 
)

Definition at line 254 of file SDL_stdlib.c.

References SDL_fmod().

Referenced by SDL_memset4().

255 {
256 #if defined(HAVE_FMODF)
257  return fmodf(x, y);
258 #else
259  return (float)SDL_fmod((double)x, (double)y);
260 #endif
261 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_fmod(double x, double y)
Definition: SDL_stdlib.c:244
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574

◆ SDL_isdigit()

int SDL_isdigit ( int  x)

Definition at line 424 of file SDL_stdlib.c.

Referenced by SDL_abs().

424 { return ((x) >= '0') && ((x) <= '9'); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_isspace()

int SDL_isspace ( int  x)

Definition at line 425 of file SDL_stdlib.c.

Referenced by SDL_abs().

425 { return ((x) == ' ') || ((x) == '\t') || ((x) == '\r') || ((x) == '\n') || ((x) == '\f') || ((x) == '\v'); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_log()

double SDL_log ( double  x)

Definition at line 264 of file SDL_stdlib.c.

References SDL_uclibc_log().

Referenced by SDL_logf(), and SDL_memset4().

265 {
266 #if defined(HAVE_LOG)
267  return log(x);
268 #else
269  return SDL_uclibc_log(x);
270 #endif
271 }
double SDL_uclibc_log(double x)
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_log10()

double SDL_log10 ( double  x)

Definition at line 284 of file SDL_stdlib.c.

References SDL_uclibc_log10().

Referenced by SDL_log10f(), and SDL_memset4().

285 {
286 #if defined(HAVE_LOG10)
287  return log10(x);
288 #else
289  return SDL_uclibc_log10(x);
290 #endif
291 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_log10(double x)

◆ SDL_log10f()

float SDL_log10f ( float  x)

Definition at line 294 of file SDL_stdlib.c.

References SDL_log10().

Referenced by SDL_memset4().

295 {
296 #if defined(HAVE_LOG10F)
297  return log10f(x);
298 #else
299  return (float)SDL_log10((double)x);
300 #endif
301 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_log10(double x)
Definition: SDL_stdlib.c:284

◆ SDL_logf()

float SDL_logf ( float  x)

Definition at line 274 of file SDL_stdlib.c.

References SDL_log().

Referenced by SDL_memset4().

275 {
276 #if defined(HAVE_LOGF)
277  return logf(x);
278 #else
279  return (float)SDL_log((double)x);
280 #endif
281 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_log(double x)
Definition: SDL_stdlib.c:264

◆ SDL_pow()

double SDL_pow ( double  x,
double  y 
)

Definition at line 304 of file SDL_stdlib.c.

References SDL_uclibc_pow().

Referenced by SDL_memset4(), and SDL_powf().

305 {
306 #if defined(HAVE_POW)
307  return pow(x, y);
308 #else
309  return SDL_uclibc_pow(x, y);
310 #endif
311 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_pow(double x, double y)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574

◆ SDL_powf()

float SDL_powf ( float  x,
float  y 
)

Definition at line 314 of file SDL_stdlib.c.

References SDL_pow().

Referenced by SDL_memset4().

315 {
316 #if defined(HAVE_POWF)
317  return powf(x, y);
318 #else
319  return (float)SDL_pow((double)x, (double)y);
320 #endif
321 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
double SDL_pow(double x, double y)
Definition: SDL_stdlib.c:304

◆ SDL_scalbn()

double SDL_scalbn ( double  x,
int  n 
)

Definition at line 324 of file SDL_stdlib.c.

References scalbn, and SDL_uclibc_scalbn().

Referenced by SDL_memset4(), and SDL_scalbnf().

325 {
326 #if defined(HAVE_SCALBN)
327  return scalbn(x, n);
328 #elif defined(HAVE__SCALB)
329  return _scalb(x, n);
330 #elif defined(HAVE_LIBC) && defined(HAVE_FLOAT_H) && (FLT_RADIX == 2)
331 /* from scalbn(3): If FLT_RADIX equals 2 (which is
332  * usual), then scalbn() is equivalent to ldexp(3). */
333  return ldexp(x, n);
334 #else
335  return SDL_uclibc_scalbn(x, n);
336 #endif
337 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
#define scalbn
Definition: math_private.h:45
GLdouble n
double SDL_uclibc_scalbn(double x, int n)

◆ SDL_scalbnf()

float SDL_scalbnf ( float  x,
int  n 
)

Definition at line 340 of file SDL_stdlib.c.

References SDL_scalbn().

Referenced by SDL_memset4().

341 {
342 #if defined(HAVE_SCALBNF)
343  return scalbnf(x, n);
344 #else
345  return (float)SDL_scalbn((double)x, n);
346 #endif
347 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_scalbn(double x, int n)
Definition: SDL_stdlib.c:324
GLdouble n

◆ SDL_sin()

double SDL_sin ( double  x)

Definition at line 350 of file SDL_stdlib.c.

References SDL_uclibc_sin(), and sin().

Referenced by SDL_memset4(), and SDL_sinf().

351 {
352 #if defined(HAVE_SIN)
353  return sin(x);
354 #else
355  return SDL_uclibc_sin(x);
356 #endif
357 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_sin(double x)
double sin(double x)
Definition: s_sin.c:46

◆ SDL_sinf()

float SDL_sinf ( float  x)

Definition at line 360 of file SDL_stdlib.c.

References SDL_sin().

Referenced by SDL_memset4().

361 {
362 #if defined(HAVE_SINF)
363  return sinf(x);
364 #else
365  return (float)SDL_sin((double)x);
366 #endif
367 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_sin(double x)
Definition: SDL_stdlib.c:350

◆ SDL_sqrt()

double SDL_sqrt ( double  x)

Definition at line 370 of file SDL_stdlib.c.

References SDL_uclibc_sqrt().

Referenced by SDL_acos(), SDL_memset4(), and SDL_sqrtf().

371 {
372 #if defined(HAVE_SQRT)
373  return sqrt(x);
374 #else
375  return SDL_uclibc_sqrt(x);
376 #endif
377 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_sqrt(double x)

◆ SDL_sqrtf()

float SDL_sqrtf ( float  x)

Definition at line 380 of file SDL_stdlib.c.

References SDL_sqrt().

Referenced by SDL_memset4().

381 {
382 #if defined(HAVE_SQRTF)
383  return sqrtf(x);
384 #else
385  return (float)SDL_sqrt((double)x);
386 #endif
387 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_sqrt(double x)
Definition: SDL_stdlib.c:370

◆ SDL_tan()

double SDL_tan ( double  x)

Definition at line 390 of file SDL_stdlib.c.

References SDL_uclibc_tan(), and tan().

Referenced by SDL_memset4(), and SDL_tanf().

391 {
392 #if defined(HAVE_TAN)
393  return tan(x);
394 #else
395  return SDL_uclibc_tan(x);
396 #endif
397 }
double tan(double x)
Definition: s_tan.c:45
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_tan(double x)

◆ SDL_tanf()

float SDL_tanf ( float  x)

Definition at line 400 of file SDL_stdlib.c.

References SDL_tan().

Referenced by SDL_memset4().

401 {
402 #if defined(HAVE_TANF)
403  return tanf(x);
404 #else
405  return (float)SDL_tan((double)x);
406 #endif
407 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_tan(double x)
Definition: SDL_stdlib.c:390

◆ SDL_tolower()

int SDL_tolower ( int  x)

Definition at line 427 of file SDL_stdlib.c.

References i, L1, L2, L3, L4, L5, L6, memcpy, and pop.

Referenced by SDL_abs().

427 { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_toupper()

int SDL_toupper ( int  x)

Definition at line 426 of file SDL_stdlib.c.

Referenced by SDL_abs().

426 { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574