include/SDL_stdinc.h
changeset 8460 f483e8bdae3c
parent 8439 14d94a8a9fb6
parent 7059 cd194e03c1da
child 8464 a2a909304cfe
     1.1 --- a/include/SDL_stdinc.h	Sat Apr 13 23:03:46 2013 -0400
     1.2 +++ b/include/SDL_stdinc.h	Sun Apr 14 11:42:55 2013 -0400
     1.3 @@ -30,7 +30,6 @@
     1.4  
     1.5  #include "SDL_config.h"
     1.6  
     1.7 -
     1.8  #ifdef HAVE_SYS_TYPES_H
     1.9  #include <sys/types.h>
    1.10  #endif
    1.11 @@ -182,14 +181,10 @@
    1.12     enums having the size of an int must be enabled.
    1.13     This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).
    1.14  */
    1.15 -/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */
    1.16 -#ifdef __MWERKS__
    1.17 -#pragma enumsalwaysint on
    1.18 -#endif
    1.19  
    1.20  /** \cond */
    1.21  #ifndef DOXYGEN_SHOULD_IGNORE_THIS
    1.22 -#if !defined(__NINTENDODS__) && !defined(__ANDROID__) 
    1.23 +#if !defined(__ANDROID__) 
    1.24     /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */
    1.25  typedef enum
    1.26  {
    1.27 @@ -209,30 +204,6 @@
    1.28  /* *INDENT-ON* */
    1.29  #endif
    1.30  
    1.31 -#ifdef HAVE_MALLOC
    1.32 -#define SDL_malloc	malloc
    1.33 -#else
    1.34 -extern DECLSPEC void *SDLCALL SDL_malloc(size_t size);
    1.35 -#endif
    1.36 -
    1.37 -#ifdef HAVE_CALLOC
    1.38 -#define SDL_calloc	calloc
    1.39 -#else
    1.40 -extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size);
    1.41 -#endif
    1.42 -
    1.43 -#ifdef HAVE_REALLOC
    1.44 -#define SDL_realloc	realloc
    1.45 -#else
    1.46 -extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size);
    1.47 -#endif
    1.48 -
    1.49 -#ifdef HAVE_FREE
    1.50 -#define SDL_free	free
    1.51 -#else
    1.52 -extern DECLSPEC void SDLCALL SDL_free(void *mem);
    1.53 -#endif
    1.54 -
    1.55  #if defined(HAVE_ALLOCA) && !defined(alloca)
    1.56  # if defined(HAVE_ALLOCA_H)
    1.57  #  include <alloca.h>
    1.58 @@ -263,380 +234,460 @@
    1.59  #define SDL_stack_free(data)            SDL_free(data)
    1.60  #endif
    1.61  
    1.62 -#ifdef HAVE_GETENV
    1.63 -#define SDL_getenv	getenv
    1.64 -#else
    1.65 -extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
    1.66 +
    1.67 +/* SDL stdinc inline functions:
    1.68 +
    1.69 +   The theory here is that by default we forcibly inline what we can, and your
    1.70 +   app will use the inline version by default. However we expose a non-inline
    1.71 +   version too, so the symbol is always available in the library even if your app
    1.72 +   bypassed the inline version. The SDL_*_inline versions aren't guaranteed to
    1.73 +   exist, so never call them directly; use SDL_* instead, and trust the system
    1.74 +   to give you the right thing.
    1.75 +
    1.76 +   The benefit here is that you can dlsym() these functions, which you
    1.77 +   couldn't if you had macros, you can link against a foreign build of SDL
    1.78 +   even if you configured differently, and you can drop the unconfigured SDL
    1.79 +   headers into a project without #defining HAVE_MALLOC (etc) and still link.
    1.80 +*/
    1.81 +
    1.82 +extern DECLSPEC void *SDLCALL SDL_malloc(size_t size);
    1.83 +#ifdef HAVE_MALLOC
    1.84 +SDL_FORCE_INLINE void *SDL_malloc_inline(size_t size) { return malloc(size); }
    1.85 +#define SDL_malloc SDL_malloc_inline
    1.86  #endif
    1.87  
    1.88 -/* SDL_putenv() has moved to SDL_compat. */
    1.89 -#ifdef HAVE_SETENV
    1.90 -#define SDL_setenv	setenv
    1.91 -#else
    1.92 -extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value,
    1.93 -                                       int overwrite);
    1.94 +extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size);
    1.95 +#ifdef HAVE_CALLOC
    1.96 +SDL_FORCE_INLINE void *SDL_calloc_inline(size_t nmemb, size_t size) { return calloc(nmemb, size); }
    1.97 +#define SDL_calloc SDL_calloc_inline
    1.98  #endif
    1.99  
   1.100 -#ifdef HAVE_QSORT
   1.101 -#define SDL_qsort	qsort
   1.102 -#else
   1.103 -extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
   1.104 -                                       int (*compare) (const void *,
   1.105 -                                                       const void *));
   1.106 +extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size);
   1.107 +#ifdef HAVE_REALLOC
   1.108 +SDL_FORCE_INLINE void *SDL_realloc_inline(void *mem, size_t size) { return realloc(mem, size); }
   1.109 +#define SDL_realloc SDL_realloc_inline
   1.110  #endif
   1.111  
   1.112 -#ifdef HAVE_ABS
   1.113 -#define SDL_abs		abs
   1.114 -#else
   1.115 -#define SDL_abs(X)	((X) < 0 ? -(X) : (X))
   1.116 +extern DECLSPEC void SDLCALL SDL_free(void *mem);
   1.117 +#ifdef HAVE_FREE
   1.118 +SDL_FORCE_INLINE void SDL_free_inline(void *mem) { free(mem); }
   1.119 +#define SDL_free SDL_free_inline
   1.120  #endif
   1.121  
   1.122 -#define SDL_min(x, y)	(((x) < (y)) ? (x) : (y))
   1.123 -#define SDL_max(x, y)	(((x) > (y)) ? (x) : (y))
   1.124 -
   1.125 -#ifdef HAVE_CTYPE_H
   1.126 -#define SDL_isdigit(X)  isdigit(X)
   1.127 -#define SDL_isspace(X)  isspace(X)
   1.128 -#define SDL_toupper(X)  toupper(X)
   1.129 -#define SDL_tolower(X)  tolower(X)
   1.130 -#else
   1.131 -#define SDL_isdigit(X)  (((X) >= '0') && ((X) <= '9'))
   1.132 -#define SDL_isspace(X)  (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n'))
   1.133 -#define SDL_toupper(X)  (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X))
   1.134 -#define SDL_tolower(X)  (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X))
   1.135 +extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
   1.136 +#ifdef HAVE_GETENV
   1.137 +SDL_FORCE_INLINE char *SDL_getenv_inline(const char *name) { return getenv(name); }
   1.138 +#define SDL_getenv SDL_getenv_inline
   1.139  #endif
   1.140  
   1.141 -#ifdef HAVE_MEMSET
   1.142 -#define SDL_memset      memset
   1.143 -#else
   1.144 -extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len);
   1.145 -#endif
   1.146 -#define SDL_zero(x)	SDL_memset(&(x), 0, sizeof((x)))
   1.147 -#define SDL_zerop(x)	SDL_memset((x), 0, sizeof(*(x)))
   1.148 -
   1.149 -#if defined(__GNUC__) && defined(i386)
   1.150 -#define SDL_memset4(dst, val, len)				\
   1.151 -do {								\
   1.152 -	int u0, u1, u2;						\
   1.153 -	__asm__ __volatile__ (					\
   1.154 -		"cld\n\t"					\
   1.155 -		"rep ; stosl\n\t"				\
   1.156 -		: "=&D" (u0), "=&a" (u1), "=&c" (u2)		\
   1.157 -		: "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len))	\
   1.158 -		: "memory" );					\
   1.159 -} while(0)
   1.160 -#endif
   1.161 -#ifndef SDL_memset4
   1.162 -#define SDL_memset4(dst, val, len)		\
   1.163 -do {						\
   1.164 -	unsigned _count = (len);		\
   1.165 -	unsigned _n = (_count + 3) / 4;		\
   1.166 -	Uint32 *_p = SDL_static_cast(Uint32 *, dst);		\
   1.167 -	Uint32 _val = (val);			\
   1.168 -	if (len == 0) break;			\
   1.169 -        switch (_count % 4) {			\
   1.170 -        case 0: do {    *_p++ = _val;		\
   1.171 -        case 3:         *_p++ = _val;		\
   1.172 -        case 2:         *_p++ = _val;		\
   1.173 -        case 1:         *_p++ = _val;		\
   1.174 -		} while ( --_n );		\
   1.175 -	}					\
   1.176 -} while(0)
   1.177 +extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite);
   1.178 +#ifdef HAVE_SETENV
   1.179 +SDL_FORCE_INLINE int SDL_setenv_inline(const char *name, const char *value, int overwrite) { return setenv(name, value, overwrite); }
   1.180 +#define SDL_setenv SDL_setenv_inline
   1.181  #endif
   1.182  
   1.183 -/* We can count on memcpy existing on Mac OS X and being well-tuned. */
   1.184 -#if defined(__MACOSX__)
   1.185 -#define SDL_memcpy      memcpy
   1.186 -#elif defined(__GNUC__) && defined(i386) && !defined(__WIN32__)
   1.187 -#define SDL_memcpy(dst, src, len)					  \
   1.188 -do {									  \
   1.189 -	int u0, u1, u2;						  	  \
   1.190 -	__asm__ __volatile__ (						  \
   1.191 -		"cld\n\t"						  \
   1.192 -		"rep ; movsl\n\t"					  \
   1.193 -		"testb $2,%b4\n\t"					  \
   1.194 -		"je 1f\n\t"						  \
   1.195 -		"movsw\n"						  \
   1.196 -		"1:\ttestb $1,%b4\n\t"					  \
   1.197 -		"je 2f\n\t"						  \
   1.198 -		"movsb\n"						  \
   1.199 -		"2:"							  \
   1.200 -		: "=&c" (u0), "=&D" (u1), "=&S" (u2)			  \
   1.201 -		: "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst),"2" (src) \
   1.202 -		: "memory" );						  \
   1.203 -} while(0)
   1.204 -#endif
   1.205 -#ifndef SDL_memcpy
   1.206 -#ifdef HAVE_MEMCPY
   1.207 -#define SDL_memcpy      memcpy
   1.208 -#elif defined(HAVE_BCOPY)
   1.209 -#define SDL_memcpy(d, s, n)	bcopy((s), (d), (n))
   1.210 -#else
   1.211 -extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src,
   1.212 -                                         size_t len);
   1.213 -#endif
   1.214 +extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *));
   1.215 +#ifdef HAVE_QSORT
   1.216 +SDL_FORCE_INLINE void SDL_qsort_inline(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *)) { qsort(base, nmemb, size, compare); }
   1.217 +#define SDL_qsort SDL_qsort_inline
   1.218  #endif
   1.219  
   1.220 -/* We can count on memcpy existing on Mac OS X and being well-tuned. */
   1.221 -#if defined(__MACOSX__)
   1.222 -#define SDL_memcpy4(dst, src, len)	SDL_memcpy((dst), (src), (len) << 2)
   1.223 -#elif defined(__GNUC__) && defined(i386)
   1.224 -#define SDL_memcpy4(dst, src, len)				\
   1.225 -do {								\
   1.226 -	int ecx, edi, esi;					\
   1.227 -	__asm__ __volatile__ (					\
   1.228 -		"cld\n\t"					\
   1.229 -		"rep ; movsl"					\
   1.230 -		: "=&c" (ecx), "=&D" (edi), "=&S" (esi)		\
   1.231 -		: "0" (SDL_static_cast(unsigned, len)), "1" (dst), "2" (src)	\
   1.232 -		: "memory" );					\
   1.233 -} while(0)
   1.234 +extern DECLSPEC int SDLCALL SDL_abs(int x);
   1.235 +#ifdef HAVE_ABS
   1.236 +SDL_FORCE_INLINE int SDL_abs_inline(int x) { return abs(x); }
   1.237 +#else
   1.238 +SDL_FORCE_INLINE int SDL_abs_inline(int x) { return ((x) < 0 ? -(x) : (x)); }
   1.239  #endif
   1.240 -#ifndef SDL_memcpy4
   1.241 -#define SDL_memcpy4(dst, src, len)	SDL_memcpy((dst), (src), (len) << 2)
   1.242 +#define SDL_abs SDL_abs_inline
   1.243 +
   1.244 +/* !!! FIXME: these have side effects. You probably shouldn't use them. */
   1.245 +/* !!! FIXME: Maybe we do forceinline functions of SDL_mini, SDL_minf, etc? */
   1.246 +#define SDL_min(x, y) (((x) < (y)) ? (x) : (y))
   1.247 +#define SDL_max(x, y) (((x) > (y)) ? (x) : (y))
   1.248 +
   1.249 +extern DECLSPEC int SDLCALL SDL_isdigit(int x);
   1.250 +extern DECLSPEC int SDLCALL SDL_isspace(int x);
   1.251 +extern DECLSPEC int SDLCALL SDL_toupper(int x);
   1.252 +extern DECLSPEC int SDLCALL SDL_tolower(int x);
   1.253 +#ifdef HAVE_CTYPE_H
   1.254 +SDL_FORCE_INLINE int SDL_isdigit_inline(int x) { return isdigit(x); }
   1.255 +SDL_FORCE_INLINE int SDL_isspace_inline(int x) { return isspace(x); }
   1.256 +SDL_FORCE_INLINE int SDL_toupper_inline(int x) { return toupper(x); }
   1.257 +SDL_FORCE_INLINE int SDL_tolower_inline(int x) { return tolower(x); }
   1.258 +#else
   1.259 +SDL_FORCE_INLINE int SDL_isdigit_inline(int x) { return ((x) >= '0') && ((x) <= '9'); }
   1.260 +SDL_FORCE_INLINE int SDL_isspace_inline(int x) { return ((x) == ' ') || ((x) == '\t') || ((x) == '\r') || ((x) == '\n'); }
   1.261 +SDL_FORCE_INLINE int SDL_toupper_inline(int x) { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); }
   1.262 +SDL_FORCE_INLINE int SDL_tolower_inline(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); }
   1.263 +#endif
   1.264 +#define SDL_isdigit SDL_isdigit_inline
   1.265 +#define SDL_isspace SDL_isspace_inline
   1.266 +#define SDL_toupper SDL_toupper_inline
   1.267 +#define SDL_tolower SDL_tolower_inline
   1.268 +
   1.269 +extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len);
   1.270 +#ifdef HAVE_MEMSET
   1.271 +SDL_FORCE_INLINE void *SDL_memset_inline(void *dst, int c, size_t len) { return memset(dst, c, len); }
   1.272 +#define SDL_memset SDL_memset_inline
   1.273  #endif
   1.274  
   1.275 -#ifdef HAVE_MEMMOVE
   1.276 -#define SDL_memmove     memmove
   1.277 +#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x)))
   1.278 +#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
   1.279 +
   1.280 +/* !!! FIXME: does this _really_ beat memset() on any modern platform? */
   1.281 +SDL_FORCE_INLINE void SDL_memset4(void *dst, int val, size_t len)
   1.282 +{
   1.283 +#if defined(__GNUC__) && defined(i386)
   1.284 +    int u0, u1, u2;
   1.285 +    __asm__ __volatile__ (
   1.286 +        "cld \n\t"
   1.287 +        "rep ; stosl \n\t"
   1.288 +        : "=&D" (u0), "=&a" (u1), "=&c" (u2)
   1.289 +        : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len))
   1.290 +        : "memory"
   1.291 +    );
   1.292 +/* !!! FIXME: amd64? */
   1.293  #else
   1.294 -extern DECLSPEC void *SDLCALL SDL_memmove(void *dst, const void *src,
   1.295 -                                          size_t len);
   1.296 +    size_t _n = (len + 3) / 4;
   1.297 +    Uint32 *_p = SDL_static_cast(Uint32 *, dst);
   1.298 +    Uint32 _val = (val);
   1.299 +    if (len == 0)
   1.300 +        return;
   1.301 +    switch (len % 4)
   1.302 +    {
   1.303 +        case 0: do {    *_p++ = _val;
   1.304 +        case 3:         *_p++ = _val;
   1.305 +        case 2:         *_p++ = _val;
   1.306 +        case 1:         *_p++ = _val;
   1.307 +        } while ( --_n );
   1.308 +    }
   1.309 +#endif
   1.310 +}
   1.311 +
   1.312 +
   1.313 +extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len);
   1.314 +#if defined(__MACOSX__)
   1.315 +SDL_FORCE_INLINE void *SDL_memcpy_inline(void *dst, const void *src, size_t len)
   1.316 +{
   1.317 +    /* We can count on memcpy existing on Mac OS X and being well-tuned. */
   1.318 +    return memcpy(dst, src, len);
   1.319 +}
   1.320 +#define SDL_memcpy SDL_memcpy_inline
   1.321 +#elif defined(__GNUC__) && defined(i386) && !defined(__WIN32__)
   1.322 +SDL_FORCE_INLINE void *SDL_memcpy_inline(void *dst, const void *src, size_t len)
   1.323 +{
   1.324 +    /* !!! FIXME: does this _really_ beat memcpy() on any modern platform? */
   1.325 +    /* !!! FIXME: shouldn't we just force the inputs to ecx/edi/esi instead of this tapdance with outputs? */
   1.326 +    /* !!! FIXME: amd64? */
   1.327 +    int u0, u1, u2;
   1.328 +    __asm__ __volatile__ (
   1.329 +        "cld \n\t"
   1.330 +        "rep ; movsl \n\t"
   1.331 +        "testb $2,%b4 \n\t"
   1.332 +        "je 1f \n\t"
   1.333 +        "movsw \n"
   1.334 +        "1:\ttestb $1,%b4 \n\t"
   1.335 +        "je 2f \n\t"
   1.336 +        "movsb \n"
   1.337 +        "2:"
   1.338 +        : "=&c" (u0), "=&D" (u1), "=&S" (u2)
   1.339 +        : "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst), "2" (src)
   1.340 +        : "memory"
   1.341 +    );
   1.342 +    return dst;
   1.343 +}
   1.344 +#define SDL_memcpy SDL_memcpy_inline
   1.345 +#elif defined(HAVE_MEMCPY)
   1.346 +SDL_FORCE_INLINE void *SDL_memcpy_inline(void *dst, const void *src, size_t len)
   1.347 +{
   1.348 +    return memcpy(dst, src, len);
   1.349 +}
   1.350 +#define SDL_memcpy SDL_memcpy_inline
   1.351 +#elif defined(HAVE_BCOPY)  /* !!! FIXME: is there _really_ ever a time where you have bcopy and not memcpy? */
   1.352 +SDL_FORCE_INLINE void *SDL_memcpy_inline(void *dst, const void *src, size_t len)
   1.353 +{
   1.354 +    bcopy(src, dst, len);
   1.355 +    return dst;
   1.356 +}
   1.357 +#define SDL_memcpy SDL_memcpy_inline
   1.358  #endif
   1.359  
   1.360 -#ifdef HAVE_MEMCMP
   1.361 -#define SDL_memcmp      memcmp
   1.362 +
   1.363 +SDL_FORCE_INLINE void *SDL_memcpy4(void *dst, const void *src, size_t dwords)
   1.364 +{
   1.365 +#if defined(__GNUC__) && defined(i386)
   1.366 +    /* !!! FIXME: does this _really_ beat memcpy() on any modern platform? */
   1.367 +    /* !!! FIXME: shouldn't we just force the inputs to ecx/edi/esi instead of this tapdance with outputs? */
   1.368 +    int ecx, edi, esi;
   1.369 +    __asm__ __volatile__ (
   1.370 +        "cld \n\t"
   1.371 +        "rep ; movsl \n\t"
   1.372 +        : "=&c" (ecx), "=&D" (edi), "=&S" (esi)
   1.373 +        : "0" (SDL_static_cast(unsigned, dwords)), "1" (dst), "2" (src)
   1.374 +        : "memory"
   1.375 +    );
   1.376 +    return dst;
   1.377  #else
   1.378 -extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2,
   1.379 -                                       size_t len);
   1.380 +    return SDL_memcpy(dst, src, dwords * 4);
   1.381 +#endif
   1.382 +}
   1.383 +
   1.384 +extern DECLSPEC void *SDLCALL SDL_memmove(void *dst, const void *src, size_t len);
   1.385 +#ifdef HAVE_MEMMOVE
   1.386 +SDL_FORCE_INLINE void *SDL_memmove_inline(void *dst, const void *src, size_t len) { return memmove(dst, src, len); }
   1.387 +#define SDL_memmove SDL_memmove_inline
   1.388  #endif
   1.389  
   1.390 -#ifdef HAVE_STRLEN
   1.391 -#define SDL_strlen      strlen
   1.392 -#else
   1.393 -extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
   1.394 +extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
   1.395 +#ifdef HAVE_MEMCMP
   1.396 +SDL_FORCE_INLINE int SDL_memcmp_inline(const void *s1, const void *s2, size_t len) { return memcmp(s1, s2, len); }
   1.397 +#define SDL_memcmp SDL_memcmp_inline
   1.398  #endif
   1.399  
   1.400 -#ifdef HAVE_WCSLEN
   1.401 -#define SDL_wcslen      wcslen
   1.402 -#else
   1.403 -#if !defined(wchar_t) && defined(__NINTENDODS__)
   1.404 -#define wchar_t short           /* TODO: figure out why libnds doesn't have this */
   1.405 -#endif
   1.406 -extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t * string);
   1.407 +extern DECLSPEC size_t SDLCALL SDL_strlen(const char *str);
   1.408 +#ifdef HAVE_STRLEN
   1.409 +SDL_FORCE_INLINE size_t SDL_strlen_inline(const char *str) { return strlen(str); }
   1.410 +#define SDL_strlen SDL_strlen_inline
   1.411  #endif
   1.412  
   1.413 -#ifdef HAVE_WCSLCPY
   1.414 -#define SDL_wcslcpy      wcslcpy
   1.415 -#else
   1.416 -extern DECLSPEC size_t SDLCALL SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen);
   1.417 +extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr);
   1.418 +#ifdef HAVE_WCSLEN
   1.419 +SDL_FORCE_INLINE size_t SDL_wcslen_inline(const wchar_t *wstr) { return wcslen(wstr); }
   1.420 +#define SDL_wcslen SDL_wcslen_inline
   1.421  #endif
   1.422  
   1.423 -#ifdef HAVE_WCSLCAT
   1.424 -#define SDL_wcslcat      wcslcat
   1.425 -#else
   1.426 -extern DECLSPEC size_t SDLCALL SDL_wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen);
   1.427 +extern DECLSPEC size_t SDLCALL SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen);
   1.428 +#ifdef HAVE_WCSLCPY
   1.429 +SDL_FORCE_INLINE size_t SDL_wcslcpy_inline(wchar_t *dst, const wchar_t *src, size_t maxlen) { return wcslcpy(dst, src, maxlen); }
   1.430 +#define SDL_wcslcpy SDL_wcslcpy_inline
   1.431  #endif
   1.432  
   1.433 -
   1.434 -#ifdef HAVE_STRLCPY
   1.435 -#define SDL_strlcpy     strlcpy
   1.436 -#else
   1.437 -extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src,
   1.438 -                                           size_t maxlen);
   1.439 +extern DECLSPEC size_t SDLCALL SDL_wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen);
   1.440 +#ifdef HAVE_WCSLCAT
   1.441 +SDL_FORCE_INLINE size_t SDL_wcslcat_inline(wchar_t *dst, const wchar_t *src, size_t maxlen) { return wcslcat(dst, src, maxlen); }
   1.442 +#define SDL_wcslcat SDL_wcslcat_inline
   1.443  #endif
   1.444  
   1.445 -extern DECLSPEC size_t SDLCALL SDL_utf8strlcpy(char *dst, const char *src,
   1.446 -                                            size_t dst_bytes);
   1.447 -
   1.448 -#ifdef HAVE_STRLCAT
   1.449 -#define SDL_strlcat    strlcat
   1.450 +extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen);
   1.451 +#ifdef HAVE_STRLCPY
   1.452 +SDL_FORCE_INLINE size_t SDL_strlcpy_inline(char *dst, const char *src, size_t maxlen) { return strlcpy(dst, src, maxlen); }
   1.453 +#define SDL_strlcpy SDL_strlcpy_inline
   1.454  #else
   1.455 -extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src,
   1.456 -                                           size_t maxlen);
   1.457  #endif
   1.458  
   1.459 -#ifdef HAVE_STRDUP
   1.460 -#define SDL_strdup     strdup
   1.461 -#else
   1.462 -extern DECLSPEC char *SDLCALL SDL_strdup(const char *string);
   1.463 +extern DECLSPEC size_t SDLCALL SDL_utf8strlcpy(char *dst, const char *src, size_t dst_bytes);
   1.464 +
   1.465 +extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen);
   1.466 +#ifdef HAVE_STRLCAT
   1.467 +SDL_FORCE_INLINE size_t SDL_strlcat_inline(char *dst, const char *src, size_t maxlen) { return strlcat(dst, src, maxlen); }
   1.468 +#define SDL_strlcat SDL_strlcat_inline
   1.469  #endif
   1.470  
   1.471 -#ifdef HAVE__STRREV
   1.472 -#define SDL_strrev      _strrev
   1.473 -#else
   1.474 -extern DECLSPEC char *SDLCALL SDL_strrev(char *string);
   1.475 +extern DECLSPEC char *SDLCALL SDL_strdup(const char *str);
   1.476 +#ifdef HAVE_STRDUP
   1.477 +SDL_FORCE_INLINE char *SDL_strdup_inline(const char *str) { return strdup(str); }
   1.478 +#define SDL_strdup SDL_strdup_inline
   1.479  #endif
   1.480  
   1.481 -#ifdef HAVE__STRUPR
   1.482 -#define SDL_strupr      _strupr
   1.483 -#else
   1.484 -extern DECLSPEC char *SDLCALL SDL_strupr(char *string);
   1.485 +extern DECLSPEC char *SDLCALL SDL_strrev(char *str);
   1.486 +#ifdef HAVE__STRREV
   1.487 +SDL_FORCE_INLINE char *SDL_strrev_inline(char *str) { return _strrev(str); }
   1.488 +#define SDL_strrev SDL_strrev_inline
   1.489  #endif
   1.490  
   1.491 -#ifdef HAVE__STRLWR
   1.492 -#define SDL_strlwr      _strlwr
   1.493 -#else
   1.494 -extern DECLSPEC char *SDLCALL SDL_strlwr(char *string);
   1.495 +extern DECLSPEC char *SDLCALL SDL_strupr(char *str);
   1.496 +#ifdef HAVE__STRUPR
   1.497 +SDL_FORCE_INLINE char *SDL_strupr_inline(char *str) { return _strupr(str); }
   1.498 +#define SDL_strupr SDL_strupr_inline
   1.499  #endif
   1.500  
   1.501 -#ifdef HAVE_STRCHR
   1.502 -#define SDL_strchr      strchr
   1.503 -#elif defined(HAVE_INDEX)
   1.504 -#define SDL_strchr      index
   1.505 -#else
   1.506 -extern DECLSPEC char *SDLCALL SDL_strchr(const char *string, int c);
   1.507 +extern DECLSPEC char *SDLCALL SDL_strlwr(char *str);
   1.508 +#ifdef HAVE__STRLWR
   1.509 +SDL_FORCE_INLINE char *SDL_strlwr_inline(char *str) { return _strlwr(str); }
   1.510 +#define SDL_strlwr SDL_strlwr_inline
   1.511  #endif
   1.512  
   1.513 -#ifdef HAVE_STRRCHR
   1.514 -#define SDL_strrchr     strrchr
   1.515 -#elif defined(HAVE_RINDEX)
   1.516 -#define SDL_strrchr     rindex
   1.517 +extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c);
   1.518 +#ifdef HAVE_STRCHR
   1.519 +SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) {
   1.520 +#ifdef __cplusplus
   1.521 +return const_cast<char*>(strchr(str, c));
   1.522  #else
   1.523 -extern DECLSPEC char *SDLCALL SDL_strrchr(const char *string, int c);
   1.524 +return (char*)strchr(str, c);
   1.525 +#endif
   1.526 +}
   1.527 +#define SDL_strchr SDL_strchr_inline
   1.528 +#elif defined(HAVE_INDEX)  /* !!! FIXME: is there anywhere that has this but not strchr? */
   1.529 +SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return index(str, c); }
   1.530 +#define SDL_strchr SDL_strchr_inline
   1.531  #endif
   1.532  
   1.533 -#ifdef HAVE_STRSTR
   1.534 -#define SDL_strstr      strstr
   1.535 +extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
   1.536 +#ifdef HAVE_STRRCHR
   1.537 +SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
   1.538 +#ifdef __cplusplus
   1.539 +return const_cast<char*>(strrchr(str, c));
   1.540  #else
   1.541 -extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack,
   1.542 -                                         const char *needle);
   1.543 +return (char*)strrchr(str, c);
   1.544 +#endif
   1.545 +}
   1.546 +#define SDL_strrchr SDL_strrchr_inline
   1.547 +#elif defined(HAVE_RINDEX)  /* !!! FIXME: is there anywhere that has this but not strrchr? */
   1.548 +SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
   1.549 +#ifdef __cplusplus
   1.550 +return const_cast<char*>(rindex(str, c));
   1.551 +#else
   1.552 +return (char*)rindex(str, c);
   1.553 +#endif
   1.554 +}
   1.555 +#define SDL_strrchr SDL_strrchr_inline
   1.556  #endif
   1.557  
   1.558 -#ifdef HAVE_ITOA
   1.559 -#define SDL_itoa        itoa
   1.560 +extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
   1.561 +#ifdef HAVE_STRSTR
   1.562 +SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) {
   1.563 +#ifdef __cplusplus
   1.564 +return const_cast<char*>(strstr(haystack, needle));
   1.565  #else
   1.566 -#define SDL_itoa(value, string, radix)	SDL_ltoa((long)value, string, radix)
   1.567 +return (char*)strstr(haystack, needle);
   1.568 +#endif
   1.569 +}
   1.570 +#define SDL_strstr SDL_strstr_inline
   1.571  #endif
   1.572  
   1.573 +extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *str, int radix);
   1.574  #ifdef HAVE__LTOA
   1.575 -#define SDL_ltoa        _ltoa
   1.576 -#else
   1.577 -extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *string, int radix);
   1.578 +SDL_FORCE_INLINE char *SDL_ltoa_inline(long value, char *str, int radix) { return _ltoa(value, str, radix); }
   1.579 +#define SDL_ltoa SDL_ltoa_inline
   1.580  #endif
   1.581  
   1.582 -#ifdef HAVE__UITOA
   1.583 -#define SDL_uitoa       _uitoa
   1.584 +extern DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix);
   1.585 +#ifdef HAVE_ITOA
   1.586 +SDL_FORCE_INLINE char *SDL_itoa_inline(int value, char *str, int radix) { return itoa(value, str, radix); }
   1.587  #else
   1.588 -#define SDL_uitoa(value, string, radix)	SDL_ultoa((long)value, string, radix)
   1.589 +SDL_FORCE_INLINE char *SDL_itoa_inline(int value, char *str, int radix) { return SDL_ltoa((long)value, str, radix); }
   1.590 +#endif
   1.591 +#define SDL_itoa SDL_itoa_inline
   1.592 +
   1.593 +extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *str, int radix);
   1.594 +#ifdef HAVE__ULTOA
   1.595 +SDL_FORCE_INLINE char *SDL_ultoa_inline(unsigned long value, char *str, int radix) { return _ultoa(value, str, radix); }
   1.596 +#define SDL_ultoa SDL_ultoa_inline
   1.597  #endif
   1.598  
   1.599 -#ifdef HAVE__ULTOA
   1.600 -#define SDL_ultoa       _ultoa
   1.601 +extern DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix);
   1.602 +#ifdef HAVE__UITOA
   1.603 +SDL_FORCE_INLINE char *SDL_uitoa_inline(unsigned int value, char *str, int radix) { return _uitoa(value, str, radix); }
   1.604  #else
   1.605 -extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *string,
   1.606 -                                        int radix);
   1.607 +SDL_FORCE_INLINE char *SDL_uitoa_inline(unsigned int value, char *str, int radix) { return SDL_ultoa((unsigned long)value, str, radix); }
   1.608 +#endif
   1.609 +#define SDL_uitoa SDL_uitoa_inline
   1.610 +
   1.611 +
   1.612 +extern DECLSPEC long SDLCALL SDL_strtol(const char *str, char **endp, int base);
   1.613 +#ifdef HAVE_STRTOL
   1.614 +SDL_FORCE_INLINE long SDL_strtol_inline(const char *str, char **endp, int base) { return strtol(str, endp, base); }
   1.615 +#define SDL_strtol SDL_strtol_inline
   1.616  #endif
   1.617  
   1.618 -#ifdef HAVE_STRTOL
   1.619 -#define SDL_strtol      strtol
   1.620 -#else
   1.621 -extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp,
   1.622 -                                        int base);
   1.623 +extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *str, char **endp, int base);
   1.624 +#ifdef HAVE_STRTOUL
   1.625 +SDL_FORCE_INLINE unsigned long SDLCALL SDL_strtoul_inline(const char *str, char **endp, int base) { return strtoul(str, endp, base); }
   1.626 +#define SDL_strtoul SDL_strtoul_inline
   1.627  #endif
   1.628  
   1.629 -#ifdef HAVE_STRTOUL
   1.630 -#define SDL_strtoul      strtoul
   1.631 -#else
   1.632 -extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string,
   1.633 -                                                  char **endp, int base);
   1.634 +extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *str, int radix);
   1.635 +#ifdef HAVE__I64TOA
   1.636 +SDL_FORCE_INLINE char *SDL_lltoa_inline(Sint64 value, char *str, int radix) { return _i64toa(value, str, radix); }
   1.637 +#define SDL_lltoa SDL_lltoa_inline
   1.638  #endif
   1.639  
   1.640 -#ifdef HAVE__I64TOA
   1.641 -#define SDL_lltoa       _i64toa
   1.642 -#else
   1.643 -extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *string,
   1.644 -                                        int radix);
   1.645 +extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *str, int radix);
   1.646 +#ifdef HAVE__UI64TOA
   1.647 +SDL_FORCE_INLINE char *SDL_ulltoa_inline(Uint64 value, char *str, int radix) { return _ui64toa(value, str, radix); }
   1.648 +#define SDL_ulltoa SDL_ulltoa_inline
   1.649  #endif
   1.650  
   1.651 -#ifdef HAVE__UI64TOA
   1.652 -#define SDL_ulltoa      _ui64toa
   1.653 -#else
   1.654 -extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *string,
   1.655 -                                         int radix);
   1.656 +extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *str, char **endp, int base);
   1.657 +#ifdef HAVE_STRTOLL
   1.658 +SDL_FORCE_INLINE Sint64 SDL_strtoll_inline(const char *str, char **endp, int base) { return strtoll(str, endp, base); }
   1.659 +#define SDL_strtoll SDL_strtoll_inline
   1.660  #endif
   1.661  
   1.662 -#ifdef HAVE_STRTOLL
   1.663 -#define SDL_strtoll     strtoll
   1.664 -#else
   1.665 -extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp,
   1.666 -                                           int base);
   1.667 +extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *str, char **endp, int base);
   1.668 +#ifdef HAVE_STRTOULL
   1.669 +SDL_FORCE_INLINE Uint64 SDL_strtoull_inline(const char *str, char **endp, int base) { return strtoull(str, endp, base); }
   1.670 +#define SDL_strtoull SDL_strtoull_inline
   1.671  #endif
   1.672  
   1.673 -#ifdef HAVE_STRTOULL
   1.674 -#define SDL_strtoull     strtoull
   1.675 -#else
   1.676 -extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp,
   1.677 -                                            int base);
   1.678 +extern DECLSPEC double SDLCALL SDL_strtod(const char *str, char **endp);
   1.679 +#ifdef HAVE_STRTOD
   1.680 +SDL_FORCE_INLINE double SDL_strtod_inline(const char *str, char **endp) { return strtod(str, endp); }
   1.681 +#define SDL_strtod SDL_strtod_inline
   1.682  #endif
   1.683  
   1.684 -#ifdef HAVE_STRTOD
   1.685 -#define SDL_strtod      strtod
   1.686 +extern DECLSPEC int SDLCALL SDL_atoi(const char *str);
   1.687 +#ifdef HAVE_ATOI
   1.688 +SDL_FORCE_INLINE int SDL_atoi_inline(const char *str) { return atoi(str); }
   1.689  #else
   1.690 -extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp);
   1.691 +SDL_FORCE_INLINE int SDL_atoi_inline(const char *str) { return SDL_strtol(str, NULL, 0); }
   1.692 +#endif
   1.693 +#define SDL_atoi SDL_atoi_inline
   1.694 +
   1.695 +extern DECLSPEC double SDLCALL SDL_atof(const char *str);
   1.696 +#ifdef HAVE_ATOF
   1.697 +SDL_FORCE_INLINE double SDL_atof_inline(const char *str) { return (double) atof(str); }
   1.698 +#else
   1.699 +SDL_FORCE_INLINE double SDL_atof_inline(const char *str) { return SDL_strtod(str, NULL); }
   1.700 +#endif
   1.701 +#define SDL_atof SDL_atof_inline
   1.702 +
   1.703 +
   1.704 +extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
   1.705 +#ifdef HAVE_STRCMP
   1.706 +SDL_FORCE_INLINE int SDL_strcmp_inline(const char *str1, const char *str2) { return strcmp(str1, str2); }
   1.707 +#define SDL_strcmp SDL_strcmp_inline
   1.708  #endif
   1.709  
   1.710 -#ifdef HAVE_ATOI
   1.711 -#define SDL_atoi        atoi
   1.712 -#else
   1.713 -#define SDL_atoi(X)     SDL_strtol(X, NULL, 0)
   1.714 +extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen);
   1.715 +#ifdef HAVE_STRNCMP
   1.716 +SDL_FORCE_INLINE int SDL_strncmp_inline(const char *str1, const char *str2, size_t maxlen) { return strncmp(str1, str2, maxlen); }
   1.717 +#define SDL_strncmp SDL_strncmp_inline
   1.718  #endif
   1.719  
   1.720 -#ifdef HAVE_ATOF
   1.721 -#define SDL_atof        atof
   1.722 -#else
   1.723 -#define SDL_atof(X)     SDL_strtod(X, NULL)
   1.724 +extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
   1.725 +#ifdef HAVE_STRCASECMP
   1.726 +SDL_FORCE_INLINE int SDL_strcasecmp_inline(const char *str1, const char *str2) { return strcasecmp(str1, str2); }
   1.727 +#define SDL_strcasecmp SDL_strcasecmp_inline
   1.728 +#elif defined(HAVE__STRICMP)
   1.729 +SDL_FORCE_INLINE int SDL_strcasecmp_inline(const char *str1, const char *str2) { return _stricmp(str1, str2); }
   1.730 +#define SDL_strcasecmp SDL_strcasecmp_inline
   1.731  #endif
   1.732  
   1.733 -#ifdef HAVE_STRCMP
   1.734 -#define SDL_strcmp      strcmp
   1.735 -#else
   1.736 -extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
   1.737 +extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t len);
   1.738 +#ifdef HAVE_STRNCASECMP
   1.739 +SDL_FORCE_INLINE int SDL_strncasecmp_inline(const char *str1, const char *str2, size_t len) { return strncasecmp(str1, str2, len); }
   1.740 +#define SDL_strncasecmp SDL_strncasecmp_inline
   1.741 +#elif defined(HAVE__STRNICMP)
   1.742 +SDL_FORCE_INLINE int SDL_strncasecmp_inline(const char *str1, const char *str2, size_t len) { return _strnicmp(str1, str2, len); }
   1.743 +#define SDL_strncasecmp SDL_strncasecmp_inline
   1.744  #endif
   1.745  
   1.746 -#ifdef HAVE_STRNCMP
   1.747 -#define SDL_strncmp     strncmp
   1.748 -#else
   1.749 -extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2,
   1.750 -                                        size_t maxlen);
   1.751 +/* Not doing SDL_*_inline functions for these, because of the varargs. */
   1.752 +extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...);
   1.753 +#ifdef HAVE_SSCANF
   1.754 +#define SDL_sscanf sscanf
   1.755  #endif
   1.756  
   1.757 -#ifdef HAVE_STRCASECMP
   1.758 -#define SDL_strcasecmp  strcasecmp
   1.759 -#elif defined(HAVE__STRICMP)
   1.760 -#define SDL_strcasecmp  _stricmp
   1.761 -#else
   1.762 -extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1,
   1.763 -                                           const char *str2);
   1.764 +extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...);
   1.765 +#ifdef HAVE_SNPRINTF
   1.766 +#define SDL_snprintf snprintf
   1.767  #endif
   1.768  
   1.769 -#ifdef HAVE_STRNCASECMP
   1.770 -#define SDL_strncasecmp strncasecmp
   1.771 -#elif defined(HAVE__STRNICMP)
   1.772 -#define SDL_strncasecmp _strnicmp
   1.773 -#else
   1.774 -extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1,
   1.775 -                                            const char *str2, size_t maxlen);
   1.776 -#endif
   1.777 -
   1.778 -#ifdef HAVE_SSCANF
   1.779 -#define SDL_sscanf      sscanf
   1.780 -#else
   1.781 -extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt,
   1.782 -                                       ...);
   1.783 -#endif
   1.784 -
   1.785 -#ifdef HAVE_SNPRINTF
   1.786 -#define SDL_snprintf    snprintf
   1.787 -#else
   1.788 -extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen,
   1.789 -                                         const char *fmt, ...);
   1.790 -#endif
   1.791 -
   1.792 +extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
   1.793  #ifdef HAVE_VSNPRINTF
   1.794 -#define SDL_vsnprintf   vsnprintf
   1.795 -#else
   1.796 -extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen,
   1.797 -                                          const char *fmt, va_list ap);
   1.798 +SDL_FORCE_INLINE int SDL_vsnprintf_inline(char *text, size_t maxlen, const char *fmt, va_list ap) { return vsnprintf(text, maxlen, fmt, ap); }
   1.799 +#define SDL_vsnprintf SDL_vsnprintf_inline
   1.800  #endif
   1.801  
   1.802  #ifndef HAVE_M_PI
   1.803 @@ -645,88 +696,94 @@
   1.804  #endif
   1.805  #endif
   1.806  
   1.807 +extern DECLSPEC double SDLCALL SDL_atan(double x);
   1.808  #ifdef HAVE_ATAN
   1.809 -#define SDL_atan        atan
   1.810 -#else
   1.811 -extern DECLSPEC double SDLCALL SDL_atan(double x);
   1.812 +SDL_FORCE_INLINE double SDL_atan_inline(double x) { return atan(x); }
   1.813 +#define SDL_atan SDL_atan_inline
   1.814  #endif
   1.815  
   1.816 +extern DECLSPEC double SDLCALL SDL_atan2(double x, double y);
   1.817  #ifdef HAVE_ATAN2
   1.818 -#define SDL_atan2       atan2
   1.819 -#else
   1.820 -extern DECLSPEC double SDLCALL SDL_atan2(double y, double x);
   1.821 +SDL_FORCE_INLINE double SDL_atan2_inline(double x, double y) { return atan2(x, y); }
   1.822 +#define SDL_atan2 SDL_atan2_inline
   1.823  #endif
   1.824  
   1.825 +extern DECLSPEC double SDLCALL SDL_ceil(double x);
   1.826  #ifdef HAVE_CEIL
   1.827 -#define SDL_ceil        ceil
   1.828 +SDL_FORCE_INLINE double SDL_ceil_inline(double x) { return ceil(x); }
   1.829  #else
   1.830 -#define SDL_ceil(x)     ((double)(int)((x)+0.5))
   1.831 +SDL_FORCE_INLINE double SDL_ceil_inline(double x) { return (double)(int)((x)+0.5); }
   1.832 +#endif
   1.833 +#define SDL_ceil SDL_ceil_inline
   1.834 +
   1.835 +extern DECLSPEC double SDLCALL SDL_copysign(double x, double y);
   1.836 +#ifdef HAVE_COPYSIGN
   1.837 +SDL_FORCE_INLINE double SDL_copysign_inline(double x, double y) { return copysign(x, y); }
   1.838 +#define SDL_copysign SDL_copysign_inline
   1.839  #endif
   1.840  
   1.841 -#ifdef HAVE_COPYSIGN
   1.842 -#define SDL_copysign    copysign
   1.843 -#else
   1.844 -extern DECLSPEC double SDLCALL SDL_copysign(double x, double y);
   1.845 +extern DECLSPEC double SDLCALL SDL_cos(double x);
   1.846 +#ifdef HAVE_COS
   1.847 +SDL_FORCE_INLINE double SDL_cos_inline(double x) { return cos(x); }
   1.848 +#define SDL_cos SDL_cos_inline
   1.849  #endif
   1.850  
   1.851 -#ifdef HAVE_COS
   1.852 -#define SDL_cos         cos
   1.853 +extern DECLSPEC float SDLCALL SDL_cosf(float x);
   1.854 +#ifdef HAVE_COSF
   1.855 +SDL_FORCE_INLINE float SDL_cosf_inline(float x) { return cosf(x); }
   1.856  #else
   1.857 -extern DECLSPEC double SDLCALL SDL_cos(double x);
   1.858 +SDL_FORCE_INLINE float SDL_cosf_inline(float x) { return (float)SDL_cos((double)x); }
   1.859 +#endif
   1.860 +#define SDL_cosf SDL_cosf_inline
   1.861 +
   1.862 +extern DECLSPEC double SDLCALL SDL_fabs(double x);
   1.863 +#ifdef HAVE_FABS
   1.864 +SDL_FORCE_INLINE double SDL_fabs_inline(double x) { return fabs(x); }
   1.865 +#define SDL_fabs SDL_fabs_inline
   1.866  #endif
   1.867  
   1.868 -#ifdef HAVE_COSF
   1.869 -#define SDL_cosf        cosf
   1.870 -#else
   1.871 -#define SDL_cosf(x) (float)SDL_cos((double)x)
   1.872 +extern DECLSPEC double SDLCALL SDL_floor(double x);
   1.873 +#ifdef HAVE_FLOOR
   1.874 +SDL_FORCE_INLINE double SDL_floor_inline(double x) { return floor(x); }
   1.875 +#define SDL_floor SDL_floor_inline
   1.876  #endif
   1.877  
   1.878 -#ifdef HAVE_FABS
   1.879 -#define SDL_fabs        fabs
   1.880 -#else
   1.881 -extern DECLSPEC double SDLCALL SDL_fabs(double x);
   1.882 +extern DECLSPEC double SDLCALL SDL_log(double x);
   1.883 +#ifdef HAVE_LOG
   1.884 +SDL_FORCE_INLINE double SDL_log_inline(double x) { return log(x); }
   1.885 +#define SDL_log SDL_log_inline
   1.886  #endif
   1.887  
   1.888 -#ifdef HAVE_FLOOR
   1.889 -#define SDL_floor       floor
   1.890 -#else
   1.891 -extern DECLSPEC double SDLCALL SDL_floor(double x);
   1.892 +extern DECLSPEC double SDLCALL SDL_pow(double x, double y);
   1.893 +#ifdef HAVE_POW
   1.894 +SDL_FORCE_INLINE double SDL_pow_inline(double x, double y) { return pow(x, y); }
   1.895 +#define SDL_pow SDL_pow_inline
   1.896  #endif
   1.897  
   1.898 -#ifdef HAVE_LOG
   1.899 -#define SDL_log         log
   1.900 -#else
   1.901 -extern DECLSPEC double SDLCALL SDL_log(double x);
   1.902 +extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n);
   1.903 +#ifdef HAVE_SCALBN
   1.904 +SDL_FORCE_INLINE double SDL_scalbn_inline(double x, int n) { return scalbn(x, n); }
   1.905 +#define SDL_scalbn SDL_scalbn_inline
   1.906  #endif
   1.907  
   1.908 -#ifdef HAVE_POW
   1.909 -#define SDL_pow         pow
   1.910 -#else
   1.911 -extern DECLSPEC double SDLCALL SDL_pow(double x, double y);
   1.912 +extern DECLSPEC double SDLCALL SDL_sin(double x);
   1.913 +#ifdef HAVE_SIN
   1.914 +SDL_FORCE_INLINE double SDL_sin_inline(double x) { return sin(x); }
   1.915 +#define SDL_sin SDL_sin_inline
   1.916  #endif
   1.917  
   1.918 -#ifdef HAVE_SCALBN
   1.919 -#define SDL_scalbn      scalbn
   1.920 +extern DECLSPEC float SDLCALL SDL_sinf(float x);
   1.921 +#ifdef HAVE_SINF
   1.922 +SDL_FORCE_INLINE float SDL_sinf_inline(float x) { return sinf(x); }
   1.923  #else
   1.924 -extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n);
   1.925 +SDL_FORCE_INLINE float SDL_sinf_inline(float x) { return (float)SDL_sin((double)x); }
   1.926  #endif
   1.927 +#define SDL_sinf SDL_sinf_inline
   1.928  
   1.929 -#ifdef HAVE_SIN
   1.930 -#define SDL_sin         sin
   1.931 -#else
   1.932 -extern DECLSPEC double SDLCALL SDL_sin(double x);
   1.933 -#endif
   1.934 -
   1.935 -#ifdef HAVE_SINF
   1.936 -#define SDL_sinf        sinf
   1.937 -#else
   1.938 -#define SDL_sinf(x) (float)SDL_sin((double)x)
   1.939 -#endif
   1.940 -
   1.941 +extern DECLSPEC double SDLCALL SDL_sqrt(double x);
   1.942  #ifdef HAVE_SQRT
   1.943 -#define SDL_sqrt        sqrt
   1.944 -#else
   1.945 -extern DECLSPEC double SDLCALL SDL_sqrt(double x);
   1.946 +SDL_FORCE_INLINE double SDL_sqrt_inline(double x) { return sqrt(x); }
   1.947 +#define SDL_sqrt SDL_sqrt_inline
   1.948  #endif
   1.949  
   1.950  /* The SDL implementation of iconv() returns these error codes */
   1.951 @@ -735,16 +792,11 @@
   1.952  #define SDL_ICONV_EILSEQ	(size_t)-3
   1.953  #define SDL_ICONV_EINVAL	(size_t)-4
   1.954  
   1.955 -#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
   1.956 -#define SDL_iconv_t     iconv_t
   1.957 -#define SDL_iconv_open  iconv_open
   1.958 -#define SDL_iconv_close iconv_close
   1.959 -#else
   1.960 +/* SDL_iconv_* are now always real symbols/types, not macros or inlined. */
   1.961  typedef struct _SDL_iconv_t *SDL_iconv_t;
   1.962  extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode,
   1.963                                                     const char *fromcode);
   1.964  extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
   1.965 -#endif
   1.966  extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
   1.967                                           size_t * inbytesleft, char **outbuf,
   1.968                                           size_t * outbytesleft);