]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - misc/buildfiles/osx/Xonotic-SDL.app/Contents/Frameworks/SDL.framework/Versions/A/Headers/SDL_stdinc.h
update to SDL 1.2.14
[xonotic/xonotic.git] / misc / buildfiles / osx / Xonotic-SDL.app / Contents / Frameworks / SDL.framework / Versions / A / Headers / SDL_stdinc.h
index e47c21daffa1fd9d1fb40a61a89ba65b45cc568d..e1f85fb75ab2f7b313789973a80dc9a7607d98c7 100644 (file)
@@ -1,6 +1,6 @@
 /*
     SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2006 Sam Lantinga
+    Copyright (C) 1997-2009 Sam Lantinga
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Lesser General Public
@@ -20,7 +20,9 @@
     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
 #ifdef HAVE_CTYPE_H
 # include <ctype.h>
 #endif
-#ifdef HAVE_ICONV_H
+#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
 # include <iconv.h>
 #endif
 
-/* The number of elements in an array */
+/** The number of elements in an array */
 #define SDL_arraysize(array)   (sizeof(array)/sizeof(array[0]))
 #define SDL_TABLESIZE(table)   SDL_arraysize(table)
 
-/* Basic data types */
-typedef enum SDL_bool {
+/* Use proper C++ casts when compiled as C++ to be compatible with the option
+ -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above. */
+#ifdef __cplusplus
+#define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
+#define SDL_static_cast(type, expression) static_cast<type>(expression)
+#else
+#define SDL_reinterpret_cast(type, expression) ((type)(expression))
+#define SDL_static_cast(type, expression) ((type)(expression))
+#endif
+
+/** @name Basic data types */
+/*@{*/
+typedef enum {
        SDL_FALSE = 0,
        SDL_TRUE  = 1
 } SDL_bool;
@@ -102,7 +115,10 @@ typedef struct {
 } Uint64, Sint64;
 #endif
 
-/* Make sure the types really have the right sizes */
+/*@}*/
+
+/** @name Make sure the types really have the right sizes */
+/*@{*/
 #define SDL_COMPILE_TIME_ASSERT(name, x)               \
        typedef int SDL_dummy_ ## name[(x) * 2 - 1]
 
@@ -114,12 +130,14 @@ 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);
-
-/* 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
-   enums having the size of an int must be enabled.
-   This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).
-*/
+/*@}*/
+
+/** @name Enum Size Check
+ *  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
+ *  enums having the size of an int must be enabled.
+ *  This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).
+ */
 /* Enable enums always int in CodeWarrior (for MPW use "-enum int") */
 #ifdef __MWERKS__
 #pragma enumsalwaysint on
@@ -132,7 +150,7 @@ typedef enum {
 #ifndef __NDS__
 SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
 #endif
-
+/*@}*/
 
 #include "begin_code.h"
 /* Set up for C function definitions, even when using C++ */
@@ -248,7 +266,7 @@ do {                                                                \
                "cld\n\t"                                       \
                "rep ; stosl\n\t"                               \
                : "=&D" (u0), "=&a" (u1), "=&c" (u2)            \
-               : "0" (dst), "1" (val), "2" ((Uint32)(len))     \
+               : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len))      \
                : "memory" );                                   \
 } while(0)
 #endif
@@ -257,8 +275,9 @@ do {                                                                \
 do {                                           \
        unsigned _count = (len);                \
        unsigned _n = (_count + 3) / 4;         \
-       Uint32 *_p = (Uint32 *)(dst);           \
+       Uint32 *_p = SDL_static_cast(Uint32 *, dst);    \
        Uint32 _val = (val);                    \
+       if (len == 0) break;                    \
         switch (_count % 4) {                  \
         case 0: do {    *_p++ = _val;          \
         case 3:         *_p++ = _val;          \
@@ -287,7 +306,7 @@ do {                                                                          \
                "movsb\n"                                                 \
                "2:"                                                      \
                : "=&c" (u0), "=&D" (u1), "=&S" (u2)                      \
-               : "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \
+               : "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst),"2" (src) \
                : "memory" );                                             \
 } while(0)
 #endif
@@ -312,7 +331,7 @@ do {                                                                \
                "cld\n\t"                                       \
                "rep ; movsl"                                   \
                : "=&c" (ecx), "=&D" (edi), "=&S" (esi)         \
-               : "0" ((unsigned)(len)), "1" (dst), "2" (src)   \
+               : "0" (SDL_static_cast(unsigned, len)), "1" (dst), "2" (src)    \
                : "memory" );                                   \
 } while(0)
 #endif
@@ -324,13 +343,14 @@ do {                                                              \
 #define SDL_revcpy(dst, src, len)                      \
 do {                                                   \
        int u0, u1, u2;                                 \
-       char *dstp = (char *)(dst);                     \
-       char *srcp = (char *)(src);                     \
+       char *dstp = SDL_static_cast(char *, dst);      \
+       char *srcp = SDL_static_cast(char *, src);      \
        int n = (len);                                  \
        if ( n >= 4 ) {                                 \
        __asm__ __volatile__ (                          \
                "std\n\t"                               \
                "rep ; movsl\n\t"                       \
+               "cld\n\t"                               \
                : "=&c" (u0), "=&D" (u1), "=&S" (u2)    \
                : "0" (n >> 2),                         \
                  "1" (dstp+(n-4)), "2" (srcp+(n-4))    \
@@ -563,13 +583,17 @@ extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *
 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 */
+/** @name SDL_ICONV Error Codes
+ *  The SDL implementation of iconv() returns these error codes 
+ */
+/*@{*/
 #define SDL_ICONV_ERROR                (size_t)-1
 #define SDL_ICONV_E2BIG                (size_t)-2
 #define SDL_ICONV_EILSEQ       (size_t)-3
 #define SDL_ICONV_EINVAL       (size_t)-4
+/*@}*/
 
-#ifdef HAVE_ICONV
+#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
 #define SDL_iconv_t     iconv_t
 #define SDL_iconv_open  iconv_open
 #define SDL_iconv_close iconv_close
@@ -579,9 +603,9 @@ extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, const cha
 extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
 #endif
 extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
-/* This function converts a string between encodings in one pass, returning a
-   string that must be freed with SDL_free() or NULL on error.
-*/
+/** 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, const char *inbuf, size_t inbytesleft);
 #define SDL_iconv_utf8_locale(S)       SDL_iconv_string("", "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)