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)
 
double SDL_atan2 (double x, double y)
 
double SDL_acos (double val)
 
double SDL_asin (double val)
 
double SDL_ceil (double x)
 
double SDL_copysign (double x, double y)
 
double SDL_cos (double x)
 
float SDL_cosf (float x)
 
double SDL_fabs (double x)
 
double SDL_floor (double x)
 
double SDL_log (double x)
 
double SDL_pow (double x, double y)
 
double SDL_scalbn (double 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 259 of file SDL_stdlib.c.

260 {
261 #if defined(HAVE_ABS)
262  return abs(x);
263 #else
264  return ((x) < 0 ? -(x) : (x));
265 #endif
266 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_acos ( double  val)

Definition at line 55 of file SDL_stdlib.c.

References SDL_atan(), and SDL_sqrt().

Referenced by SDL_asin().

56 {
57 #if defined(HAVE_ACOS)
58  return acos(val);
59 #else
60  double result;
61  if (val == -1.0) {
62  result = M_PI;
63  } else {
64  result = SDL_atan(SDL_sqrt(1.0 - val * val) / val);
65  if (result < 0.0)
66  {
67  result += M_PI;
68  }
69  }
70  return result;
71 #endif
72 }
GLuint64EXT * result
double SDL_sqrt(double x)
Definition: SDL_stdlib.c:220
double SDL_atan(double x)
Definition: SDL_stdlib.c:35
GLuint GLfloat * val
double SDL_asin ( double  val)

Definition at line 75 of file SDL_stdlib.c.

References SDL_acos().

76 {
77 #if defined(HAVE_ASIN)
78  return asin(val);
79 #else
80  double result;
81  if (val == -1.0) {
82  result = -(M_PI / 2.0);
83  } else {
84  result = (M_PI / 2.0) - SDL_acos(val);
85  }
86  return result;
87 #endif
88 }
GLuint64EXT * result
double SDL_acos(double val)
Definition: SDL_stdlib.c:55
GLuint GLfloat * val
double SDL_atan ( double  x)

Definition at line 35 of file SDL_stdlib.c.

References atan(), and SDL_uclibc_atan().

Referenced by SDL_acos().

36 {
37 #if defined(HAVE_ATAN)
38  return atan(x);
39 #else
40  return SDL_uclibc_atan(x);
41 #endif /* HAVE_ATAN */
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
double SDL_atan2 ( double  x,
double  y 
)

Definition at line 45 of file SDL_stdlib.c.

References SDL_uclibc_atan2().

46 {
47 #if defined(HAVE_ATAN2)
48  return atan2(x, y);
49 #else
50  return SDL_uclibc_atan2(x, y);
51 #endif /* HAVE_ATAN2 */
52 }
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
double SDL_ceil ( double  x)

Definition at line 91 of file SDL_stdlib.c.

References SDL_floor().

92 {
93 #if defined(HAVE_CEIL)
94  return ceil(x);
95 #else
96  double integer = SDL_floor(x);
97  double fraction = x - integer;
98  if (fraction > 0.0) {
99  integer += 1.0;
100  }
101  return integer;
102 #endif /* HAVE_CEIL */
103 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_floor(double x)
Definition: SDL_stdlib.c:154
double SDL_copysign ( double  x,
double  y 
)

Definition at line 106 of file SDL_stdlib.c.

References copysign, and SDL_uclibc_copysign().

107 {
108 #if defined(HAVE_COPYSIGN)
109  return copysign(x, y);
110 #elif defined(HAVE__COPYSIGN)
111  return _copysign(x, y);
112 #elif defined(__WATCOMC__) && defined(__386__)
113  /* this is nasty as hell, but it works.. */
114  unsigned int *xi = (unsigned int *) &x,
115  *yi = (unsigned int *) &y;
116  xi[1] = (yi[1] & 0x80000000) | (xi[1] & 0x7fffffff);
117  return x;
118 #else
119  return SDL_uclibc_copysign(x, y);
120 #endif /* HAVE_COPYSIGN */
121 }
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
#define copysign
Definition: math_private.h:34
double SDL_cos ( double  x)

Definition at line 124 of file SDL_stdlib.c.

References cos, and SDL_uclibc_cos().

Referenced by SDL_cosf().

125 {
126 #if defined(HAVE_COS)
127  return cos(x);
128 #else
129  return SDL_uclibc_cos(x);
130 #endif /* HAVE_COS */
131 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
#define cos
Definition: math_private.h:35
double SDL_uclibc_cos(double x)
float SDL_cosf ( float  x)

Definition at line 134 of file SDL_stdlib.c.

References SDL_cos().

135 {
136 #if defined(HAVE_COSF)
137  return cosf(x);
138 #else
139  return (float)SDL_cos((double)x);
140 #endif
141 }
double SDL_cos(double x)
Definition: SDL_stdlib.c:124
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_fabs ( double  x)

Definition at line 144 of file SDL_stdlib.c.

References fabs, and SDL_uclibc_fabs().

145 {
146 #if defined(HAVE_FABS)
147  return fabs(x);
148 #else
149  return SDL_uclibc_fabs(x);
150 #endif /* HAVE_FABS */
151 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_fabs(double x)
#define fabs
Definition: math_private.h:36
double SDL_floor ( double  x)

Definition at line 154 of file SDL_stdlib.c.

References floor, and SDL_uclibc_floor().

Referenced by SDL_ceil().

155 {
156 #if defined(HAVE_FLOOR)
157  return floor(x);
158 #else
159  return SDL_uclibc_floor(x);
160 #endif /* HAVE_FLOOR */
161 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_floor(double x)
#define floor
Definition: math_private.h:37
int SDL_isdigit ( int  x)

Definition at line 274 of file SDL_stdlib.c.

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

Definition at line 275 of file SDL_stdlib.c.

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

Definition at line 164 of file SDL_stdlib.c.

References SDL_uclibc_log().

165 {
166 #if defined(HAVE_LOG)
167  return log(x);
168 #else
169  return SDL_uclibc_log(x);
170 #endif /* HAVE_LOG */
171 }
double SDL_uclibc_log(double x)
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_pow ( double  x,
double  y 
)

Definition at line 174 of file SDL_stdlib.c.

References SDL_uclibc_pow().

175 {
176 #if defined(HAVE_POW)
177  return pow(x, y);
178 #else
179  return SDL_uclibc_pow(x, y);
180 #endif /* HAVE_POW */
181 }
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
double SDL_scalbn ( double  x,
int  n 
)

Definition at line 184 of file SDL_stdlib.c.

References scalbn, and SDL_uclibc_scalbn().

185 {
186 #if defined(HAVE_SCALBN)
187  return scalbn(x, n);
188 #elif defined(HAVE__SCALB)
189  return _scalb(x, n);
190 #elif defined(HAVE_LIBC) && defined(HAVE_FLOAT_H) && (FLT_RADIX == 2)
191 /* from scalbn(3): If FLT_RADIX equals 2 (which is
192  * usual), then scalbn() is equivalent to ldexp(3). */
193  return ldexp(x, n);
194 #else
195  return SDL_uclibc_scalbn(x, n);
196 #endif /* HAVE_SCALBN */
197 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
#define scalbn
Definition: math_private.h:40
GLdouble n
double SDL_uclibc_scalbn(double x, int n)
double SDL_sin ( double  x)

Definition at line 200 of file SDL_stdlib.c.

References SDL_uclibc_sin(), and sin.

Referenced by SDL_sinf().

201 {
202 #if defined(HAVE_SIN)
203  return sin(x);
204 #else
205  return SDL_uclibc_sin(x);
206 #endif /* HAVE_SIN */
207 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_sin(double x)
#define sin
Definition: math_private.h:41
float SDL_sinf ( float  x)

Definition at line 210 of file SDL_stdlib.c.

References SDL_sin().

211 {
212 #if defined(HAVE_SINF)
213  return sinf(x);
214 #else
215  return (float)SDL_sin((double)x);
216 #endif /* HAVE_SINF */
217 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_sin(double x)
Definition: SDL_stdlib.c:200
double SDL_sqrt ( double  x)

Definition at line 220 of file SDL_stdlib.c.

References SDL_uclibc_sqrt().

Referenced by SDL_acos(), and SDL_sqrtf().

221 {
222 #if defined(HAVE_SQRT)
223  return sqrt(x);
224 #else
225  return SDL_uclibc_sqrt(x);
226 #endif
227 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_sqrt(double x)
float SDL_sqrtf ( float  x)

Definition at line 230 of file SDL_stdlib.c.

References SDL_sqrt().

231 {
232 #if defined(HAVE_SQRTF)
233  return sqrtf(x);
234 #else
235  return (float)SDL_sqrt((double)x);
236 #endif
237 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_sqrt(double x)
Definition: SDL_stdlib.c:220
double SDL_tan ( double  x)

Definition at line 240 of file SDL_stdlib.c.

References SDL_uclibc_tan(), and tan().

Referenced by SDL_tanf().

241 {
242 #if defined(HAVE_TAN)
243  return tan(x);
244 #else
245  return SDL_uclibc_tan(x);
246 #endif
247 }
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)
float SDL_tanf ( float  x)

Definition at line 250 of file SDL_stdlib.c.

References SDL_tan().

251 {
252 #if defined(HAVE_TANF)
253  return tanf(x);
254 #else
255  return (float)SDL_tan((double)x);
256 #endif
257 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_tan(double x)
Definition: SDL_stdlib.c:240
int SDL_tolower ( int  x)

Definition at line 277 of file SDL_stdlib.c.

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

Definition at line 276 of file SDL_stdlib.c.

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