Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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...
  • Loading branch information
slouken committed Feb 7, 2006
1 parent 57f0f66 commit 41ee6df
Show file tree
Hide file tree
Showing 212 changed files with 1,840 additions and 1,884 deletions.
12 changes: 7 additions & 5 deletions include/SDL_config.h
Expand Up @@ -54,16 +54,16 @@
#endif /* !_WIN32_WCE */

/* Features provided by SDL_stdlib.h */
#if !defined(_WIN32) /* Don't use C runtime versions of these on Windows */
#define HAVE_GETENV
#define HAVE_PUTENV
#endif
#define HAVE_MALLOC
#define HAVE_REALLOC
#define HAVE_FREE
#ifndef HAVE_ALLOCA
#define HAVE_ALLOCA
#endif
#if !defined(_WIN32) /* Don't use C runtime versions of these on Windows */
#define HAVE_GETENV
#define HAVE_PUTENV
#endif
/*#define HAVE_QSORT*/

/* Features provided by SDL_string.h */
Expand All @@ -74,6 +74,8 @@
#define HAVE_STRLEN
#define HAVE_STRCPY
#define HAVE_STRNCPY
#define HAVE_STRCAT
#define HAVE_STRNCAT
/*#define HAVE__STRREV*/
/*#define HAVE__STRUPR*/
/*#define HAVE__STRLWR*/
Expand All @@ -94,7 +96,7 @@
/*#define HAVE_STRCASECMP*/
#define HAVE_SSCANF
/*#define HAVE_SNPRINTF*/
#define HAVE_VSNPRINTF
/*#define HAVE_VSNPRINTF*/

#endif /* HAVE_LIBC */

Expand Down
37 changes: 1 addition & 36 deletions include/SDL_getenv.h
Expand Up @@ -20,39 +20,4 @@
slouken@libsdl.org
*/

#ifndef _SDL_getenv_h
#define _SDL_getenv_h

#include "SDL_config.h"

#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif

#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif

#ifdef HAVE_GETENV
#define SDL_getenv getenv
#else
#define getenv SDL_getenv
extern DECLSPEC char * SDLCALL SDL_getenv(const char *name);
#endif

#ifdef HAVE_PUTENV
#define SDL_putenv putenv
#else
#define putenv SDL_putenv
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
#endif

/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"

#endif /* _SDL_getenv_h */
#include "SDL_stdlib.h"
21 changes: 13 additions & 8 deletions include/SDL_stdlib.h
Expand Up @@ -49,9 +49,6 @@ char *alloca ();
#endif

#include "SDL_types.h"
#include "SDL_stdarg.h"
#include "SDL_getenv.h"


#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
Expand All @@ -62,36 +59,44 @@ extern "C" {
#ifdef HAVE_MALLOC
#define SDL_malloc malloc
#else
#define malloc SDL_malloc
extern DECLSPEC void * SDLCALL SDL_malloc(size_t size);
#endif

#ifdef HAVE_REALLOC
#define SDL_realloc realloc
#else
#define realloc SDL_realloc
extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size);
#endif

#ifdef HAVE_FREE
#define SDL_free free
#else
#define free SDL_free
extern DECLSPEC void SDLCALL SDL_free(void *mem);
#endif

#ifdef HAVE_ALLOCA
#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*count)
#define SDL_stack_free(data)
#else
#define SDL_stack_alloc(type, count) SDL_malloc(sizeof(type)*count)
#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*count)
#define SDL_stack_free(data) SDL_free(data)
#endif

#ifdef HAVE_GETENV
#define SDL_getenv getenv
#else
extern DECLSPEC char * SDLCALL SDL_getenv(const char *name);
#endif

#ifdef HAVE_PUTENV
#define SDL_putenv putenv
#else
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
#endif

#ifdef HAVE_QSORT
#define SDL_qsort qsort
#else
#define qsort SDL_qsort
extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
int (*compare)(const void *, const void *));
#endif
Expand Down
73 changes: 26 additions & 47 deletions include/SDL_string.h
Expand Up @@ -44,10 +44,9 @@
extern "C" {
#endif

#ifndef HAVE_MEMSET
#define memset SDL_memset
#endif
#ifndef SDL_memset
#ifdef HAVE_MEMSET
#define SDL_memset memset
#else
extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len);
#endif

Expand Down Expand Up @@ -98,23 +97,14 @@ do { \
: "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \
: "memory" ); \
} while(0)
#define SDL_memcpy4(dst, src, len) \
do { \
int ecx, edi, esi; \
__asm__ __volatile__ ( \
"cld\n\t" \
"rep ; movsl" \
: "=&c" (ecx), "=&D" (edi), "=&S" (esi) \
: "0" ((unsigned)(len)), "1" (dst), "2" (src) \
: "memory" ); \
} while(0)
#endif
#ifndef HAVE_MEMCPY
#define memcpy SDL_memcpy
#endif
#ifndef SDL_memcpy
#ifdef HAVE_MEMCPY
#define SDL_memcpy memcpy
#else
extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len);
#endif
#endif

#if defined(__GNUC__) && defined(i386)
#define SDL_memcpy4(dst, src, len) \
Expand Down Expand Up @@ -162,9 +152,9 @@ do { \
extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len);
#endif

