Mercurial > sdl-ios-xcode
annotate include/SDL_stdinc.h @ 1422:d2ee8da60262
Added pre-configured versions of SDL_config.h for various platforms
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 24 Feb 2006 07:26:31 +0000 |
parents | d910939febfa |
children | 84de7511f79f |
rev | line source |
---|---|
1357 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
3 Copyright (C) 1997-2006 Sam Lantinga | |
4 | |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Lesser General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2.1 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Lesser General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Lesser General Public | |
16 License along with this library; if not, write to the Free Software | |
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
18 | |
19 Sam Lantinga | |
20 slouken@libsdl.org | |
21 */ | |
22 | |
23 /* This is a general header that includes C language support */ | |
24 | |
25 #ifndef _SDL_stdinc_h | |
26 #define _SDL_stdinc_h | |
27 | |
28 #include "SDL_config.h" | |
29 | |
30 | |
31 #if HAVE_SYS_TYPES_H | |
32 #include <sys/types.h> | |
33 #endif | |
34 #if HAVE_STDIO_H | |
35 #include <stdio.h> | |
36 #endif | |
37 #if STDC_HEADERS | |
38 # include <stdlib.h> | |
39 # include <stddef.h> | |
40 # include <stdarg.h> | |
41 #else | |
42 # if HAVE_STDLIB_H | |
43 # include <stdlib.h> | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1357
diff
changeset
|
44 # elif HAVE_MALLOC_H |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1357
diff
changeset
|
45 # include <malloc.h> |
1357 | 46 # endif |
1422
d2ee8da60262
Added pre-configured versions of SDL_config.h for various platforms
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
47 # if HAVE_STDDEF_H |
d2ee8da60262
Added pre-configured versions of SDL_config.h for various platforms
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
48 # include <stddef.h> |
d2ee8da60262
Added pre-configured versions of SDL_config.h for various platforms
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
49 # endif |
1357 | 50 # if HAVE_STDARG_H |
51 # include <stdarg.h> | |
52 # endif | |
53 #endif | |
54 #if HAVE_STRING_H | |
55 # if !STDC_HEADERS && HAVE_MEMORY_H | |
56 # include <memory.h> | |
57 # endif | |
58 # include <string.h> | |
59 #endif | |
60 #if HAVE_STRINGS_H | |
61 # include <strings.h> | |
62 #endif | |
63 #if HAVE_INTTYPES_H | |
64 # include <inttypes.h> | |
65 #else | |
66 # if HAVE_STDINT_H | |
67 # include <stdint.h> | |
68 # endif | |
69 #endif | |
70 #if HAVE_CTYPE_H | |
71 # include <ctype.h> | |
72 #endif | |
73 | |
74 /* The number of elements in an array */ | |
75 #define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) | |
76 #define SDL_TABLESIZE(table) SDL_arraysize(table) | |
77 | |
78 /* Basic data types */ | |
79 typedef enum SDL_bool { | |
80 SDL_FALSE = 0, | |
81 SDL_TRUE = 1 | |
82 } SDL_bool; | |
83 | |
84 typedef int8_t Sint8; | |
85 typedef uint8_t Uint8; | |
86 typedef int16_t Sint16; | |
87 typedef uint16_t Uint16; | |
88 typedef int32_t Sint32; | |
89 typedef uint32_t Uint32; | |
90 | |
91 #ifdef SDL_HAS_64BIT_TYPE | |
92 typedef int64_t Sint64; | |
93 typedef uint64_t Uint64; | |
94 #else | |
95 /* This is really just a hack to prevent the compiler from complaining */ | |
96 typedef struct { | |
97 Uint32 hi; | |
98 Uint32 lo; | |
99 } Uint64, Sint64; | |
100 #endif | |
101 | |
102 /* Make sure the types really have the right sizes */ | |
103 #define SDL_COMPILE_TIME_ASSERT(name, x) \ | |
104 typedef int SDL_dummy_ ## name[(x) * 2 - 1] | |
105 | |
106 SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); | |
107 SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); | |
108 SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); | |
109 SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); | |
110 SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); | |
111 SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); | |
112 SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); | |
113 SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); | |
114 | |
115 /* Check to make sure enums are the size of ints, for structure packing. | |
116 For both Watcom C/C++ and Borland C/C++ the compiler option that makes | |
117 enums having the size of an int must be enabled. | |
118 This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). | |
119 */ | |
120 /* Enable enums always int in CodeWarrior (for MPW use "-enum int") */ | |
121 #ifdef __MWERKS__ | |
122 #pragma enumsalwaysint on | |
123 #endif | |
124 | |
125 typedef enum { | |
126 DUMMY_ENUM_VALUE | |
127 } SDL_DUMMY_ENUM; | |
128 | |
129 SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); | |
130 | |
131 | |
132 #include "begin_code.h" | |
133 /* Set up for C function definitions, even when using C++ */ | |
134 #ifdef __cplusplus | |
135 extern "C" { | |
136 #endif | |
137 | |
138 #if HAVE_MALLOC | |
139 #define SDL_malloc malloc | |
140 #else | |
141 extern DECLSPEC void * SDLCALL SDL_malloc(size_t size); | |
142 #endif | |
143 | |
144 #if HAVE_CALLOC | |
145 #define SDL_calloc calloc | |
146 #else | |
147 extern DECLSPEC void * SDLCALL SDL_calloc(size_t nmemb, size_t size); | |
148 #endif | |
149 | |
150 #if HAVE_REALLOC | |
151 #define SDL_realloc realloc | |
152 #else | |
153 extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size); | |
154 #endif | |
155 | |
156 #if HAVE_FREE | |
157 #define SDL_free free | |
158 #else | |
159 extern DECLSPEC void SDLCALL SDL_free(void *mem); | |
160 #endif | |
161 | |
1381
8570e1f4b1f1
On FreeBSD, alloca is defined in stdlib.h
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
162 #if HAVE_ALLOCA && !defined(alloca) |
8570e1f4b1f1
On FreeBSD, alloca is defined in stdlib.h
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
163 # if HAVE_ALLOCA_H |
8570e1f4b1f1
On FreeBSD, alloca is defined in stdlib.h
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
164 # include <alloca.h> |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1381
diff
changeset
|
165 # elif defined(__GNUC__) |
1381
8570e1f4b1f1
On FreeBSD, alloca is defined in stdlib.h
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
166 # define alloca __builtin_alloca |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1381
diff
changeset
|
167 # elif defined(_MSC_VER) |
1381
8570e1f4b1f1
On FreeBSD, alloca is defined in stdlib.h
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
168 # include <malloc.h> |
8570e1f4b1f1
On FreeBSD, alloca is defined in stdlib.h
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
169 # define alloca _alloca |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1381
diff
changeset
|
170 # elif defined(__AIX__) |
1381
8570e1f4b1f1
On FreeBSD, alloca is defined in stdlib.h
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
171 #pragma alloca |
8570e1f4b1f1
On FreeBSD, alloca is defined in stdlib.h
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
172 # else |
8570e1f4b1f1
On FreeBSD, alloca is defined in stdlib.h
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
173 char *alloca (); |
8570e1f4b1f1
On FreeBSD, alloca is defined in stdlib.h
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
174 # endif |
8570e1f4b1f1
On FreeBSD, alloca is defined in stdlib.h
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
175 #endif |
1357 | 176 #if HAVE_ALLOCA |
177 #define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*count) | |
178 #define SDL_stack_free(data) | |
179 #else | |
180 #define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*count) | |
181 #define SDL_stack_free(data) SDL_free(data) | |
182 #endif | |
183 | |
184 #if HAVE_GETENV | |
185 #define SDL_getenv getenv | |
186 #else | |
187 extern DECLSPEC char * SDLCALL SDL_getenv(const char *name); | |
188 #endif | |
189 | |
190 #if HAVE_PUTENV | |
191 #define SDL_putenv putenv | |
192 #else | |
193 extern DECLSPEC int SDLCALL SDL_putenv(const char *variable); | |
194 #endif | |
195 | |
196 #if HAVE_QSORT | |
197 #define SDL_qsort qsort | |
198 #else | |
199 extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, | |
200 int (*compare)(const void *, const void *)); | |
201 #endif | |
202 | |
203 #if HAVE_ABS | |
204 #define SDL_abs abs | |
205 #else | |
206 #define SDL_abs(X) ((X) < 0 ? -(X) : (X)) | |
207 #endif | |
208 | |
1379
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1368
diff
changeset
|
209 #define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) |
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1368
diff
changeset
|
210 #define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) |
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1368
diff
changeset
|
211 |
1357 | 212 #if HAVE_CTYPE_H |
213 #define SDL_isdigit(X) isdigit(X) | |
214 #define SDL_isspace(X) isspace(X) | |
215 #define SDL_toupper(X) toupper(X) | |
216 #define SDL_tolower(X) tolower(X) | |
217 #else | |
218 #define SDL_isdigit(X) (((X) >= '0') && ((X) <= '9')) | |
219 #define SDL_isspace(X) (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n')) | |
220 #define SDL_toupper(X) (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X)) | |
221 #define SDL_tolower(X) (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X)) | |
222 #endif | |
223 | |
224 #if HAVE_MEMSET | |
225 #define SDL_memset memset | |
226 #else | |
227 extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len); | |
228 #endif | |
229 | |
230 #if defined(__GNUC__) && defined(i386) | |
231 #define SDL_memset4(dst, val, len) \ | |
232 do { \ | |
233 int u0, u1, u2; \ | |
234 __asm__ __volatile__ ( \ | |
235 "cld\n\t" \ | |
236 "rep ; stosl\n\t" \ | |
237 : "=&D" (u0), "=&a" (u1), "=&c" (u2) \ | |
238 : "0" (dst), "1" (val), "2" ((Uint32)(len)) \ | |
239 : "memory" ); \ | |
240 } while(0) | |
241 #endif | |
242 #ifndef SDL_memset4 | |
243 #define SDL_memset4(dst, val, len) \ | |
244 do { \ | |
245 unsigned _count = (len); \ | |
246 unsigned _n = (_count + 3) / 4; \ | |
247 Uint32 *_p = (Uint32 *)(dst); \ | |
248 Uint32 _val = (val); \ | |
249 switch (_count % 4) { \ | |
250 case 0: do { *_p++ = _val; \ | |
251 case 3: *_p++ = _val; \ | |
252 case 2: *_p++ = _val; \ | |
253 case 1: *_p++ = _val; \ | |
254 } while ( --_n ); \ | |
255 } \ | |
256 } while(0) | |
257 #endif | |
258 | |
259 #if defined(__GNUC__) && defined(i386) | |
260 #define SDL_memcpy(dst, src, len) \ | |
261 do { \ | |
262 int u0, u1, u2; \ | |
263 __asm__ __volatile__ ( \ | |
264 "cld\n\t" \ | |
265 "rep ; movsl\n\t" \ | |
266 "testb $2,%b4\n\t" \ | |
267 "je 1f\n\t" \ | |
268 "movsw\n" \ | |
269 "1:\ttestb $1,%b4\n\t" \ | |
270 "je 2f\n\t" \ | |
271 "movsb\n" \ | |
272 "2:" \ | |
273 : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ | |
274 : "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \ | |
275 : "memory" ); \ | |
276 } while(0) | |
277 #endif | |
278 #ifndef SDL_memcpy | |
279 #if HAVE_MEMCPY | |
280 #define SDL_memcpy memcpy | |
281 #elif HAVE_BCOPY | |
282 #define SDL_memcpy(d, s, n) bcopy((s), (d), (n)) | |
283 #else | |
284 extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len); | |
285 #endif | |
286 #endif | |
287 | |
288 #if defined(__GNUC__) && defined(i386) | |
289 #define SDL_memcpy4(dst, src, len) \ | |
290 do { \ | |
291 int ecx, edi, esi; \ | |
292 __asm__ __volatile__ ( \ | |
293 "cld\n\t" \ | |
294 "rep ; movsl" \ | |
295 : "=&c" (ecx), "=&D" (edi), "=&S" (esi) \ | |
296 : "0" ((unsigned)(len)), "1" (dst), "2" (src) \ | |
297 : "memory" ); \ | |
298 } while(0) | |
299 #endif | |
300 #ifndef SDL_memcpy4 | |
301 #define SDL_memcpy4(dst, src, len) SDL_memcpy(dst, src, (len) << 2) | |
302 #endif | |
303 | |
304 #if defined(__GNUC__) && defined(i386) | |
305 #define SDL_revcpy(dst, src, len) \ | |
306 do { \ | |
307 int u0, u1, u2; \ | |
308 char *dstp = (char *)(dst); \ | |
309 char *srcp = (char *)(src); \ | |
310 int n = (len); \ | |
311 if ( n >= 4 ) { \ | |
312 __asm__ __volatile__ ( \ | |
313 "std\n\t" \ | |
314 "rep ; movsl\n\t" \ | |
315 : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ | |
316 : "0" (n >> 2), \ | |
317 "1" (dstp+(n-4)), "2" (srcp+(n-4)) \ | |
318 : "memory" ); \ | |
319 } \ | |
320 switch (n & 3) { \ | |
321 case 3: dstp[2] = srcp[2]; \ | |
322 case 2: dstp[1] = srcp[1]; \ | |
323 case 1: dstp[0] = srcp[0]; \ | |
324 break; \ | |
325 default: \ | |
326 break; \ | |
327 } \ | |
328 } while(0) | |
329 #endif | |
330 #ifndef SDL_revcpy | |
331 extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len); | |
332 #endif | |
333 | |
334 #if HAVE_MEMMOVE | |
335 #define SDL_memmove memmove | |
336 #elif HAVE_BCOPY | |
337 #define SDL_memmove(d, s, n) bcopy((s), (d), (n)) | |
338 #else | |
339 #define SDL_memmove(dst, src, len) \ | |
340 do { \ | |
341 if ( dst < src ) { \ | |
342 SDL_memcpy(dst, src, len); \ | |
343 } else { \ | |
344 SDL_revcpy(dst, src, len); \ | |
345 } \ | |
346 } while(0) | |
347 #endif | |
348 | |
349 #if HAVE_MEMCMP | |
350 #define SDL_memcmp memcmp | |
351 #else | |
352 extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); | |
353 #endif | |
354 | |
355 #if HAVE_STRLEN | |
356 #define SDL_strlen strlen | |
357 #else | |
358 extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string); | |
359 #endif | |
360 | |
1379
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1368
diff
changeset
|
361 #if HAVE_STRLCPY |
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1368
diff
changeset
|
362 #define SDL_strlcpy strlcpy |
1357 | 363 #else |
1379
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1368
diff
changeset
|
364 extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen); |
1357 | 365 #endif |
366 | |
1379
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1368
diff
changeset
|
367 #if HAVE_STRLCAT |
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1368
diff
changeset
|
368 #define SDL_strlcat strlcat |
1357 | 369 #else |
1379
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1368
diff
changeset
|
370 extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen); |
1357 | 371 #endif |
372 | |
373 #if HAVE_STRDUP | |
374 #define SDL_strdup strdup | |
375 #else | |
376 extern DECLSPEC char * SDLCALL SDL_strdup(const char *string); | |
377 #endif | |
378 | |
379 #if HAVE__STRREV | |
380 #define SDL_strrev _strrev | |
381 #else | |
382 extern DECLSPEC char * SDLCALL SDL_strrev(char *string); | |
383 #endif | |
384 | |
385 #if HAVE__STRUPR | |
386 #define SDL_strupr _strupr | |
387 #else | |
388 extern DECLSPEC char * SDLCALL SDL_strupr(char *string); | |
389 #endif | |
390 | |
391 #if HAVE__STRLWR | |
392 #define SDL_strlwr _strlwr | |
393 #else | |
394 extern DECLSPEC char * SDLCALL SDL_strlwr(char *string); | |
395 #endif | |
396 | |
397 #if HAVE_STRCHR | |
398 #define SDL_strchr strchr | |
399 #elif HAVE_INDEX | |
400 #define SDL_strchr index | |
401 #else | |
402 extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c); | |
403 #endif | |
404 | |
405 #if HAVE_STRRCHR | |
406 #define SDL_strrchr strrchr | |
407 #elif HAVE_RINDEX | |
408 #define SDL_strrchr rindex | |
409 #else | |
410 extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c); | |
411 #endif | |
412 | |
413 #if HAVE_STRSTR | |
414 #define SDL_strstr strstr | |
415 #else | |
416 extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle); | |
417 #endif | |
418 | |
419 #if HAVE_ITOA | |
420 #define SDL_itoa itoa | |
421 #else | |
422 #define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix) | |
423 #endif | |
424 | |
425 #if HAVE__LTOA | |
426 #define SDL_ltoa _ltoa | |
427 #else | |
428 extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix); | |
429 #endif | |
430 | |
431 #if HAVE__UITOA | |
432 #define SDL_uitoa _uitoa | |
433 #else | |
434 #define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix) | |
435 #endif | |
436 | |
437 #if HAVE__ULTOA | |
438 #define SDL_ultoa _ultoa | |
439 #else | |
440 extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix); | |
441 #endif | |
442 | |
443 #if HAVE_STRTOL | |
444 #define SDL_strtol strtol | |
445 #else | |
446 extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base); | |
447 #endif | |
448 | |
449 #if SDL_HAS_64BIT_TYPE | |
450 | |
451 #if HAVE__I64TOA | |
452 #define SDL_lltoa _i64toa | |
453 #else | |
454 extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix); | |
455 #endif | |
456 | |
457 #if HAVE__UI64TOA | |
458 #define SDL_ulltoa _ui64toa | |
459 #else | |
460 extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix); | |
461 #endif | |
462 | |
463 #if HAVE_STRTOLL | |
464 #define SDL_strtoll strtoll | |
465 #else | |
466 extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base); | |
467 #endif | |
468 | |
469 #endif /* SDL_HAS_64BIT_TYPE */ | |
470 | |
471 #if HAVE_STRTOD | |
472 #define SDL_strtod strtod | |
473 #else | |
474 extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp); | |
475 #endif | |
476 | |
477 #if HAVE_ATOI | |
478 #define SDL_atoi atoi | |
479 #else | |
480 #define SDL_atoi(X) SDL_strtol(X, NULL, 0) | |
481 #endif | |
482 | |
483 #if HAVE_ATOF | |
484 #define SDL_atof atof | |
485 #else | |
486 #define SDL_atof(X) SDL_strtod(X, NULL) | |
487 #endif | |
488 | |
489 #if HAVE_STRCMP | |
490 #define SDL_strcmp strcmp | |
491 #else | |
492 extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); | |
493 #endif | |
494 | |
495 #if HAVE_STRNCMP | |
496 #define SDL_strncmp strncmp | |
497 #else | |
498 extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); | |
499 #endif | |
500 | |
501 #if HAVE_STRCASECMP | |
502 #define SDL_strcasecmp strcasecmp | |
503 #elif HAVE_STRICMP | |
504 #define SDL_strcasecmp stricmp | |
505 #else | |
506 extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); | |
507 #endif | |
508 | |
509 #if HAVE_SSCANF | |
510 #define SDL_sscanf sscanf | |
511 #else | |
512 extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...); | |
513 #endif | |
514 | |
515 #if HAVE_SNPRINTF | |
516 #define SDL_snprintf snprintf | |
517 #else | |
518 extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...); | |
519 #endif | |
520 | |
521 #if HAVE_VSNPRINTF | |
522 #define SDL_vsnprintf vsnprintf | |
523 #else | |
524 extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); | |
525 #endif | |
526 | |
527 /* Ends C function definitions when using C++ */ | |
528 #ifdef __cplusplus | |
529 } | |
530 #endif | |
531 #include "close_code.h" | |
532 | |
533 #endif /* _SDL_stdinc_h */ |