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