#ifndef HAVE_MEMMOVE
#define memmove SDL_memmove
#endif
#ifdef HAVE_MEMMOVE
#define SDL_memmove memmove
#else
#define SDL_memmove(dst, src, len) \
do { \
if ( dst < src ) { \
Expand All @@ -173,109 +163,107 @@ do { \
SDL_revcpy(dst, src, len); \
} \
} while(0)

#ifndef HAVE_MEMCMP
#define memcmp SDL_memcmp
#endif
#ifndef SDL_memcmp

#ifdef HAVE_MEMCMP
#define SDL_memcmp memcmp
#else
extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
#endif

#ifdef HAVE_STRLEN
#define SDL_strlen strlen
#else
#define strlen SDL_strlen
extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
#endif

#ifdef HAVE_STRCPY
#define SDL_strcpy strcpy
#else
#define strcpy SDL_strcpy
extern DECLSPEC char * SDLCALL SDL_strcpy(char *dst, const char *src);
#endif

#ifdef HAVE_STRNCPY
#define SDL_strncpy strncpy
#else
#define strncpy SDL_strncpy
extern DECLSPEC char * SDLCALL SDL_strncpy(char *dst, const char *src, size_t maxlen);
#endif

#ifdef HAVE_STRCAT
#define SDL_strcat strcat
#else
#define SDL_strcat(dst, src) (SDL_strcpy(dst+SDL_strlen(dst), src), dst)
#endif

#ifdef HAVE_STRNCAT
#define SDL_strncat strncat
#else
#define SDL_strncat(dst, src, n) (SDL_strncpy(dst+SDL_strlen(dst), src, n), dst)
#endif

#ifdef HAVE__STRREV
#define SDL_strrev _strrev
#else
#define _strrev SDL_strrev
extern DECLSPEC char * SDLCALL SDL_strrev(char *string);
#endif

#ifdef HAVE__STRUPR
#define SDL_strupr _strupr
#else
#define _strupr SDL_strupr
extern DECLSPEC char * SDLCALL SDL_strupr(char *string);
#endif

#ifdef HAVE__STRLWR
#define SDL_strlwr _strlwr
#else
#define _strlwr SDL_strlwr
extern DECLSPEC char * SDLCALL SDL_strlwr(char *string);
#endif

#ifdef HAVE_STRCHR
#define SDL_strchr strchr
#else
#define strchr SDL_strchr
extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c);
#endif

#ifdef HAVE_STRRCHR
#define SDL_strrchr strrchr
#else
#define strrchr SDL_strrchr
extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c);
#endif

#ifdef HAVE_STRSTR
#define SDL_strstr strstr
#else
#define strstr SDL_strstr
extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle);
#endif

#ifdef HAVE_ITOA
#define SDL_itoa itoa
#else
#define itoa SDL_itoa
#define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix)
#endif

#ifdef HAVE__LTOA
#define SDL_ltoa _ltoa
#else
#define _ltoa SDL_ltoa
extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix);
#endif

#ifdef HAVE__UITOA
#define SDL_uitoa _uitoa
#else
#define _uitoa SDL_uitoa
#define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix)
#endif

#ifdef HAVE__ULTOA
#define SDL_ultoa _ultoa
#else
#define _ultoa SDL_ultoa
extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix);
#endif

#ifdef HAVE_STRTOL
#define SDL_strtol strtol
#else
#define strtol SDL_strtol
extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base);
#endif

Expand All @@ -284,21 +272,18 @@ extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int bas
#ifdef HAVE__I64TOA
#define SDL_lltoa _i64toa
#else
#define _i64toa SDL_lltoa
extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix);
#endif

#ifdef HAVE__UI64TOA
#define SDL_ulltoa _ui64toa
#else
#define _ui64toa SDL_ulltoa
extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix);
#endif

#ifdef HAVE_STRTOLL
#define SDL_strtoll strtoll
#else
#define strtoll SDL_strtoll
extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base);
#endif

Expand All @@ -307,14 +292,12 @@ extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int
#ifdef HAVE_STRCMP
#define SDL_strcmp strcmp
#else
#define strcmp SDL_strcmp
extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
#endif

#ifdef HAVE_STRNCMP
#define SDL_strncmp strncmp
#else
#define strncmp SDL_strncmp
extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen);
#endif

Expand All @@ -325,28 +308,24 @@ extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size
#ifdef HAVE_STRCASECMP
#define SDL_strcasecmp strcasecmp
#else
#define strcasecmp SDL_strcasecmp
extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
#endif

#ifdef HAVE_SSCANF
#define SDL_sscanf sscanf
#else
#define sscanf SDL_sscanf
extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...);
#endif

#ifdef HAVE_SNPRINTF
#define SDL_snprintf snprintf
#else
#define snprintf SDL_snprintf
extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...);
#endif

#ifdef HAVE_VSNPRINTF
#define SDL_vsnprintf vsnprintf
#else
#define vsnprintf SDL_vsnprintf
extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
#endif

Expand Down

0 comments on commit 41ee6df

Please sign in to comment.