slouken@4761
|
1 |
/*
|
slouken@5535
|
2 |
Simple DirectMedia Layer
|
slouken@6885
|
3 |
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
|
slouken@4761
|
4 |
|
slouken@5535
|
5 |
This software is provided 'as-is', without any express or implied
|
slouken@5535
|
6 |
warranty. In no event will the authors be held liable for any damages
|
slouken@5535
|
7 |
arising from the use of this software.
|
slouken@4761
|
8 |
|
slouken@5535
|
9 |
Permission is granted to anyone to use this software for any purpose,
|
slouken@5535
|
10 |
including commercial applications, and to alter it and redistribute it
|
slouken@5535
|
11 |
freely, subject to the following restrictions:
|
slouken@4761
|
12 |
|
slouken@5535
|
13 |
1. The origin of this software must not be misrepresented; you must not
|
slouken@5535
|
14 |
claim that you wrote the original software. If you use this software
|
slouken@5535
|
15 |
in a product, an acknowledgment in the product documentation would be
|
slouken@5535
|
16 |
appreciated but is not required.
|
slouken@5535
|
17 |
2. Altered source versions must be plainly marked as such, and must not be
|
slouken@5535
|
18 |
misrepresented as being the original software.
|
slouken@5535
|
19 |
3. This notice may not be removed or altered from any source distribution.
|
slouken@4761
|
20 |
*/
|
slouken@4761
|
21 |
|
slouken@4761
|
22 |
/**
|
slouken@4761
|
23 |
* \file SDL_stdinc.h
|
slouken@4761
|
24 |
*
|
slouken@4761
|
25 |
* This is a general header that includes C language support.
|
slouken@4761
|
26 |
*/
|
slouken@4761
|
27 |
|
slouken@4761
|
28 |
#ifndef _SDL_stdinc_h
|
slouken@4761
|
29 |
#define _SDL_stdinc_h
|
slouken@4761
|
30 |
|
slouken@4761
|
31 |
#include "SDL_config.h"
|
slouken@4761
|
32 |
|
slouken@4761
|
33 |
#ifdef HAVE_SYS_TYPES_H
|
slouken@4761
|
34 |
#include <sys/types.h>
|
slouken@4761
|
35 |
#endif
|
slouken@4761
|
36 |
#ifdef HAVE_STDIO_H
|
slouken@4761
|
37 |
#include <stdio.h>
|
slouken@4761
|
38 |
#endif
|
slouken@4761
|
39 |
#if defined(STDC_HEADERS)
|
slouken@4761
|
40 |
# include <stdlib.h>
|
slouken@4761
|
41 |
# include <stddef.h>
|
slouken@4761
|
42 |
# include <stdarg.h>
|
slouken@4761
|
43 |
#else
|
slouken@4761
|
44 |
# if defined(HAVE_STDLIB_H)
|
slouken@4761
|
45 |
# include <stdlib.h>
|
slouken@4761
|
46 |
# elif defined(HAVE_MALLOC_H)
|
slouken@4761
|
47 |
# include <malloc.h>
|
slouken@4761
|
48 |
# endif
|
slouken@4761
|
49 |
# if defined(HAVE_STDDEF_H)
|
slouken@4761
|
50 |
# include <stddef.h>
|
slouken@4761
|
51 |
# endif
|
slouken@4761
|
52 |
# if defined(HAVE_STDARG_H)
|
slouken@4761
|
53 |
# include <stdarg.h>
|
slouken@4761
|
54 |
# endif
|
slouken@4761
|
55 |
#endif
|
slouken@4761
|
56 |
#ifdef HAVE_STRING_H
|
slouken@4761
|
57 |
# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
|
slouken@4761
|
58 |
# include <memory.h>
|
slouken@4761
|
59 |
# endif
|
slouken@4761
|
60 |
# include <string.h>
|
slouken@4761
|
61 |
#endif
|
slouken@4761
|
62 |
#ifdef HAVE_STRINGS_H
|
slouken@4761
|
63 |
# include <strings.h>
|
slouken@4761
|
64 |
#endif
|
slouken@4761
|
65 |
#if defined(HAVE_INTTYPES_H)
|
slouken@4761
|
66 |
# include <inttypes.h>
|
slouken@4761
|
67 |
#elif defined(HAVE_STDINT_H)
|
slouken@4761
|
68 |
# include <stdint.h>
|
slouken@4761
|
69 |
#endif
|
slouken@4761
|
70 |
#ifdef HAVE_CTYPE_H
|
slouken@4761
|
71 |
# include <ctype.h>
|
slouken@4761
|
72 |
#endif
|
slouken@4761
|
73 |
#ifdef HAVE_MATH_H
|
slouken@4761
|
74 |
# include <math.h>
|
slouken@4761
|
75 |
#endif
|
slouken@4761
|
76 |
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
|
slouken@4761
|
77 |
# include <iconv.h>
|
slouken@4761
|
78 |
#endif
|
slouken@4761
|
79 |
|
slouken@4761
|
80 |
/**
|
slouken@4761
|
81 |
* The number of elements in an array.
|
slouken@4761
|
82 |
*/
|
slouken@4761
|
83 |
#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0]))
|
slouken@4761
|
84 |
#define SDL_TABLESIZE(table) SDL_arraysize(table)
|
slouken@4761
|
85 |
|
slouken@4761
|
86 |
/**
|
slouken@4761
|
87 |
* \name Cast operators
|
slouken@4761
|
88 |
*
|
slouken@4761
|
89 |
* Use proper C++ casts when compiled as C++ to be compatible with the option
|
slouken@4761
|
90 |
* -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above).
|
slouken@4761
|
91 |
*/
|
slouken@4761
|
92 |
/*@{*/
|
slouken@4761
|
93 |
#ifdef __cplusplus
|
slouken@4761
|
94 |
#define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
|
slouken@4761
|
95 |
#define SDL_static_cast(type, expression) static_cast<type>(expression)
|
icculus@7076
|
96 |
#define SDL_const_cast(type, expression) const_cast<type>(expression)
|
slouken@4761
|
97 |
#else
|
slouken@4761
|
98 |
#define SDL_reinterpret_cast(type, expression) ((type)(expression))
|
slouken@4761
|
99 |
#define SDL_static_cast(type, expression) ((type)(expression))
|
icculus@7076
|
100 |
#define SDL_const_cast(type, expression) ((type)(expression))
|
slouken@4761
|
101 |
#endif
|
slouken@4761
|
102 |
/*@}*//*Cast operators*/
|
slouken@4761
|
103 |
|
slouken@4761
|
104 |
/* Define a four character code as a Uint32 */
|
slouken@4761
|
105 |
#define SDL_FOURCC(A, B, C, D) \
|
slouken@4761
|
106 |
((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \
|
slouken@4761
|
107 |
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \
|
slouken@4761
|
108 |
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \
|
slouken@4761
|
109 |
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24))
|
slouken@4761
|
110 |
|
slouken@4761
|
111 |
/**
|
slouken@4761
|
112 |
* \name Basic data types
|
slouken@4761
|
113 |
*/
|
slouken@4761
|
114 |
/*@{*/
|
slouken@4761
|
115 |
|
slouken@4761
|
116 |
typedef enum
|
slouken@4761
|
117 |
{
|
slouken@4761
|
118 |
SDL_FALSE = 0,
|
slouken@4761
|
119 |
SDL_TRUE = 1
|
slouken@4761
|
120 |
} SDL_bool;
|
slouken@4761
|
121 |
|
slouken@4761
|
122 |
/**
|
slouken@4761
|
123 |
* \brief A signed 8-bit integer type.
|
slouken@4761
|
124 |
*/
|
slouken@4761
|
125 |
typedef int8_t Sint8;
|
slouken@4761
|
126 |
/**
|
slouken@4761
|
127 |
* \brief An unsigned 8-bit integer type.
|
slouken@4761
|
128 |
*/
|
slouken@4761
|
129 |
typedef uint8_t Uint8;
|
slouken@4761
|
130 |
/**
|
slouken@4761
|
131 |
* \brief A signed 16-bit integer type.
|
slouken@4761
|
132 |
*/
|
slouken@4761
|
133 |
typedef int16_t Sint16;
|
slouken@4761
|
134 |
/**
|
slouken@4761
|
135 |
* \brief An unsigned 16-bit integer type.
|
slouken@4761
|
136 |
*/
|
slouken@4761
|
137 |
typedef uint16_t Uint16;
|
slouken@4761
|
138 |
/**
|
slouken@4761
|
139 |
* \brief A signed 32-bit integer type.
|
slouken@4761
|
140 |
*/
|
slouken@4761
|
141 |
typedef int32_t Sint32;
|
slouken@4761
|
142 |
/**
|
slouken@4761
|
143 |
* \brief An unsigned 32-bit integer type.
|
slouken@4761
|
144 |
*/
|
slouken@4761
|
145 |
typedef uint32_t Uint32;
|
slouken@4761
|
146 |
|
slouken@4761
|
147 |
/**
|
slouken@4761
|
148 |
* \brief A signed 64-bit integer type.
|
slouken@4761
|
149 |
*/
|
slouken@4761
|
150 |
typedef int64_t Sint64;
|
slouken@4761
|
151 |
/**
|
slouken@4761
|
152 |
* \brief An unsigned 64-bit integer type.
|
slouken@4761
|
153 |
*/
|
slouken@4761
|
154 |
typedef uint64_t Uint64;
|
slouken@4761
|
155 |
|
slouken@4761
|
156 |
/*@}*//*Basic data types*/
|
slouken@4761
|
157 |
|
slouken@4761
|
158 |
|
slouken@4761
|
159 |
#define SDL_COMPILE_TIME_ASSERT(name, x) \
|
slouken@4761
|
160 |
typedef int SDL_dummy_ ## name[(x) * 2 - 1]
|
slouken@4761
|
161 |
/** \cond */
|
slouken@4761
|
162 |
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
slouken@4761
|
163 |
SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
|
slouken@4761
|
164 |
SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
|
slouken@4761
|
165 |
SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
|
slouken@4761
|
166 |
SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
|
slouken@4761
|
167 |
SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
|
slouken@4761
|
168 |
SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
|
slouken@4761
|
169 |
SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
|
slouken@4761
|
170 |
SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
|
slouken@4761
|
171 |
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
slouken@4761
|
172 |
/** \endcond */
|
slouken@4761
|
173 |
|
slouken@4761
|
174 |
/* Check to make sure enums are the size of ints, for structure packing.
|
slouken@4761
|
175 |
For both Watcom C/C++ and Borland C/C++ the compiler option that makes
|
slouken@4761
|
176 |
enums having the size of an int must be enabled.
|
slouken@4761
|
177 |
This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).
|
slouken@4761
|
178 |
*/
|
slouken@4761
|
179 |
|
slouken@4761
|
180 |
/** \cond */
|
slouken@4761
|
181 |
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
slouken@7011
|
182 |
#if !defined(__ANDROID__)
|
paul@4697
|
183 |
/* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */
|
slouken@4761
|
184 |
typedef enum
|
slouken@4761
|
185 |
{
|
slouken@4761
|
186 |
DUMMY_ENUM_VALUE
|
slouken@4761
|
187 |
} SDL_DUMMY_ENUM;
|
slouken@4761
|
188 |
|
slouken@4761
|
189 |
SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
|
slouken@4761
|
190 |
#endif
|
slouken@4761
|
191 |
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
slouken@4761
|
192 |
/** \endcond */
|
slouken@4761
|
193 |
|
slouken@4761
|
194 |
#include "begin_code.h"
|
slouken@4761
|
195 |
/* Set up for C function definitions, even when using C++ */
|
slouken@4761
|
196 |
#ifdef __cplusplus
|
slouken@4761
|
197 |
/* *INDENT-OFF* */
|
slouken@4761
|
198 |
extern "C" {
|
slouken@4761
|
199 |
/* *INDENT-ON* */
|
slouken@4761
|
200 |
#endif
|
slouken@4761
|
201 |
|
slouken@4761
|
202 |
#if defined(HAVE_ALLOCA) && !defined(alloca)
|
slouken@4761
|
203 |
# if defined(HAVE_ALLOCA_H)
|
slouken@4761
|
204 |
# include <alloca.h>
|
slouken@4761
|
205 |
# elif defined(__GNUC__)
|
slouken@4761
|
206 |
# define alloca __builtin_alloca
|
slouken@4761
|
207 |
# elif defined(_MSC_VER)
|
slouken@4761
|
208 |
# include <malloc.h>
|
slouken@4761
|
209 |
# define alloca _alloca
|
slouken@4761
|
210 |
# elif defined(__WATCOMC__)
|
slouken@4761
|
211 |
# include <malloc.h>
|
slouken@4761
|
212 |
# elif defined(__BORLANDC__)
|
slouken@4761
|
213 |
# include <malloc.h>
|
slouken@4761
|
214 |
# elif defined(__DMC__)
|
slouken@4761
|
215 |
# include <stdlib.h>
|
slouken@4761
|
216 |
# elif defined(__AIX__)
|
slouken@4761
|
217 |
#pragma alloca
|
slouken@4761
|
218 |
# elif defined(__MRC__)
|
slouken@4761
|
219 |
void *alloca(unsigned);
|
slouken@4761
|
220 |
# else
|
slouken@4761
|
221 |
char *alloca();
|
slouken@4761
|
222 |
# endif
|
slouken@4761
|
223 |
#endif
|
slouken@4761
|
224 |
#ifdef HAVE_ALLOCA
|
slouken@4761
|
225 |
#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count))
|
slouken@4761
|
226 |
#define SDL_stack_free(data)
|
slouken@4761
|
227 |
#else
|
slouken@4761
|
228 |
#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count))
|
slouken@4761
|
229 |
#define SDL_stack_free(data) SDL_free(data)
|
slouken@4761
|
230 |
#endif
|
slouken@4761
|
231 |
|
icculus@7003
|
232 |
|
icculus@7003
|
233 |
/* SDL stdinc inline functions:
|
icculus@7003
|
234 |
|
slouken@7005
|
235 |
The theory here is that by default we forcibly inline what we can, and your
|
slouken@7005
|
236 |
app will use the inline version by default. However we expose a non-inline
|
slouken@7005
|
237 |
version too, so the symbol is always available in the library even if your app
|
slouken@7005
|
238 |
bypassed the inline version. The SDL_*_inline versions aren't guaranteed to
|
slouken@7005
|
239 |
exist, so never call them directly; use SDL_* instead, and trust the system
|
slouken@7005
|
240 |
to give you the right thing.
|
icculus@7003
|
241 |
|
icculus@7003
|
242 |
The benefit here is that you can dlsym() these functions, which you
|
icculus@7003
|
243 |
couldn't if you had macros, you can link against a foreign build of SDL
|
icculus@7003
|
244 |
even if you configured differently, and you can drop the unconfigured SDL
|
icculus@7003
|
245 |
headers into a project without #defining HAVE_MALLOC (etc) and still link.
|
icculus@7003
|
246 |
*/
|
icculus@7003
|
247 |
|
icculus@7003
|
248 |
extern DECLSPEC void *SDLCALL SDL_malloc(size_t size);
|
icculus@7003
|
249 |
#ifdef HAVE_MALLOC
|
icculus@7003
|
250 |
SDL_FORCE_INLINE void *SDL_malloc_inline(size_t size) { return malloc(size); }
|
icculus@7003
|
251 |
#define SDL_malloc SDL_malloc_inline
|
slouken@4761
|
252 |
#endif
|
slouken@4761
|
253 |
|
icculus@7003
|
254 |
extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size);
|
icculus@7003
|
255 |
#ifdef HAVE_CALLOC
|
icculus@7003
|
256 |
SDL_FORCE_INLINE void *SDL_calloc_inline(size_t nmemb, size_t size) { return calloc(nmemb, size); }
|
icculus@7003
|
257 |
#define SDL_calloc SDL_calloc_inline
|
slouken@4761
|
258 |
#endif
|
slouken@4761
|
259 |
|
icculus@7003
|
260 |
extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size);
|
icculus@7003
|
261 |
#ifdef HAVE_REALLOC
|
icculus@7003
|
262 |
SDL_FORCE_INLINE void *SDL_realloc_inline(void *mem, size_t size) { return realloc(mem, size); }
|
icculus@7003
|
263 |
#define SDL_realloc SDL_realloc_inline
|
slouken@4761
|
264 |
#endif
|
slouken@4761
|
265 |
|
icculus@7003
|
266 |
extern DECLSPEC void SDLCALL SDL_free(void *mem);
|
icculus@7003
|
267 |
#ifdef HAVE_FREE
|
icculus@7003
|
268 |
SDL_FORCE_INLINE void SDL_free_inline(void *mem) { free(mem); }
|
icculus@7003
|
269 |
#define SDL_free SDL_free_inline
|
slouken@4761
|
270 |
#endif
|
slouken@4761
|
271 |
|
icculus@7003
|
272 |
extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
|
icculus@7003
|
273 |
#ifdef HAVE_GETENV
|
icculus@7003
|
274 |
SDL_FORCE_INLINE char *SDL_getenv_inline(const char *name) { return getenv(name); }
|
icculus@7003
|
275 |
#define SDL_getenv SDL_getenv_inline
|
slouken@4761
|
276 |
#endif
|
slouken@4761
|
277 |
|
icculus@7003
|
278 |
extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite);
|
icculus@7003
|
279 |
#ifdef HAVE_SETENV
|
icculus@7003
|
280 |
SDL_FORCE_INLINE int SDL_setenv_inline(const char *name, const char *value, int overwrite) { return setenv(name, value, overwrite); }
|
icculus@7003
|
281 |
#define SDL_setenv SDL_setenv_inline
|
slouken@4761
|
282 |
#endif
|
slouken@4761
|
283 |
|
icculus@7003
|
284 |
extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *));
|
icculus@7003
|
285 |
#ifdef HAVE_QSORT
|
icculus@7057
|
286 |
SDL_FORCE_INLINE void SDL_qsort_inline(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *)) { qsort(base, nmemb, size, compare); }
|
icculus@7003
|
287 |
#define SDL_qsort SDL_qsort_inline
|
slouken@4761
|
288 |
#endif
|
slouken@4761
|
289 |
|
icculus@7003
|
290 |
extern DECLSPEC int SDLCALL SDL_abs(int x);
|
icculus@7003
|
291 |
#ifdef HAVE_ABS
|
icculus@7003
|
292 |
SDL_FORCE_INLINE int SDL_abs_inline(int x) { return abs(x); }
|
icculus@7003
|
293 |
#else
|
icculus@7003
|
294 |
SDL_FORCE_INLINE int SDL_abs_inline(int x) { return ((x) < 0 ? -(x) : (x)); }
|
slouken@4761
|
295 |
#endif
|
icculus@7003
|
296 |
#define SDL_abs SDL_abs_inline
|
icculus@7003
|
297 |
|
icculus@7003
|
298 |
/* !!! FIXME: these have side effects. You probably shouldn't use them. */
|
icculus@7003
|
299 |
/* !!! FIXME: Maybe we do forceinline functions of SDL_mini, SDL_minf, etc? */
|
icculus@7003
|
300 |
#define SDL_min(x, y) (((x) < (y)) ? (x) : (y))
|
icculus@7003
|
301 |
#define SDL_max(x, y) (((x) > (y)) ? (x) : (y))
|
icculus@7003
|
302 |
|
icculus@7003
|
303 |
extern DECLSPEC int SDLCALL SDL_isdigit(int x);
|
icculus@7003
|
304 |
extern DECLSPEC int SDLCALL SDL_isspace(int x);
|
icculus@7003
|
305 |
extern DECLSPEC int SDLCALL SDL_toupper(int x);
|
icculus@7003
|
306 |
extern DECLSPEC int SDLCALL SDL_tolower(int x);
|
icculus@7003
|
307 |
#ifdef HAVE_CTYPE_H
|
icculus@7003
|
308 |
SDL_FORCE_INLINE int SDL_isdigit_inline(int x) { return isdigit(x); }
|
icculus@7003
|
309 |
SDL_FORCE_INLINE int SDL_isspace_inline(int x) { return isspace(x); }
|
icculus@7003
|
310 |
SDL_FORCE_INLINE int SDL_toupper_inline(int x) { return toupper(x); }
|
icculus@7003
|
311 |
SDL_FORCE_INLINE int SDL_tolower_inline(int x) { return tolower(x); }
|
icculus@7003
|
312 |
#else
|
icculus@7003
|
313 |
SDL_FORCE_INLINE int SDL_isdigit_inline(int x) { return ((x) >= '0') && ((x) <= '9'); }
|
icculus@7003
|
314 |
SDL_FORCE_INLINE int SDL_isspace_inline(int x) { return ((x) == ' ') || ((x) == '\t') || ((x) == '\r') || ((x) == '\n'); }
|
icculus@7003
|
315 |
SDL_FORCE_INLINE int SDL_toupper_inline(int x) { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); }
|
icculus@7003
|
316 |
SDL_FORCE_INLINE int SDL_tolower_inline(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); }
|
icculus@7003
|
317 |
#endif
|
icculus@7003
|
318 |
#define SDL_isdigit SDL_isdigit_inline
|
icculus@7003
|
319 |
#define SDL_isspace SDL_isspace_inline
|
icculus@7003
|
320 |
#define SDL_toupper SDL_toupper_inline
|
icculus@7003
|
321 |
#define SDL_tolower SDL_tolower_inline
|
icculus@7003
|
322 |
|
icculus@7003
|
323 |
extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len);
|
icculus@7003
|
324 |
#ifdef HAVE_MEMSET
|
icculus@7003
|
325 |
SDL_FORCE_INLINE void *SDL_memset_inline(void *dst, int c, size_t len) { return memset(dst, c, len); }
|
icculus@7003
|
326 |
#define SDL_memset SDL_memset_inline
|
slouken@4761
|
327 |
#endif
|
slouken@4761
|
328 |
|
icculus@7003
|
329 |
#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x)))
|
icculus@7003
|
330 |
#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
|
icculus@7003
|
331 |
|
icculus@7003
|
332 |
/* !!! FIXME: does this _really_ beat memset() on any modern platform? */
|
icculus@7003
|
333 |
SDL_FORCE_INLINE void SDL_memset4(void *dst, int val, size_t len)
|
icculus@7003
|
334 |
{
|
icculus@7003
|
335 |
#if defined(__GNUC__) && defined(i386)
|
icculus@7003
|
336 |
int u0, u1, u2;
|
icculus@7003
|
337 |
__asm__ __volatile__ (
|
icculus@7003
|
338 |
"cld \n\t"
|
icculus@7003
|
339 |
"rep ; stosl \n\t"
|
icculus@7003
|
340 |
: "=&D" (u0), "=&a" (u1), "=&c" (u2)
|
icculus@7003
|
341 |
: "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len))
|
icculus@7003
|
342 |
: "memory"
|
icculus@7003
|
343 |
);
|
icculus@7003
|
344 |
/* !!! FIXME: amd64? */
|
slouken@4761
|
345 |
#else
|
slouken@7015
|
346 |
size_t _n = (len + 3) / 4;
|
icculus@7003
|
347 |
Uint32 *_p = SDL_static_cast(Uint32 *, dst);
|
icculus@7003
|
348 |
Uint32 _val = (val);
|
icculus@7003
|
349 |
if (len == 0)
|
icculus@7003
|
350 |
return;
|
slouken@7015
|
351 |
switch (len % 4)
|
icculus@7003
|
352 |
{
|
icculus@7003
|
353 |
case 0: do { *_p++ = _val;
|
icculus@7003
|
354 |
case 3: *_p++ = _val;
|
icculus@7003
|
355 |
case 2: *_p++ = _val;
|
icculus@7003
|
356 |
case 1: *_p++ = _val;
|
icculus@7003
|
357 |
} while ( --_n );
|
icculus@7003
|
358 |
}
|
icculus@7003
|
359 |
#endif
|
icculus@7003
|
360 |
}
|
icculus@7003
|
361 |
|
icculus@7003
|
362 |
|
icculus@7003
|
363 |
extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len);
|
icculus@7003
|
364 |
#if defined(__MACOSX__)
|
icculus@7003
|
365 |
SDL_FORCE_INLINE void *SDL_memcpy_inline(void *dst, const void *src, size_t len)
|
icculus@7003
|
366 |
{
|
icculus@7003
|
367 |
/* We can count on memcpy existing on Mac OS X and being well-tuned. */
|
icculus@7003
|
368 |
return memcpy(dst, src, len);
|
icculus@7003
|
369 |
}
|
icculus@7003
|
370 |
#define SDL_memcpy SDL_memcpy_inline
|
icculus@7003
|
371 |
#elif defined(__GNUC__) && defined(i386) && !defined(__WIN32__)
|
icculus@7003
|
372 |
SDL_FORCE_INLINE void *SDL_memcpy_inline(void *dst, const void *src, size_t len)
|
icculus@7003
|
373 |
{
|
icculus@7003
|
374 |
/* !!! FIXME: does this _really_ beat memcpy() on any modern platform? */
|
icculus@7003
|
375 |
/* !!! FIXME: shouldn't we just force the inputs to ecx/edi/esi instead of this tapdance with outputs? */
|
icculus@7003
|
376 |
/* !!! FIXME: amd64? */
|
icculus@7003
|
377 |
int u0, u1, u2;
|
icculus@7003
|
378 |
__asm__ __volatile__ (
|
icculus@7003
|
379 |
"cld \n\t"
|
icculus@7003
|
380 |
"rep ; movsl \n\t"
|
icculus@7003
|
381 |
"testb $2,%b4 \n\t"
|
icculus@7003
|
382 |
"je 1f \n\t"
|
icculus@7003
|
383 |
"movsw \n"
|
icculus@7003
|
384 |
"1:\ttestb $1,%b4 \n\t"
|
icculus@7003
|
385 |
"je 2f \n\t"
|
icculus@7003
|
386 |
"movsb \n"
|
icculus@7003
|
387 |
"2:"
|
icculus@7003
|
388 |
: "=&c" (u0), "=&D" (u1), "=&S" (u2)
|
icculus@7003
|
389 |
: "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst), "2" (src)
|
icculus@7003
|
390 |
: "memory"
|
icculus@7003
|
391 |
);
|
icculus@7003
|
392 |
return dst;
|
icculus@7003
|
393 |
}
|
icculus@7003
|
394 |
#define SDL_memcpy SDL_memcpy_inline
|
icculus@7003
|
395 |
#elif defined(HAVE_MEMCPY)
|
icculus@7003
|
396 |
SDL_FORCE_INLINE void *SDL_memcpy_inline(void *dst, const void *src, size_t len)
|
icculus@7003
|
397 |
{
|
icculus@7003
|
398 |
return memcpy(dst, src, len);
|
icculus@7003
|
399 |
}
|
icculus@7003
|
400 |
#define SDL_memcpy SDL_memcpy_inline
|
icculus@7003
|
401 |
#elif defined(HAVE_BCOPY) /* !!! FIXME: is there _really_ ever a time where you have bcopy and not memcpy? */
|
icculus@7003
|
402 |
SDL_FORCE_INLINE void *SDL_memcpy_inline(void *dst, const void *src, size_t len)
|
icculus@7003
|
403 |
{
|
icculus@7003
|
404 |
bcopy(src, dst, len);
|
icculus@7003
|
405 |
return dst;
|
icculus@7003
|
406 |
}
|
icculus@7003
|
407 |
#define SDL_memcpy SDL_memcpy_inline
|
slouken@4761
|
408 |
#endif
|
slouken@4761
|
409 |
|
icculus@7003
|
410 |
|
icculus@7003
|
411 |
SDL_FORCE_INLINE void *SDL_memcpy4(void *dst, const void *src, size_t dwords)
|
icculus@7003
|
412 |
{
|
slouken@7006
|
413 |
#if defined(__GNUC__) && defined(i386)
|
icculus@7003
|
414 |
/* !!! FIXME: does this _really_ beat memcpy() on any modern platform? */
|
icculus@7003
|
415 |
/* !!! FIXME: shouldn't we just force the inputs to ecx/edi/esi instead of this tapdance with outputs? */
|
icculus@7003
|
416 |
int ecx, edi, esi;
|
icculus@7003
|
417 |
__asm__ __volatile__ (
|
icculus@7003
|
418 |
"cld \n\t"
|
icculus@7003
|
419 |
"rep ; movsl \n\t"
|
icculus@7003
|
420 |
: "=&c" (ecx), "=&D" (edi), "=&S" (esi)
|
slouken@7006
|
421 |
: "0" (SDL_static_cast(unsigned, dwords)), "1" (dst), "2" (src)
|
icculus@7003
|
422 |
: "memory"
|
icculus@7003
|
423 |
);
|
icculus@7003
|
424 |
return dst;
|
slouken@4761
|
425 |
#else
|
icculus@7003
|
426 |
return SDL_memcpy(dst, src, dwords * 4);
|
icculus@7003
|
427 |
#endif
|
icculus@7003
|
428 |
}
|
icculus@7003
|
429 |
|
icculus@7003
|
430 |
extern DECLSPEC void *SDLCALL SDL_memmove(void *dst, const void *src, size_t len);
|
icculus@7003
|
431 |
#ifdef HAVE_MEMMOVE
|
icculus@7003
|
432 |
SDL_FORCE_INLINE void *SDL_memmove_inline(void *dst, const void *src, size_t len) { return memmove(dst, src, len); }
|
icculus@7003
|
433 |
#define SDL_memmove SDL_memmove_inline
|
slouken@4761
|
434 |
#endif
|
slouken@4761
|
435 |
|
icculus@7003
|
436 |
extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
|
icculus@7003
|
437 |
#ifdef HAVE_MEMCMP
|
icculus@7003
|
438 |
SDL_FORCE_INLINE int SDL_memcmp_inline(const void *s1, const void *s2, size_t len) { return memcmp(s1, s2, len); }
|
icculus@7003
|
439 |
#define SDL_memcmp SDL_memcmp_inline
|
slouken@4761
|
440 |
#endif
|
slouken@4761
|
441 |
|
icculus@7003
|
442 |
extern DECLSPEC size_t SDLCALL SDL_strlen(const char *str);
|
icculus@7003
|
443 |
#ifdef HAVE_STRLEN
|
icculus@7003
|
444 |
SDL_FORCE_INLINE size_t SDL_strlen_inline(const char *str) { return strlen(str); }
|
icculus@7003
|
445 |
#define SDL_strlen SDL_strlen_inline
|
slouken@4761
|
446 |
#endif
|
slouken@4761
|
447 |
|
icculus@7003
|
448 |
extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr);
|
icculus@7003
|
449 |
#ifdef HAVE_WCSLEN
|
icculus@7003
|
450 |
SDL_FORCE_INLINE size_t SDL_wcslen_inline(const wchar_t *wstr) { return wcslen(wstr); }
|
icculus@7003
|
451 |
#define SDL_wcslen SDL_wcslen_inline
|
slouken@4761
|
452 |
#endif
|
dewyatt@4758
|
453 |
|
icculus@7003
|
454 |
extern DECLSPEC size_t SDLCALL SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen);
|
icculus@7003
|
455 |
#ifdef HAVE_WCSLCPY
|
icculus@7003
|
456 |
SDL_FORCE_INLINE size_t SDL_wcslcpy_inline(wchar_t *dst, const wchar_t *src, size_t maxlen) { return wcslcpy(dst, src, maxlen); }
|
icculus@7003
|
457 |
#define SDL_wcslcpy SDL_wcslcpy_inline
|
slouken@4761
|
458 |
#endif
|
slouken@4761
|
459 |
|
icculus@7003
|
460 |
extern DECLSPEC size_t SDLCALL SDL_wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen);
|
icculus@7003
|
461 |
#ifdef HAVE_WCSLCAT
|
icculus@7003
|
462 |
SDL_FORCE_INLINE size_t SDL_wcslcat_inline(wchar_t *dst, const wchar_t *src, size_t maxlen) { return wcslcat(dst, src, maxlen); }
|
icculus@7003
|
463 |
#define SDL_wcslcat SDL_wcslcat_inline
|
slouken@4761
|
464 |
#endif
|
slouken@4761
|
465 |
|
icculus@7003
|
466 |
extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen);
|
icculus@7003
|
467 |
#ifdef HAVE_STRLCPY
|
icculus@7003
|
468 |
SDL_FORCE_INLINE size_t SDL_strlcpy_inline(char *dst, const char *src, size_t maxlen) { return strlcpy(dst, src, maxlen); }
|
icculus@7003
|
469 |
#define SDL_strlcpy SDL_strlcpy_inline
|
slouken@4761
|
470 |
#else
|
slouken@4761
|
471 |
#endif
|
slouken@4761
|
472 |
|
icculus@7003
|
473 |
extern DECLSPEC size_t SDLCALL SDL_utf8strlcpy(char *dst, const char *src, size_t dst_bytes);
|
icculus@7003
|
474 |
|
icculus@7003
|
475 |
extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen);
|
icculus@7003
|
476 |
#ifdef HAVE_STRLCAT
|
icculus@7003
|
477 |
SDL_FORCE_INLINE size_t SDL_strlcat_inline(char *dst, const char *src, size_t maxlen) { return strlcat(dst, src, maxlen); }
|
icculus@7003
|
478 |
#define SDL_strlcat SDL_strlcat_inline
|
slouken@4761
|
479 |
#endif
|
slouken@4761
|
480 |
|
icculus@7003
|
481 |
extern DECLSPEC char *SDLCALL SDL_strdup(const char *str);
|
icculus@7003
|
482 |
#ifdef HAVE_STRDUP
|
icculus@7003
|
483 |
SDL_FORCE_INLINE char *SDL_strdup_inline(const char *str) { return strdup(str); }
|
icculus@7003
|
484 |
#define SDL_strdup SDL_strdup_inline
|
slouken@4761
|
485 |
#endif
|
slouken@4761
|
486 |
|
icculus@7003
|
487 |
extern DECLSPEC char *SDLCALL SDL_strrev(char *str);
|
icculus@7003
|
488 |
#ifdef HAVE__STRREV
|
icculus@7003
|
489 |
SDL_FORCE_INLINE char *SDL_strrev_inline(char *str) { return _strrev(str); }
|
icculus@7003
|
490 |
#define SDL_strrev SDL_strrev_inline
|
slouken@4761
|
491 |
#endif
|
slouken@4761
|
492 |
|
icculus@7003
|
493 |
extern DECLSPEC char *SDLCALL SDL_strupr(char *str);
|
icculus@7003
|
494 |
#ifdef HAVE__STRUPR
|
icculus@7003
|
495 |
SDL_FORCE_INLINE char *SDL_strupr_inline(char *str) { return _strupr(str); }
|
icculus@7003
|
496 |
#define SDL_strupr SDL_strupr_inline
|
slouken@4761
|
497 |
#endif
|
slouken@4761
|
498 |
|
icculus@7003
|
499 |
extern DECLSPEC char *SDLCALL SDL_strlwr(char *str);
|
icculus@7003
|
500 |
#ifdef HAVE__STRLWR
|
icculus@7003
|
501 |
SDL_FORCE_INLINE char *SDL_strlwr_inline(char *str) { return _strlwr(str); }
|
icculus@7003
|
502 |
#define SDL_strlwr SDL_strlwr_inline
|
slouken@4761
|
503 |
#endif
|
slouken@4761
|
504 |
|
icculus@7003
|
505 |
extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c);
|
icculus@7003
|
506 |
#ifdef HAVE_STRCHR
|
icculus@7076
|
507 |
SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return SDL_const_cast(char*,strchr(str, c)); }
|
icculus@7003
|
508 |
#define SDL_strchr SDL_strchr_inline
|
icculus@7003
|
509 |
#elif defined(HAVE_INDEX) /* !!! FIXME: is there anywhere that has this but not strchr? */
|
icculus@7076
|
510 |
SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return SDL_const_cast(char*,index(str, c)); }
|
icculus@7003
|
511 |
#define SDL_strchr SDL_strchr_inline
|
slouken@4761
|
512 |
#endif
|
slouken@4761
|
513 |
|
icculus@7003
|
514 |
extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
|
icculus@7003
|
515 |
#ifdef HAVE_STRRCHR
|
icculus@7076
|
516 |
SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return SDL_const_cast(char*,strrchr(str, c)); }
|
icculus@7003
|
517 |
#define SDL_strrchr SDL_strrchr_inline
|
icculus@7003
|
518 |
#elif defined(HAVE_RINDEX) /* !!! FIXME: is there anywhere that has this but not strrchr? */
|
icculus@7076
|
519 |
SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return SDL_const_cast(char*,rindex(str, c)); }
|
icculus@7003
|
520 |
#define SDL_strrchr SDL_strrchr_inline
|
slouken@4761
|
521 |
#endif
|
slouken@4761
|
522 |
|
icculus@7003
|
523 |
extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
|
icculus@7003
|
524 |
#ifdef HAVE_STRSTR
|
icculus@7076
|
525 |
SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) { return SDL_const_cast(char*,strstr(haystack, needle)); }
|
icculus@7003
|
526 |
#define SDL_strstr SDL_strstr_inline
|
slouken@4761
|
527 |
#endif
|
slouken@4761
|
528 |
|
icculus@7003
|
529 |
extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *str, int radix);
|
slouken@4761
|
530 |
#ifdef HAVE__LTOA
|
icculus@7003
|
531 |
SDL_FORCE_INLINE char *SDL_ltoa_inline(long value, char *str, int radix) { return _ltoa(value, str, radix); }
|
icculus@7003
|
532 |
#define SDL_ltoa SDL_ltoa_inline
|
slouken@4761
|
533 |
#endif
|
slouken@4761
|
534 |
|
icculus@7003
|
535 |
extern DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix);
|
icculus@7003
|
536 |
#ifdef HAVE_ITOA
|
icculus@7003
|
537 |
SDL_FORCE_INLINE char *SDL_itoa_inline(int value, char *str, int radix) { return itoa(value, str, radix); }
|
slouken@4761
|
538 |
#else
|
icculus@7003
|
539 |
SDL_FORCE_INLINE char *SDL_itoa_inline(int value, char *str, int radix) { return SDL_ltoa((long)value, str, radix); }
|
icculus@7003
|
540 |
#endif
|
icculus@7003
|
541 |
#define SDL_itoa SDL_itoa_inline
|
icculus@7003
|
542 |
|
icculus@7003
|
543 |
extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *str, int radix);
|
icculus@7003
|
544 |
#ifdef HAVE__ULTOA
|
icculus@7003
|
545 |
SDL_FORCE_INLINE char *SDL_ultoa_inline(unsigned long value, char *str, int radix) { return _ultoa(value, str, radix); }
|
icculus@7003
|
546 |
#define SDL_ultoa SDL_ultoa_inline
|
slouken@4761
|
547 |
#endif
|
slouken@4761
|
548 |
|
icculus@7003
|
549 |
extern DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix);
|
icculus@7003
|
550 |
#ifdef HAVE__UITOA
|
icculus@7003
|
551 |
SDL_FORCE_INLINE char *SDL_uitoa_inline(unsigned int value, char *str, int radix) { return _uitoa(value, str, radix); }
|
slouken@4761
|
552 |
#else
|
icculus@7003
|
553 |
SDL_FORCE_INLINE char *SDL_uitoa_inline(unsigned int value, char *str, int radix) { return SDL_ultoa((unsigned long)value, str, radix); }
|
icculus@7003
|
554 |
#endif
|
icculus@7003
|
555 |
#define SDL_uitoa SDL_uitoa_inline
|
icculus@7003
|
556 |
|
icculus@7003
|
557 |
|
icculus@7003
|
558 |
extern DECLSPEC long SDLCALL SDL_strtol(const char *str, char **endp, int base);
|
icculus@7003
|
559 |
#ifdef HAVE_STRTOL
|
icculus@7003
|
560 |
SDL_FORCE_INLINE long SDL_strtol_inline(const char *str, char **endp, int base) { return strtol(str, endp, base); }
|
icculus@7003
|
561 |
#define SDL_strtol SDL_strtol_inline
|
slouken@4761
|
562 |
#endif
|
slouken@4761
|
563 |
|
icculus@7003
|
564 |
extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *str, char **endp, int base);
|
icculus@7003
|
565 |
#ifdef HAVE_STRTOUL
|
icculus@7003
|
566 |
SDL_FORCE_INLINE unsigned long SDLCALL SDL_strtoul_inline(const char *str, char **endp, int base) { return strtoul(str, endp, base); }
|
icculus@7003
|
567 |
#define SDL_strtoul SDL_strtoul_inline
|
slouken@4761
|
568 |
#endif
|
slouken@4761
|
569 |
|
icculus@7003
|
570 |
extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *str, int radix);
|
icculus@7003
|
571 |
#ifdef HAVE__I64TOA
|
icculus@7003
|
572 |
SDL_FORCE_INLINE char *SDL_lltoa_inline(Sint64 value, char *str, int radix) { return _i64toa(value, str, radix); }
|
icculus@7003
|
573 |
#define SDL_lltoa SDL_lltoa_inline
|
slouken@4761
|
574 |
#endif
|
slouken@4761
|
575 |
|
icculus@7003
|
576 |
extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *str, int radix);
|
icculus@7003
|
577 |
#ifdef HAVE__UI64TOA
|
icculus@7003
|
578 |
SDL_FORCE_INLINE char *SDL_ulltoa_inline(Uint64 value, char *str, int radix) { return _ui64toa(value, str, radix); }
|
icculus@7003
|
579 |
#define SDL_ulltoa SDL_ulltoa_inline
|
slouken@4761
|
580 |
#endif
|
slouken@4761
|
581 |
|
icculus@7003
|
582 |
extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *str, char **endp, int base);
|
icculus@7003
|
583 |
#ifdef HAVE_STRTOLL
|
icculus@7003
|
584 |
SDL_FORCE_INLINE Sint64 SDL_strtoll_inline(const char *str, char **endp, int base) { return strtoll(str, endp, base); }
|
icculus@7003
|
585 |
#define SDL_strtoll SDL_strtoll_inline
|
slouken@4761
|
586 |
#endif
|
slouken@4761
|
587 |
|
icculus@7003
|
588 |
extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *str, char **endp, int base);
|
icculus@7003
|
589 |
#ifdef HAVE_STRTOULL
|
icculus@7003
|
590 |
SDL_FORCE_INLINE Uint64 SDL_strtoull_inline(const char *str, char **endp, int base) { return strtoull(str, endp, base); }
|
icculus@7003
|
591 |
#define SDL_strtoull SDL_strtoull_inline
|
slouken@4761
|
592 |
#endif
|
slouken@4761
|
593 |
|
icculus@7003
|
594 |
extern DECLSPEC double SDLCALL SDL_strtod(const char *str, char **endp);
|
icculus@7003
|
595 |
#ifdef HAVE_STRTOD
|
icculus@7036
|
596 |
SDL_FORCE_INLINE double SDL_strtod_inline(const char *str, char **endp) { return strtod(str, endp); }
|
icculus@7003
|
597 |
#define SDL_strtod SDL_strtod_inline
|
slouken@4761
|
598 |
#endif
|
slouken@4761
|
599 |
|
icculus@7003
|
600 |
extern DECLSPEC int SDLCALL SDL_atoi(const char *str);
|
icculus@7003
|
601 |
#ifdef HAVE_ATOI
|
icculus@7003
|
602 |
SDL_FORCE_INLINE int SDL_atoi_inline(const char *str) { return atoi(str); }
|
slouken@4761
|
603 |
#else
|
icculus@7003
|
604 |
SDL_FORCE_INLINE int SDL_atoi_inline(const char *str) { return SDL_strtol(str, NULL, 0); }
|
icculus@7003
|
605 |
#endif
|
icculus@7003
|
606 |
#define SDL_atoi SDL_atoi_inline
|
icculus@7003
|
607 |
|
icculus@7003
|
608 |
extern DECLSPEC double SDLCALL SDL_atof(const char *str);
|
icculus@7003
|
609 |
#ifdef HAVE_ATOF
|
icculus@7003
|
610 |
SDL_FORCE_INLINE double SDL_atof_inline(const char *str) { return (double) atof(str); }
|
icculus@7003
|
611 |
#else
|
icculus@7003
|
612 |
SDL_FORCE_INLINE double SDL_atof_inline(const char *str) { return SDL_strtod(str, NULL); }
|
icculus@7003
|
613 |
#endif
|
icculus@7003
|
614 |
#define SDL_atof SDL_atof_inline
|
icculus@7003
|
615 |
|
icculus@7003
|
616 |
|
icculus@7003
|
617 |
extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
|
icculus@7003
|
618 |
#ifdef HAVE_STRCMP
|
icculus@7003
|
619 |
SDL_FORCE_INLINE int SDL_strcmp_inline(const char *str1, const char *str2) { return strcmp(str1, str2); }
|
icculus@7003
|
620 |
#define SDL_strcmp SDL_strcmp_inline
|
slouken@4761
|
621 |
#endif
|
slouken@4761
|
622 |
|
icculus@7003
|
623 |
extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen);
|
icculus@7003
|
624 |
#ifdef HAVE_STRNCMP
|
icculus@7003
|
625 |
SDL_FORCE_INLINE int SDL_strncmp_inline(const char *str1, const char *str2, size_t maxlen) { return strncmp(str1, str2, maxlen); }
|
icculus@7003
|
626 |
#define SDL_strncmp SDL_strncmp_inline
|
slouken@4761
|
627 |
#endif
|
slouken@4761
|
628 |
|
icculus@7003
|
629 |
extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
|
icculus@7003
|
630 |
#ifdef HAVE_STRCASECMP
|
icculus@7003
|
631 |
SDL_FORCE_INLINE int SDL_strcasecmp_inline(const char *str1, const char *str2) { return strcasecmp(str1, str2); }
|
icculus@7003
|
632 |
#define SDL_strcasecmp SDL_strcasecmp_inline
|
icculus@7003
|
633 |
#elif defined(HAVE__STRICMP)
|
icculus@7003
|
634 |
SDL_FORCE_INLINE int SDL_strcasecmp_inline(const char *str1, const char *str2) { return _stricmp(str1, str2); }
|
icculus@7003
|
635 |
#define SDL_strcasecmp SDL_strcasecmp_inline
|
slouken@4761
|
636 |
#endif
|
slouken@4761
|
637 |
|
icculus@7003
|
638 |
extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t len);
|
icculus@7003
|
639 |
#ifdef HAVE_STRNCASECMP
|
icculus@7003
|
640 |
SDL_FORCE_INLINE int SDL_strncasecmp_inline(const char *str1, const char *str2, size_t len) { return strncasecmp(str1, str2, len); }
|
icculus@7003
|
641 |
#define SDL_strncasecmp SDL_strncasecmp_inline
|
icculus@7003
|
642 |
#elif defined(HAVE__STRNICMP)
|
icculus@7003
|
643 |
SDL_FORCE_INLINE int SDL_strncasecmp_inline(const char *str1, const char *str2, size_t len) { return _strnicmp(str1, str2, len); }
|
icculus@7003
|
644 |
#define SDL_strncasecmp SDL_strncasecmp_inline
|
slouken@4761
|
645 |
#endif
|
slouken@4761
|
646 |
|
icculus@7003
|
647 |
/* Not doing SDL_*_inline functions for these, because of the varargs. */
|
icculus@7003
|
648 |
extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...);
|
icculus@7003
|
649 |
#ifdef HAVE_SSCANF
|
icculus@7003
|
650 |
#define SDL_sscanf sscanf
|
slouken@4761
|
651 |
#endif
|
slouken@4761
|
652 |
|
icculus@7003
|
653 |
extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...);
|
icculus@7003
|
654 |
#ifdef HAVE_SNPRINTF
|
icculus@7003
|
655 |
#define SDL_snprintf snprintf
|
slouken@4761
|
656 |
#endif
|
slouken@4761
|
657 |
|
icculus@7003
|
658 |
extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
|
slouken@4761
|
659 |
#ifdef HAVE_VSNPRINTF
|
icculus@7003
|
660 |
SDL_FORCE_INLINE int SDL_vsnprintf_inline(char *text, size_t maxlen, const char *fmt, va_list ap) { return vsnprintf(text, maxlen, fmt, ap); }
|
icculus@7003
|
661 |
#define SDL_vsnprintf SDL_vsnprintf_inline
|
slouken@4761
|
662 |
#endif
|
slouken@4761
|
663 |
|
slouken@4761
|
664 |
#ifndef HAVE_M_PI
|
slouken@6627
|
665 |
#ifndef M_PI
|
slouken@4761
|
666 |
#define M_PI 3.14159265358979323846264338327950288 /* pi */
|
slouken@4761
|
667 |
#endif
|
slouken@6627
|
668 |
#endif
|
slouken@4761
|
669 |
|
icculus@7003
|
670 |
extern DECLSPEC double SDLCALL SDL_atan(double x);
|
slouken@4873
|
671 |
#ifdef HAVE_ATAN
|
icculus@7003
|
672 |
SDL_FORCE_INLINE double SDL_atan_inline(double x) { return atan(x); }
|
icculus@7003
|
673 |
#define SDL_atan SDL_atan_inline
|
slouken@4873
|
674 |
#endif
|
slouken@4873
|
675 |
|
icculus@7003
|
676 |
extern DECLSPEC double SDLCALL SDL_atan2(double x, double y);
|
slouken@4870
|
677 |
#ifdef HAVE_ATAN2
|
icculus@7003
|
678 |
SDL_FORCE_INLINE double SDL_atan2_inline(double x, double y) { return atan2(x, y); }
|
icculus@7003
|
679 |
#define SDL_atan2 SDL_atan2_inline
|
slouken@4870
|
680 |
#endif
|
slouken@4870
|
681 |
|
icculus@7003
|
682 |
extern DECLSPEC double SDLCALL SDL_ceil(double x);
|
slouken@4761
|
683 |
#ifdef HAVE_CEIL
|
icculus@7003
|
684 |
SDL_FORCE_INLINE double SDL_ceil_inline(double x) { return ceil(x); }
|
slouken@4761
|
685 |
#else
|
icculus@7003
|
686 |
SDL_FORCE_INLINE double SDL_ceil_inline(double x) { return (double)(int)((x)+0.5); }
|
icculus@7003
|
687 |
#endif
|
icculus@7003
|
688 |
#define SDL_ceil SDL_ceil_inline
|
icculus@7003
|
689 |
|
icculus@7003
|
690 |
extern DECLSPEC double SDLCALL SDL_copysign(double x, double y);
|
icculus@7003
|
691 |
#ifdef HAVE_COPYSIGN
|
icculus@7003
|
692 |
SDL_FORCE_INLINE double SDL_copysign_inline(double x, double y) { return copysign(x, y); }
|
icculus@7003
|
693 |
#define SDL_copysign SDL_copysign_inline
|
slouken@4761
|
694 |
#endif
|
slouken@4761
|
695 |
|
icculus@7003
|
696 |
extern DECLSPEC double SDLCALL SDL_cos(double x);
|
icculus@7003
|
697 |
#ifdef HAVE_COS
|
icculus@7003
|
698 |
SDL_FORCE_INLINE double SDL_cos_inline(double x) { return cos(x); }
|
icculus@7003
|
699 |
#define SDL_cos SDL_cos_inline
|
slouken@4761
|
700 |
#endif
|
slouken@4761
|
701 |
|
icculus@7003
|
702 |
extern DECLSPEC float SDLCALL SDL_cosf(float x);
|
icculus@7003
|
703 |
#ifdef HAVE_COSF
|
icculus@7003
|
704 |
SDL_FORCE_INLINE float SDL_cosf_inline(float x) { return cosf(x); }
|
slouken@4761
|
705 |
#else
|
icculus@7003
|
706 |
SDL_FORCE_INLINE float SDL_cosf_inline(float x) { return (float)SDL_cos((double)x); }
|
icculus@7003
|
707 |
#endif
|
icculus@7003
|
708 |
#define SDL_cosf SDL_cosf_inline
|
icculus@7003
|
709 |
|
icculus@7003
|
710 |
extern DECLSPEC double SDLCALL SDL_fabs(double x);
|
icculus@7003
|
711 |
#ifdef HAVE_FABS
|
icculus@7003
|
712 |
SDL_FORCE_INLINE double SDL_fabs_inline(double x) { return fabs(x); }
|
icculus@7003
|
713 |
#define SDL_fabs SDL_fabs_inline
|
slouken@4761
|
714 |
#endif
|
slouken@4761
|
715 |
|
icculus@7003
|
716 |
extern DECLSPEC double SDLCALL SDL_floor(double x);
|
icculus@7003
|
717 |
#ifdef HAVE_FLOOR
|
icculus@7003
|
718 |
SDL_FORCE_INLINE double SDL_floor_inline(double x) { return floor(x); }
|
icculus@7003
|
719 |
#define SDL_floor SDL_floor_inline
|
slouken@4761
|
720 |
#endif
|
slouken@4761
|
721 |
|
icculus@7003
|
722 |
extern DECLSPEC double SDLCALL SDL_log(double x);
|
icculus@7003
|
723 |
#ifdef HAVE_LOG
|
icculus@7003
|
724 |
SDL_FORCE_INLINE double SDL_log_inline(double x) { return log(x); }
|
icculus@7003
|
725 |
#define SDL_log SDL_log_inline
|
slouken@4761
|
726 |
#endif
|
slouken@4761
|
727 |
|
icculus@7003
|
728 |
extern DECLSPEC double SDLCALL SDL_pow(double x, double y);
|
icculus@7003
|
729 |
#ifdef HAVE_POW
|
icculus@7003
|
730 |
SDL_FORCE_INLINE double SDL_pow_inline(double x, double y) { return pow(x, y); }
|
icculus@7003
|
731 |
#define SDL_pow SDL_pow_inline
|
slouken@4761
|
732 |
#endif
|
slouken@4761
|
733 |
|
icculus@7003
|
734 |
extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n);
|
icculus@7003
|
735 |
#ifdef HAVE_SCALBN
|
icculus@7003
|
736 |
SDL_FORCE_INLINE double SDL_scalbn_inline(double x, int n) { return scalbn(x, n); }
|
icculus@7003
|
737 |
#define SDL_scalbn SDL_scalbn_inline
|
slouken@4761
|
738 |
#endif
|
slouken@4761
|
739 |
|
icculus@7003
|
740 |
extern DECLSPEC double SDLCALL SDL_sin(double x);
|
icculus@7003
|
741 |
#ifdef HAVE_SIN
|
icculus@7003
|
742 |
SDL_FORCE_INLINE double SDL_sin_inline(double x) { return sin(x); }
|
icculus@7003
|
743 |
#define SDL_sin SDL_sin_inline
|
slouken@4761
|
744 |
#endif
|
slouken@4761
|
745 |
|
icculus@7003
|
746 |
extern DECLSPEC float SDLCALL SDL_sinf(float x);
|
icculus@7003
|
747 |
#ifdef HAVE_SINF
|
icculus@7003
|
748 |
SDL_FORCE_INLINE float SDL_sinf_inline(float x) { return sinf(x); }
|
slouken@4761
|
749 |
#else
|
icculus@7003
|
750 |
SDL_FORCE_INLINE float SDL_sinf_inline(float x) { return (float)SDL_sin((double)x); }
|
slouken@4761
|
751 |
#endif
|
icculus@7003
|
752 |
#define SDL_sinf SDL_sinf_inline
|
slouken@4761
|
753 |
|
icculus@7003
|
754 |
extern DECLSPEC double SDLCALL SDL_sqrt(double x);
|
slouken@4761
|
755 |
#ifdef HAVE_SQRT
|
icculus@7003
|
756 |
SDL_FORCE_INLINE double SDL_sqrt_inline(double x) { return sqrt(x); }
|
icculus@7003
|
757 |
#define SDL_sqrt SDL_sqrt_inline
|
slouken@4761
|
758 |
#endif
|
slouken@4761
|
759 |
|
slouken@4761
|
760 |
/* The SDL implementation of iconv() returns these error codes */
|
slouken@4761
|
761 |
#define SDL_ICONV_ERROR (size_t)-1
|
slouken@4761
|
762 |
#define SDL_ICONV_E2BIG (size_t)-2
|
slouken@4761
|
763 |
#define SDL_ICONV_EILSEQ (size_t)-3
|
slouken@4761
|
764 |
#define SDL_ICONV_EINVAL (size_t)-4
|
slouken@4761
|
765 |
|
icculus@7003
|
766 |
/* SDL_iconv_* are now always real symbols/types, not macros or inlined. */
|
slouken@4761
|
767 |
typedef struct _SDL_iconv_t *SDL_iconv_t;
|
slouken@4761
|
768 |
extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode,
|
slouken@4761
|
769 |
const char *fromcode);
|
slouken@4761
|
770 |
extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
|
slouken@4761
|
771 |
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
|
slouken@4761
|
772 |
size_t * inbytesleft, char **outbuf,
|
slouken@4761
|
773 |
size_t * outbytesleft);
|
slouken@4761
|
774 |
/**
|
slouken@4761
|
775 |
* This function converts a string between encodings in one pass, returning a
|
slouken@4761
|
776 |
* string that must be freed with SDL_free() or NULL on error.
|
slouken@4761
|
777 |
*/
|
slouken@4761
|
778 |
extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
|
slouken@4761
|
779 |
const char *fromcode,
|
slouken@4761
|
780 |
const char *inbuf,
|
slouken@4761
|
781 |
size_t inbytesleft);
|
slouken@4761
|
782 |
#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
|
slouken@6610
|
783 |
#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
|
slouken@6610
|
784 |
#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
|
slouken@4761
|
785 |
|
slouken@4761
|
786 |
/* Ends C function definitions when using C++ */
|
slouken@4761
|
787 |
#ifdef __cplusplus
|
slouken@4761
|
788 |
/* *INDENT-OFF* */
|
slouken@4761
|
789 |
}
|
slouken@4761
|
790 |
/* *INDENT-ON* */
|
slouken@4761
|
791 |
#endif
|
slouken@4761
|
792 |
#include "close_code.h"
|
slouken@4761
|
793 |
|
slouken@4761
|
794 |
#endif /* _SDL_stdinc_h */
|
slouken@4761
|
795 |
|
slouken@4761
|
796 |
/* vi: set ts=4 sw=4 expandtab: */
|