Mercurial > sdl-ios-xcode
comparison include/SDL_string.h @ 1336:3692456e7b0f
Use SDL_ prefixed versions of C library functions.
FIXME:
Change #include <stdlib.h> to #include "SDL_stdlib.h"
Change #include <string.h> to #include "SDL_string.h"
Make sure nothing else broke because of this...
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 07 Feb 2006 06:59:48 +0000 |
parents | 450721ad5436 |
children | d02b552e5304 |
comparison
equal
deleted
inserted
replaced
1335:c39265384763 | 1336:3692456e7b0f |
---|---|
42 /* Set up for C function definitions, even when using C++ */ | 42 /* Set up for C function definitions, even when using C++ */ |
43 #ifdef __cplusplus | 43 #ifdef __cplusplus |
44 extern "C" { | 44 extern "C" { |
45 #endif | 45 #endif |
46 | 46 |
47 #ifndef HAVE_MEMSET | 47 #ifdef HAVE_MEMSET |
48 #define memset SDL_memset | 48 #define SDL_memset memset |
49 #endif | 49 #else |
50 #ifndef SDL_memset | |
51 extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len); | 50 extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len); |
52 #endif | 51 #endif |
53 | 52 |
54 #if defined(__GNUC__) && defined(i386) | 53 #if defined(__GNUC__) && defined(i386) |
55 #define SDL_memset4(dst, val, len) \ | 54 #define SDL_memset4(dst, val, len) \ |
96 "2:" \ | 95 "2:" \ |
97 : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ | 96 : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ |
98 : "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \ | 97 : "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \ |
99 : "memory" ); \ | 98 : "memory" ); \ |
100 } while(0) | 99 } while(0) |
101 #define SDL_memcpy4(dst, src, len) \ | |
102 do { \ | |
103 int ecx, edi, esi; \ | |
104 __asm__ __volatile__ ( \ | |
105 "cld\n\t" \ | |
106 "rep ; movsl" \ | |
107 : "=&c" (ecx), "=&D" (edi), "=&S" (esi) \ | |
108 : "0" ((unsigned)(len)), "1" (dst), "2" (src) \ | |
109 : "memory" ); \ | |
110 } while(0) | |
111 #endif | |
112 #ifndef HAVE_MEMCPY | |
113 #define memcpy SDL_memcpy | |
114 #endif | 100 #endif |
115 #ifndef SDL_memcpy | 101 #ifndef SDL_memcpy |
102 #ifdef HAVE_MEMCPY | |
103 #define SDL_memcpy memcpy | |
104 #else | |
116 extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len); | 105 extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len); |
106 #endif | |
117 #endif | 107 #endif |
118 | 108 |
119 #if defined(__GNUC__) && defined(i386) | 109 #if defined(__GNUC__) && defined(i386) |
120 #define SDL_memcpy4(dst, src, len) \ | 110 #define SDL_memcpy4(dst, src, len) \ |
121 do { \ | 111 do { \ |
160 #endif | 150 #endif |
161 #ifndef SDL_revcpy | 151 #ifndef SDL_revcpy |
162 extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len); | 152 extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len); |
163 #endif | 153 #endif |
164 | 154 |
165 #ifndef HAVE_MEMMOVE | 155 #ifdef HAVE_MEMMOVE |
166 #define memmove SDL_memmove | 156 #define SDL_memmove memmove |
167 #endif | 157 #else |
168 #define SDL_memmove(dst, src, len) \ | 158 #define SDL_memmove(dst, src, len) \ |
169 do { \ | 159 do { \ |
170 if ( dst < src ) { \ | 160 if ( dst < src ) { \ |
171 SDL_memcpy(dst, src, len); \ | 161 SDL_memcpy(dst, src, len); \ |
172 } else { \ | 162 } else { \ |
173 SDL_revcpy(dst, src, len); \ | 163 SDL_revcpy(dst, src, len); \ |
174 } \ | 164 } \ |
175 } while(0) | 165 } while(0) |
176 | 166 #endif |
177 #ifndef HAVE_MEMCMP | 167 |
178 #define memcmp SDL_memcmp | 168 #ifdef HAVE_MEMCMP |
179 #endif | 169 #define SDL_memcmp memcmp |
180 #ifndef SDL_memcmp | 170 #else |
181 extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); | 171 extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); |
182 #endif | 172 #endif |
183 | 173 |
184 #ifdef HAVE_STRLEN | 174 #ifdef HAVE_STRLEN |
185 #define SDL_strlen strlen | 175 #define SDL_strlen strlen |
186 #else | 176 #else |
187 #define strlen SDL_strlen | |
188 extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string); | 177 extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string); |
189 #endif | 178 #endif |
190 | 179 |
191 #ifdef HAVE_STRCPY | 180 #ifdef HAVE_STRCPY |
192 #define SDL_strcpy strcpy | 181 #define SDL_strcpy strcpy |
193 #else | 182 #else |
194 #define strcpy SDL_strcpy | |
195 extern DECLSPEC char * SDLCALL SDL_strcpy(char *dst, const char *src); | 183 extern DECLSPEC char * SDLCALL SDL_strcpy(char *dst, const char *src); |
196 #endif | 184 #endif |
197 | 185 |
198 #ifdef HAVE_STRNCPY | 186 #ifdef HAVE_STRNCPY |
199 #define SDL_strncpy strncpy | 187 #define SDL_strncpy strncpy |
200 #else | 188 #else |
201 #define strncpy SDL_strncpy | |
202 extern DECLSPEC char * SDLCALL SDL_strncpy(char *dst, const char *src, size_t maxlen); | 189 extern DECLSPEC char * SDLCALL SDL_strncpy(char *dst, const char *src, size_t maxlen); |
190 #endif | |
191 | |
192 #ifdef HAVE_STRCAT | |
193 #define SDL_strcat strcat | |
194 #else | |
195 #define SDL_strcat(dst, src) (SDL_strcpy(dst+SDL_strlen(dst), src), dst) | |
196 #endif | |
197 | |
198 #ifdef HAVE_STRNCAT | |
199 #define SDL_strncat strncat | |
200 #else | |
201 #define SDL_strncat(dst, src, n) (SDL_strncpy(dst+SDL_strlen(dst), src, n), dst) | |
203 #endif | 202 #endif |
204 | 203 |
205 #ifdef HAVE__STRREV | 204 #ifdef HAVE__STRREV |
206 #define SDL_strrev _strrev | 205 #define SDL_strrev _strrev |
207 #else | 206 #else |
208 #define _strrev SDL_strrev | |
209 extern DECLSPEC char * SDLCALL SDL_strrev(char *string); | 207 extern DECLSPEC char * SDLCALL SDL_strrev(char *string); |
210 #endif | 208 #endif |
211 | 209 |
212 #ifdef HAVE__STRUPR | 210 #ifdef HAVE__STRUPR |
213 #define SDL_strupr _strupr | 211 #define SDL_strupr _strupr |
214 #else | 212 #else |
215 #define _strupr SDL_strupr | |
216 extern DECLSPEC char * SDLCALL SDL_strupr(char *string); | 213 extern DECLSPEC char * SDLCALL SDL_strupr(char *string); |
217 #endif | 214 #endif |
218 | 215 |
219 #ifdef HAVE__STRLWR | 216 #ifdef HAVE__STRLWR |
220 #define SDL_strlwr _strlwr | 217 #define SDL_strlwr _strlwr |
221 #else | 218 #else |
222 #define _strlwr SDL_strlwr | |
223 extern DECLSPEC char * SDLCALL SDL_strlwr(char *string); | 219 extern DECLSPEC char * SDLCALL SDL_strlwr(char *string); |
224 #endif | 220 #endif |
225 | 221 |
226 #ifdef HAVE_STRCHR | 222 #ifdef HAVE_STRCHR |
227 #define SDL_strchr strchr | 223 #define SDL_strchr strchr |
228 #else | 224 #else |
229 #define strchr SDL_strchr | |
230 extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c); | 225 extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c); |
231 #endif | 226 #endif |
232 | 227 |
233 #ifdef HAVE_STRRCHR | 228 #ifdef HAVE_STRRCHR |
234 #define SDL_strrchr strrchr | 229 #define SDL_strrchr strrchr |
235 #else | 230 #else |
236 #define strrchr SDL_strrchr | |
237 extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c); | 231 extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c); |
238 #endif | 232 #endif |
239 | 233 |
240 #ifdef HAVE_STRSTR | 234 #ifdef HAVE_STRSTR |
241 #define SDL_strstr strstr | 235 #define SDL_strstr strstr |
242 #else | 236 #else |
243 #define strstr SDL_strstr | |
244 extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle); | 237 extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle); |
245 #endif | 238 #endif |
246 | 239 |
247 #ifdef HAVE_ITOA | 240 #ifdef HAVE_ITOA |
248 #define SDL_itoa itoa | 241 #define SDL_itoa itoa |
249 #else | 242 #else |
250 #define itoa SDL_itoa | |
251 #define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix) | 243 #define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix) |
252 #endif | 244 #endif |
253 | 245 |
254 #ifdef HAVE__LTOA | 246 #ifdef HAVE__LTOA |
255 #define SDL_ltoa _ltoa | 247 #define SDL_ltoa _ltoa |
256 #else | 248 #else |
257 #define _ltoa SDL_ltoa | |
258 extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix); | 249 extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix); |
259 #endif | 250 #endif |
260 | 251 |
261 #ifdef HAVE__UITOA | 252 #ifdef HAVE__UITOA |
262 #define SDL_uitoa _uitoa | 253 #define SDL_uitoa _uitoa |
263 #else | 254 #else |
264 #define _uitoa SDL_uitoa | |
265 #define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix) | 255 #define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix) |
266 #endif | 256 #endif |
267 | 257 |
268 #ifdef HAVE__ULTOA | 258 #ifdef HAVE__ULTOA |
269 #define SDL_ultoa _ultoa | 259 #define SDL_ultoa _ultoa |
270 #else | 260 #else |
271 #define _ultoa SDL_ultoa | |
272 extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix); | 261 extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix); |
273 #endif | 262 #endif |
274 | 263 |
275 #ifdef HAVE_STRTOL | 264 #ifdef HAVE_STRTOL |
276 #define SDL_strtol strtol | 265 #define SDL_strtol strtol |
277 #else | 266 #else |
278 #define strtol SDL_strtol | |
279 extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base); | 267 extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base); |
280 #endif | 268 #endif |
281 | 269 |
282 #ifdef SDL_HAS_64BIT_TYPE | 270 #ifdef SDL_HAS_64BIT_TYPE |
283 | 271 |
284 #ifdef HAVE__I64TOA | 272 #ifdef HAVE__I64TOA |
285 #define SDL_lltoa _i64toa | 273 #define SDL_lltoa _i64toa |
286 #else | 274 #else |
287 #define _i64toa SDL_lltoa | |
288 extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix); | 275 extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix); |
289 #endif | 276 #endif |
290 | 277 |
291 #ifdef HAVE__UI64TOA | 278 #ifdef HAVE__UI64TOA |
292 #define SDL_ulltoa _ui64toa | 279 #define SDL_ulltoa _ui64toa |
293 #else | 280 #else |
294 #define _ui64toa SDL_ulltoa | |
295 extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix); | 281 extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix); |
296 #endif | 282 #endif |
297 | 283 |
298 #ifdef HAVE_STRTOLL | 284 #ifdef HAVE_STRTOLL |
299 #define SDL_strtoll strtoll | 285 #define SDL_strtoll strtoll |
300 #else | 286 #else |
301 #define strtoll SDL_strtoll | |
302 extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base); | 287 extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base); |
303 #endif | 288 #endif |
304 | 289 |
305 #endif /* SDL_HAS_64BIT_TYPE */ | 290 #endif /* SDL_HAS_64BIT_TYPE */ |
306 | 291 |
307 #ifdef HAVE_STRCMP | 292 #ifdef HAVE_STRCMP |
308 #define SDL_strcmp strcmp | 293 #define SDL_strcmp strcmp |
309 #else | 294 #else |
310 #define strcmp SDL_strcmp | |
311 extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); | 295 extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); |
312 #endif | 296 #endif |
313 | 297 |
314 #ifdef HAVE_STRNCMP | 298 #ifdef HAVE_STRNCMP |
315 #define SDL_strncmp strncmp | 299 #define SDL_strncmp strncmp |
316 #else | 300 #else |
317 #define strncmp SDL_strncmp | |
318 extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); | 301 extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); |
319 #endif | 302 #endif |
320 | 303 |
321 #if defined(HAVE_STRICMP) && !defined(HAVE_STRCASECMP) | 304 #if defined(HAVE_STRICMP) && !defined(HAVE_STRCASECMP) |
322 #define strcasecmp stricmp | 305 #define strcasecmp stricmp |
323 #define HAVE_STRCASECMP | 306 #define HAVE_STRCASECMP |
324 #endif | 307 #endif |
325 #ifdef HAVE_STRCASECMP | 308 #ifdef HAVE_STRCASECMP |
326 #define SDL_strcasecmp strcasecmp | 309 #define SDL_strcasecmp strcasecmp |
327 #else | 310 #else |
328 #define strcasecmp SDL_strcasecmp | |
329 extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); | 311 extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); |
330 #endif | 312 #endif |
331 | 313 |
332 #ifdef HAVE_SSCANF | 314 #ifdef HAVE_SSCANF |
333 #define SDL_sscanf sscanf | 315 #define SDL_sscanf sscanf |
334 #else | 316 #else |
335 #define sscanf SDL_sscanf | |
336 extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...); | 317 extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...); |
337 #endif | 318 #endif |
338 | 319 |
339 #ifdef HAVE_SNPRINTF | 320 #ifdef HAVE_SNPRINTF |
340 #define SDL_snprintf snprintf | 321 #define SDL_snprintf snprintf |
341 #else | 322 #else |
342 #define snprintf SDL_snprintf | |
343 extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...); | 323 extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...); |
344 #endif | 324 #endif |
345 | 325 |
346 #ifdef HAVE_VSNPRINTF | 326 #ifdef HAVE_VSNPRINTF |
347 #define SDL_vsnprintf vsnprintf | 327 #define SDL_vsnprintf vsnprintf |
348 #else | 328 #else |
349 #define vsnprintf SDL_vsnprintf | |
350 extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); | 329 extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); |
351 #endif | 330 #endif |
352 | 331 |
353 /* Ends C function definitions when using C++ */ | 332 /* Ends C function definitions when using C++ */ |
354 #ifdef __cplusplus | 333 #ifdef __cplusplus |