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

◆ SDL_abs()

int SDL_abs ( int  x)

Definition at line 249 of file SDL_stdlib.c.

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

250 {
251 #if defined(HAVE_ABS)
252  return abs(x);
253 #else
254  return ((x) < 0 ? -(x) : (x));
255 #endif
256 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567

◆ SDL_acos()

double SDL_acos ( double  val)

Definition at line 55 of file SDL_stdlib.c.

References SDL_atan(), and SDL_sqrt().

Referenced by SDL_asin(), and SDL_memset4().

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:210
double SDL_atan(double x)
Definition: SDL_stdlib.c:35
GLuint GLfloat * val

◆ SDL_asin()

double SDL_asin ( double  val)

Definition at line 75 of file SDL_stdlib.c.

References SDL_acos().

Referenced by SDL_memset4().

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

◆ 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(), and SDL_memset4().

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:1567
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 45 of file SDL_stdlib.c.

References SDL_uclibc_atan2().

Referenced by SDL_memset4().

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:1567
double SDL_uclibc_atan2(double y, double x)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567

◆ SDL_ceil()

double SDL_ceil ( double  x)

Definition at line 91 of file SDL_stdlib.c.

References SDL_floor().

Referenced by SDL_memset4().

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:1567
double SDL_floor(double x)
Definition: SDL_stdlib.c:148

◆ SDL_copysign()

double SDL_copysign ( double  x,
double  y 
)

Definition at line 106 of file SDL_stdlib.c.

References copysign, and SDL_uclibc_copysign().

Referenced by SDL_memset4().

107 {
108 #if defined(HAVE_COPYSIGN)
109  return copysign(x, y);
110 #elif defined(HAVE__COPYSIGN)
111  return _copysign(x, y);
112 #else
113  return SDL_uclibc_copysign(x, y);
114 #endif /* HAVE_COPYSIGN */
115 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_copysign(double x, double y)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
#define copysign
Definition: math_private.h:34

◆ SDL_cos()

double SDL_cos ( double  x)

Definition at line 118 of file SDL_stdlib.c.

References cos, and SDL_uclibc_cos().

Referenced by SDL_cosf(), and SDL_memset4().

119 {
120 #if defined(HAVE_COS)
121  return cos(x);
122 #else
123  return SDL_uclibc_cos(x);
124 #endif /* HAVE_COS */
125 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
#define cos
Definition: math_private.h:35
double SDL_uclibc_cos(double x)

◆ SDL_cosf()

float SDL_cosf ( float  x)

Definition at line 128 of file SDL_stdlib.c.

References SDL_cos().

Referenced by SDL_memset4().

129 {
130 #if defined(HAVE_COSF)
131  return cosf(x);
132 #else
133  return (float)SDL_cos((double)x);
134 #endif
135 }
double SDL_cos(double x)
Definition: SDL_stdlib.c:118
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567

◆ SDL_fabs()

double SDL_fabs ( double  x)

Definition at line 138 of file SDL_stdlib.c.

References fabs, and SDL_uclibc_fabs().

Referenced by SDL_memset4().

139 {
140 #if defined(HAVE_FABS)
141  return fabs(x);
142 #else
143  return SDL_uclibc_fabs(x);
144 #endif /* HAVE_FABS */
145 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_fabs(double x)
#define fabs
Definition: math_private.h:36

◆ SDL_floor()

double SDL_floor ( double  x)

Definition at line 148 of file SDL_stdlib.c.

References floor, and SDL_uclibc_floor().

Referenced by SDL_ceil(), and SDL_memset4().

149 {
150 #if defined(HAVE_FLOOR)
151  return floor(x);
152 #else
153  return SDL_uclibc_floor(x);
154 #endif /* HAVE_FLOOR */
155 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_floor(double x)
#define floor
Definition: math_private.h:37

◆ SDL_isdigit()

int SDL_isdigit ( int  x)

Definition at line 264 of file SDL_stdlib.c.

Referenced by SDL_abs().

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

◆ SDL_isspace()

int SDL_isspace ( int  x)

Definition at line 265 of file SDL_stdlib.c.

Referenced by SDL_abs().

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

◆ SDL_log()

double SDL_log ( double  x)

Definition at line 158 of file SDL_stdlib.c.

References SDL_uclibc_log().

Referenced by SDL_memset4().

159 {
160 #if defined(HAVE_LOG)
161  return log(x);
162 #else
163  return SDL_uclibc_log(x);
164 #endif /* HAVE_LOG */
165 }
double SDL_uclibc_log(double x)
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567

◆ SDL_pow()

double SDL_pow ( double  x,
double  y 
)

Definition at line 168 of file SDL_stdlib.c.

References SDL_uclibc_pow().

Referenced by SDL_memset4().

169 {
170 #if defined(HAVE_POW)
171  return pow(x, y);
172 #else
173  return SDL_uclibc_pow(x, y);
174 #endif /* HAVE_POW */
175 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_pow(double x, double y)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567

◆ SDL_scalbn()

double SDL_scalbn ( double  x,
int  n 
)

Definition at line 178 of file SDL_stdlib.c.

References scalbn, and SDL_uclibc_scalbn().

Referenced by SDL_memset4().

179 {
180 #if defined(HAVE_SCALBN)
181  return scalbn(x, n);
182 #elif defined(HAVE__SCALB)
183  return _scalb(x, n);
184 #else
185  return SDL_uclibc_scalbn(x, n);
186 #endif /* HAVE_SCALBN */
187 }
GLdouble n
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
#define scalbn
Definition: math_private.h:40
double SDL_uclibc_scalbn(double x, int n)

◆ SDL_sin()

double SDL_sin ( double  x)

Definition at line 190 of file SDL_stdlib.c.

References SDL_uclibc_sin(), and sin.

Referenced by SDL_memset4(), and SDL_sinf().

191 {
192 #if defined(HAVE_SIN)
193  return sin(x);
194 #else
195  return SDL_uclibc_sin(x);
196 #endif /* HAVE_SIN */
197 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_sin(double x)
#define sin
Definition: math_private.h:41

◆ SDL_sinf()

float SDL_sinf ( float  x)

Definition at line 200 of file SDL_stdlib.c.

References SDL_sin().

Referenced by SDL_memset4().

201 {
202 #if defined(HAVE_SINF)
203  return sinf(x);
204 #else
205  return (float)SDL_sin((double)x);
206 #endif /* HAVE_SINF */
207 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_sin(double x)
Definition: SDL_stdlib.c:190

◆ SDL_sqrt()

double SDL_sqrt ( double  x)

Definition at line 210 of file SDL_stdlib.c.

References SDL_uclibc_sqrt().

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

211 {
212 #if defined(HAVE_SQRT)
213  return sqrt(x);
214 #else
215  return SDL_uclibc_sqrt(x);
216 #endif
217 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_sqrt(double x)

◆ SDL_sqrtf()

float SDL_sqrtf ( float  x)

Definition at line 220 of file SDL_stdlib.c.

References SDL_sqrt().

Referenced by SDL_memset4().

221 {
222 #if defined(HAVE_SQRTF)
223  return sqrtf(x);
224 #else
225  return (float)SDL_sqrt((double)x);
226 #endif
227 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_sqrt(double x)
Definition: SDL_stdlib.c:210

◆ SDL_tan()

double SDL_tan ( double  x)

Definition at line 230 of file SDL_stdlib.c.

References SDL_uclibc_tan(), and tan().

Referenced by SDL_memset4(), and SDL_tanf().

231 {
232 #if defined(HAVE_TAN)
233  return tan(x);
234 #else
235  return SDL_uclibc_tan(x);
236 #endif
237 }
double tan(double x)
Definition: s_tan.c:45
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_tan(double x)

◆ SDL_tanf()

float SDL_tanf ( float  x)

Definition at line 240 of file SDL_stdlib.c.

References SDL_tan().

Referenced by SDL_memset4().

241 {
242 #if defined(HAVE_TANF)
243  return tanf(x);
244 #else
245  return (float)SDL_tan((double)x);
246 #endif
247 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_tan(double x)
Definition: SDL_stdlib.c:230

◆ SDL_tolower()

int SDL_tolower ( int  x)

Definition at line 267 of file SDL_stdlib.c.

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

Referenced by SDL_abs().

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

◆ SDL_toupper()

int SDL_toupper ( int  x)

Definition at line 266 of file SDL_stdlib.c.

Referenced by SDL_abs().

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