SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401938
This commit is contained in:
Sam Lantinga 2006-07-10 21:04:37 +00:00
parent 91a32b77a2
commit 0f030a1802
686 changed files with 117556 additions and 98661 deletions

View file

@ -20,7 +20,11 @@
slouken@libsdl.org
*/
/* This is a general header that includes C language support */
/**
* \file SDL_stdinc.h
*
* This is a general header that includes C language support
*/
#ifndef _SDL_stdinc_h
#define _SDL_stdinc_h
@ -77,33 +81,66 @@
#define SDL_TABLESIZE(table) SDL_arraysize(table)
/* Basic data types */
typedef enum SDL_bool {
SDL_FALSE = 0,
SDL_TRUE = 1
typedef enum SDL_bool
{
SDL_FALSE = 0,
SDL_TRUE = 1
} SDL_bool;
typedef int8_t Sint8;
typedef uint8_t Uint8;
typedef int16_t Sint16;
typedef uint16_t Uint16;
typedef int32_t Sint32;
typedef uint32_t Uint32;
/**
* \typedef Sint8
* \brief A signed 8-bit integer type.
*/
typedef int8_t Sint8;
/**
* \typedef Uint8
* \brief An unsigned 8-bit integer type.
*/
typedef uint8_t Uint8;
/**
* \typedef Sint16
* \brief A signed 16-bit integer type.
*/
typedef int16_t Sint16;
/**
* \typedef Uint16
* \brief An unsigned 16-bit integer type.
*/
typedef uint16_t Uint16;
/**
* \typedef Sint32
* \brief A signed 32-bit integer type.
*/
typedef int32_t Sint32;
/**
* \typedef Uint32
* \brief An unsigned 32-bit integer type.
*/
typedef uint32_t Uint32;
#ifdef SDL_HAS_64BIT_TYPE
typedef int64_t Sint64;
typedef uint64_t Uint64;
/**
* \typedef Sint64
* \brief A signed 64-bit integer type.
* \warning On platforms without any sort of 64-bit datatype, this is equivalent to Sint32!
*/
typedef int64_t Sint64;
/**
* \typedef Uint64
* \brief An unsigned 64-bit integer type.
* \warning On platforms without any sort of 64-bit datatype, this is equivalent to Uint32!
*/
typedef uint64_t Uint64;
#else
/* This is really just a hack to prevent the compiler from complaining */
typedef struct {
Uint32 hi;
Uint32 lo;
} Uint64, Sint64;
typdef Sint32 Sint64;
typdef Uint32 Uint32;
#endif
/* Make sure the types really have the right sizes */
#define SDL_COMPILE_TIME_ASSERT(name, x) \
typedef int SDL_dummy_ ## name[(x) * 2 - 1]
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
@ -112,6 +149,7 @@ SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
/* Check to make sure enums are the size of ints, for structure packing.
For both Watcom C/C++ and Borland C/C++ the compiler option that makes
@ -123,35 +161,39 @@ SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
#pragma enumsalwaysint on
#endif
typedef enum {
DUMMY_ENUM_VALUE
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
typedef enum
{
DUMMY_ENUM_VALUE
} SDL_DUMMY_ENUM;
SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
#ifdef HAVE_MALLOC
#define SDL_malloc malloc
#else
extern DECLSPEC void * SDLCALL SDL_malloc(size_t size);
extern DECLSPEC void *SDLCALL SDL_malloc(size_t size);
#endif
#ifdef HAVE_CALLOC
#define SDL_calloc calloc
#else
extern DECLSPEC void * SDLCALL SDL_calloc(size_t nmemb, size_t size);
extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size);
#endif
#ifdef HAVE_REALLOC
#define SDL_realloc realloc
#else
extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size);
extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size);
#endif
#ifdef HAVE_FREE
@ -173,11 +215,11 @@ extern DECLSPEC void SDLCALL SDL_free(void *mem);
# elif defined(__DMC__)
# include <stdlib.h>
# elif defined(__AIX__)
#pragma alloca
#pragma alloca
# elif defined(__MRC__)
void *alloca (unsigned);
void *alloca(unsigned);
# else
char *alloca ();
char *alloca();
# endif
#endif
#ifdef HAVE_ALLOCA
@ -191,7 +233,7 @@ extern DECLSPEC void SDLCALL SDL_free(void *mem);
#ifdef HAVE_GETENV
#define SDL_getenv getenv
#else
extern DECLSPEC char * SDLCALL SDL_getenv(const char *name);
extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
#endif
#ifdef HAVE_PUTENV
@ -204,7 +246,8 @@ extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
#define SDL_qsort qsort
#else
extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
int (*compare)(const void *, const void *));
int (*compare) (const void *,
const void *));
#endif
#ifdef HAVE_ABS
@ -231,8 +274,10 @@ extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
#ifdef HAVE_MEMSET
#define SDL_memset memset
#else
extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len);
extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len);
#endif
#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x)))
#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
#if defined(__GNUC__) && defined(i386)
#define SDL_memset4(dst, val, len) \
@ -288,7 +333,8 @@ do { \
#elif defined(HAVE_BCOPY)
#define SDL_memcpy(d, s, n) bcopy((s), (d), (n))
#else
extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len);
extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src,
size_t len);
#endif
#endif
@ -335,7 +381,8 @@ do { \
} while(0)
#endif
#ifndef SDL_revcpy
extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len);
extern DECLSPEC void *SDLCALL SDL_revcpy(void *dst, const void *src,
size_t len);
#endif
#ifdef HAVE_MEMMOVE
@ -356,7 +403,8 @@ do { \
#ifdef HAVE_MEMCMP
#define SDL_memcmp memcmp
#else
extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2,
size_t len);
#endif
#ifdef HAVE_STRLEN
@ -368,37 +416,39 @@ extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
#ifdef HAVE_STRLCPY
#define SDL_strlcpy strlcpy
#else
extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen);
extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src,
size_t maxlen);
#endif
#ifdef HAVE_STRLCAT
#define SDL_strlcat strlcat
#else
extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen);
extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src,
size_t maxlen);
#endif
#ifdef HAVE_STRDUP
#define SDL_strdup strdup
#else
extern DECLSPEC char * SDLCALL SDL_strdup(const char *string);
extern DECLSPEC char *SDLCALL SDL_strdup(const char *string);
#endif
#ifdef HAVE__STRREV
#define SDL_strrev _strrev
#else
extern DECLSPEC char * SDLCALL SDL_strrev(char *string);
extern DECLSPEC char *SDLCALL SDL_strrev(char *string);
#endif
#ifdef HAVE__STRUPR
#define SDL_strupr _strupr
#else
extern DECLSPEC char * SDLCALL SDL_strupr(char *string);
extern DECLSPEC char *SDLCALL SDL_strupr(char *string);
#endif
#ifdef HAVE__STRLWR
#define SDL_strlwr _strlwr
#else
extern DECLSPEC char * SDLCALL SDL_strlwr(char *string);
extern DECLSPEC char *SDLCALL SDL_strlwr(char *string);
#endif
#ifdef HAVE_STRCHR
@ -406,7 +456,7 @@ extern DECLSPEC char * SDLCALL SDL_strlwr(char *string);
#elif defined(HAVE_INDEX)
#define SDL_strchr index
#else
extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c);
extern DECLSPEC char *SDLCALL SDL_strchr(const char *string, int c);
#endif
#ifdef HAVE_STRRCHR
@ -414,13 +464,14 @@ extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c);
#elif defined(HAVE_RINDEX)
#define SDL_strrchr rindex
#else
extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c);
extern DECLSPEC char *SDLCALL SDL_strrchr(const char *string, int c);
#endif
#ifdef HAVE_STRSTR
#define SDL_strstr strstr
#else
extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle);
extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack,
const char *needle);
#endif
#ifdef HAVE_ITOA
@ -432,7 +483,7 @@ extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *need
#ifdef HAVE__LTOA
#define SDL_ltoa _ltoa
#else
extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix);
extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *string, int radix);
#endif
#ifdef HAVE__UITOA
@ -444,19 +495,22 @@ extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix);
#ifdef HAVE__ULTOA
#define SDL_ultoa _ultoa
#else
extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix);
extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *string,
int radix);
#endif
#ifdef HAVE_STRTOL
#define SDL_strtol strtol
#else
extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base);
extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp,
int base);
#endif
#ifdef HAVE_STRTOUL
#define SDL_strtoul strtoul
#else
extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, char **endp, int base);
extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string,
char **endp, int base);
#endif
#ifdef SDL_HAS_64BIT_TYPE
@ -464,25 +518,29 @@ extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, char **end
#ifdef HAVE__I64TOA
#define SDL_lltoa _i64toa
#else
extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix);
extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *string,
int radix);
#endif
#ifdef HAVE__UI64TOA
#define SDL_ulltoa _ui64toa
#else
extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix);
extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *string,
int radix);
#endif
#ifdef HAVE_STRTOLL
#define SDL_strtoll strtoll
#else
extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base);
extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp,
int base);
#endif
#ifdef HAVE_STRTOULL
#define SDL_strtoull strtoull
#else
extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp, int base);
extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp,
int base);
#endif
#endif /* SDL_HAS_64BIT_TYPE */
@ -514,7 +572,8 @@ extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
#ifdef HAVE_STRNCMP
#define SDL_strncmp strncmp
#else
extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen);
extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2,
size_t maxlen);
#endif
#ifdef HAVE_STRCASECMP
@ -522,7 +581,8 @@ extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size
#elif defined(HAVE__STRICMP)
#define SDL_strcasecmp _stricmp
#else
extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1,
const char *str2);
#endif
#ifdef HAVE_STRNCASECMP
@ -530,25 +590,29 @@ extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
#elif defined(HAVE__STRNICMP)
#define SDL_strncasecmp _strnicmp
#else
extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen);
extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1,
const char *str2, size_t maxlen);
#endif
#ifdef HAVE_SSCANF
#define SDL_sscanf sscanf
#else
extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...);
extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt,
...);
#endif
#ifdef HAVE_SNPRINTF
#define SDL_snprintf snprintf
#else
extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...);
extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen,
const char *fmt, ...);
#endif
#ifdef HAVE_VSNPRINTF
#define SDL_vsnprintf vsnprintf
#else
extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen,
const char *fmt, va_list ap);
#endif
/* The SDL implementation of iconv() returns these error codes */
@ -561,17 +625,25 @@ extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char
#define SDL_iconv_t iconv_t
#define SDL_iconv_open iconv_open
#define SDL_iconv_close iconv_close
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf,
size_t * inbytesleft, char **outbuf,
size_t * outbytesleft);
#else
typedef struct _SDL_iconv_t *SDL_iconv_t;
extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, const char *fromcode);
extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode,
const char *fromcode);
extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf,
size_t * inbytesleft, char **outbuf,
size_t * outbytesleft);
#endif
/* This function converts a string between encodings in one pass, returning a
string that must be freed with SDL_free() or NULL on error.
*/
extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, char *inbuf, size_t inbytesleft);
extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
const char *fromcode,
char *inbuf,
size_t inbytesleft);
#define SDL_iconv_utf8_ascii(S) SDL_iconv_string("ASCII", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_utf8_latin1(S) SDL_iconv_string("LATIN1", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
@ -579,8 +651,12 @@ extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_stdinc_h */
/* vi: set ts=4 sw=4 expandtab: */