include/SDL_stdinc.h
changeset 4755 436183eb30c8
parent 4754 2072fed2f583
parent 4492 bff93336121e
child 4758 e2f4e31b41fc
     1.1 --- a/include/SDL_stdinc.h	Tue Jul 13 15:05:45 2010 -0400
     1.2 +++ b/include/SDL_stdinc.h	Sun Jul 18 13:48:23 2010 -0400
     1.3 @@ -1,788 +1,795 @@
     1.4 -/*
     1.5 -    SDL - Simple DirectMedia Layer
     1.6 -    Copyright (C) 1997-2010 Sam Lantinga
     1.7 -
     1.8 -    This library is free software; you can redistribute it and/or
     1.9 -    modify it under the terms of the GNU Lesser General Public
    1.10 -    License as published by the Free Software Foundation; either
    1.11 -    version 2.1 of the License, or (at your option) any later version.
    1.12 -
    1.13 -    This library is distributed in the hope that it will be useful,
    1.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 -    Lesser General Public License for more details.
    1.17 -
    1.18 -    You should have received a copy of the GNU Lesser General Public
    1.19 -    License along with this library; if not, write to the Free Software
    1.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1.21 -
    1.22 -    Sam Lantinga
    1.23 -    slouken@libsdl.org
    1.24 -*/
    1.25 -
    1.26 -/**
    1.27 - *  \file SDL_stdinc.h
    1.28 - *  
    1.29 - *  This is a general header that includes C language support.
    1.30 - */
    1.31 -
    1.32 -#ifndef _SDL_stdinc_h
    1.33 -#define _SDL_stdinc_h
    1.34 -
    1.35 -#include "SDL_config.h"
    1.36 -
    1.37 -
    1.38 -#ifdef HAVE_SYS_TYPES_H
    1.39 -#include <sys/types.h>
    1.40 -#endif
    1.41 -#ifdef HAVE_STDIO_H
    1.42 -#include <stdio.h>
    1.43 -#endif
    1.44 -#if defined(STDC_HEADERS)
    1.45 -# include <stdlib.h>
    1.46 -# include <stddef.h>
    1.47 -# include <stdarg.h>
    1.48 -#else
    1.49 -# if defined(HAVE_STDLIB_H)
    1.50 -#  include <stdlib.h>
    1.51 -# elif defined(HAVE_MALLOC_H)
    1.52 -#  include <malloc.h>
    1.53 -# endif
    1.54 -# if defined(HAVE_STDDEF_H)
    1.55 -#  include <stddef.h>
    1.56 -# endif
    1.57 -# if defined(HAVE_STDARG_H)
    1.58 -#  include <stdarg.h>
    1.59 -# endif
    1.60 -#endif
    1.61 -#ifdef HAVE_STRING_H
    1.62 -# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
    1.63 -#  include <memory.h>
    1.64 -# endif
    1.65 -# include <string.h>
    1.66 -#endif
    1.67 -#ifdef HAVE_STRINGS_H
    1.68 -# include <strings.h>
    1.69 -#endif
    1.70 -#if defined(HAVE_INTTYPES_H)
    1.71 -# include <inttypes.h>
    1.72 -#elif defined(HAVE_STDINT_H)
    1.73 -# include <stdint.h>
    1.74 -#endif
    1.75 -#ifdef HAVE_CTYPE_H
    1.76 -# include <ctype.h>
    1.77 -#endif
    1.78 -#ifdef HAVE_MATH_H
    1.79 -# include <math.h>
    1.80 -#endif
    1.81 -#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
    1.82 -# include <iconv.h>
    1.83 -#endif
    1.84 -
    1.85 -/**
    1.86 - *  The number of elements in an array.
    1.87 - */
    1.88 -#define SDL_arraysize(array)	(sizeof(array)/sizeof(array[0]))
    1.89 -#define SDL_TABLESIZE(table)	SDL_arraysize(table)
    1.90 -
    1.91 -/**
    1.92 - *  \name Cast operators
    1.93 - *  
    1.94 - *  Use proper C++ casts when compiled as C++ to be compatible with the option
    1.95 - *  -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above).
    1.96 - */
    1.97 -/*@{*/
    1.98 -#ifdef __cplusplus
    1.99 -#define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
   1.100 -#define SDL_static_cast(type, expression) static_cast<type>(expression)
   1.101 -#else
   1.102 -#define SDL_reinterpret_cast(type, expression) ((type)(expression))
   1.103 -#define SDL_static_cast(type, expression) ((type)(expression))
   1.104 -#endif
   1.105 -/*@}*//*Cast operators*/
   1.106 -
   1.107 -/**
   1.108 - *  \name Basic data types
   1.109 - */
   1.110 -/*@{*/
   1.111 -
   1.112 -typedef enum
   1.113 -{
   1.114 -    SDL_FALSE = 0,
   1.115 -    SDL_TRUE = 1
   1.116 -} SDL_bool;
   1.117 -
   1.118 -/**
   1.119 - * \brief A signed 8-bit integer type.
   1.120 - */
   1.121 -typedef int8_t Sint8;
   1.122 -/**
   1.123 - * \brief An unsigned 8-bit integer type.
   1.124 - */
   1.125 -typedef uint8_t Uint8;
   1.126 -/**
   1.127 - * \brief A signed 16-bit integer type.
   1.128 - */
   1.129 -typedef int16_t Sint16;
   1.130 -/**
   1.131 - * \brief An unsigned 16-bit integer type.
   1.132 - */
   1.133 -typedef uint16_t Uint16;
   1.134 -/**
   1.135 - * \brief A signed 32-bit integer type.
   1.136 - */
   1.137 -typedef int32_t Sint32;
   1.138 -/**
   1.139 - * \brief An unsigned 32-bit integer type.
   1.140 - */
   1.141 -typedef uint32_t Uint32;
   1.142 -
   1.143 -#ifdef SDL_HAS_64BIT_TYPE
   1.144 -/**
   1.145 - * \brief A signed 64-bit integer type.
   1.146 - * \warning On platforms without any sort of 64-bit datatype, this is equivalent to Sint32!
   1.147 - */
   1.148 -typedef int64_t Sint64;
   1.149 -/**
   1.150 - * \brief An unsigned 64-bit integer type.
   1.151 - * \warning On platforms without any sort of 64-bit datatype, this is equivalent to Uint32!
   1.152 - */
   1.153 -typedef uint64_t Uint64;
   1.154 -#else
   1.155 -/* This is really just a hack to prevent the compiler from complaining */
   1.156 -typedef Sint32 Sint64;
   1.157 -typedef Uint32 Uint64;
   1.158 -#endif
   1.159 -
   1.160 -/*@}*//*Basic data types*/
   1.161 -
   1.162 -
   1.163 -#define SDL_COMPILE_TIME_ASSERT(name, x)               \
   1.164 -       typedef int SDL_dummy_ ## name[(x) * 2 - 1]
   1.165 -/** \cond */
   1.166 -#ifndef DOXYGEN_SHOULD_IGNORE_THIS
   1.167 -SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
   1.168 -SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
   1.169 -SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
   1.170 -SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
   1.171 -SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
   1.172 -SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
   1.173 -#ifndef __NINTENDODS__          /* TODO: figure out why the following happens:
   1.174 -                                   include/SDL_stdinc.h:150: error: size of array 'SDL_dummy_uint64' is negative
   1.175 -                                   include/SDL_stdinc.h:151: error: size of array 'SDL_dummy_sint64' is negative */
   1.176 -SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
   1.177 -SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
   1.178 -#endif
   1.179 -#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
   1.180 -/** \endcond */
   1.181 -
   1.182 -/* Check to make sure enums are the size of ints, for structure packing.
   1.183 -   For both Watcom C/C++ and Borland C/C++ the compiler option that makes
   1.184 -   enums having the size of an int must be enabled.
   1.185 -   This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).
   1.186 -*/
   1.187 -/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */
   1.188 -#ifdef __MWERKS__
   1.189 -#pragma enumsalwaysint on
   1.190 -#endif
   1.191 -
   1.192 -/** \cond */
   1.193 -#ifndef DOXYGEN_SHOULD_IGNORE_THIS
   1.194 -#ifndef __NINTENDODS__          /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */
   1.195 -typedef enum
   1.196 -{
   1.197 -    DUMMY_ENUM_VALUE
   1.198 -} SDL_DUMMY_ENUM;
   1.199 -
   1.200 -SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
   1.201 -#endif
   1.202 -#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
   1.203 -/** \endcond */
   1.204 -
   1.205 -#include "begin_code.h"
   1.206 -/* Set up for C function definitions, even when using C++ */
   1.207 -#ifdef __cplusplus
   1.208 -/* *INDENT-OFF* */
   1.209 -extern "C" {
   1.210 -/* *INDENT-ON* */
   1.211 -#endif
   1.212 -
   1.213 -#ifdef HAVE_MALLOC
   1.214 -#define SDL_malloc	malloc
   1.215 -#else
   1.216 -extern DECLSPEC void *SDLCALL SDL_malloc(size_t size);
   1.217 -#endif
   1.218 -
   1.219 -#ifdef HAVE_CALLOC
   1.220 -#define SDL_calloc	calloc
   1.221 -#else
   1.222 -extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size);
   1.223 -#endif
   1.224 -
   1.225 -#ifdef HAVE_REALLOC
   1.226 -#define SDL_realloc	realloc
   1.227 -#else
   1.228 -extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size);
   1.229 -#endif
   1.230 -
   1.231 -#ifdef HAVE_FREE
   1.232 -#define SDL_free	free
   1.233 -#else
   1.234 -extern DECLSPEC void SDLCALL SDL_free(void *mem);
   1.235 -#endif
   1.236 -
   1.237 -#if defined(HAVE_ALLOCA) && !defined(alloca)
   1.238 -# if defined(HAVE_ALLOCA_H)
   1.239 -#  include <alloca.h>
   1.240 -# elif defined(__GNUC__)
   1.241 -#  define alloca __builtin_alloca
   1.242 -# elif defined(_MSC_VER)
   1.243 -#  include <malloc.h>
   1.244 -#  define alloca _alloca
   1.245 -# elif defined(__WATCOMC__)
   1.246 -#  include <malloc.h>
   1.247 -# elif defined(__BORLANDC__)
   1.248 -#  include <malloc.h>
   1.249 -# elif defined(__DMC__)
   1.250 -#  include <stdlib.h>
   1.251 -# elif defined(__AIX__)
   1.252 -#pragma alloca
   1.253 -# elif defined(__MRC__)
   1.254 -void *alloca(unsigned);
   1.255 -# else
   1.256 -char *alloca();
   1.257 -# endif
   1.258 -#endif
   1.259 -#ifdef HAVE_ALLOCA
   1.260 -#define SDL_stack_alloc(type, count)    (type*)alloca(sizeof(type)*(count))
   1.261 -#define SDL_stack_free(data)
   1.262 -#else
   1.263 -#define SDL_stack_alloc(type, count)    (type*)SDL_malloc(sizeof(type)*(count))
   1.264 -#define SDL_stack_free(data)            SDL_free(data)
   1.265 -#endif
   1.266 -
   1.267 -#ifdef HAVE_GETENV
   1.268 -#define SDL_getenv	getenv
   1.269 -#else
   1.270 -extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
   1.271 -#endif
   1.272 -
   1.273 -/* SDL_putenv() has moved to SDL_compat. */
   1.274 -#ifdef HAVE_SETENV
   1.275 -#define SDL_setenv	setenv
   1.276 -#else
   1.277 -extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value,
   1.278 -                                       int overwrite);
   1.279 -#endif
   1.280 -
   1.281 -#ifdef HAVE_QSORT
   1.282 -#define SDL_qsort	qsort
   1.283 -#else
   1.284 -extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
   1.285 -                                       int (*compare) (const void *,
   1.286 -                                                       const void *));
   1.287 -#endif
   1.288 -
   1.289 -#ifdef HAVE_ABS
   1.290 -#define SDL_abs		abs
   1.291 -#else
   1.292 -#define SDL_abs(X)	((X) < 0 ? -(X) : (X))
   1.293 -#endif
   1.294 -
   1.295 -#define SDL_min(x, y)	(((x) < (y)) ? (x) : (y))
   1.296 -#define SDL_max(x, y)	(((x) > (y)) ? (x) : (y))
   1.297 -
   1.298 -#ifdef HAVE_CTYPE_H
   1.299 -#define SDL_isdigit(X)  isdigit(X)
   1.300 -#define SDL_isspace(X)  isspace(X)
   1.301 -#define SDL_toupper(X)  toupper(X)
   1.302 -#define SDL_tolower(X)  tolower(X)
   1.303 -#else
   1.304 -#define SDL_isdigit(X)  (((X) >= '0') && ((X) <= '9'))
   1.305 -#define SDL_isspace(X)  (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n'))
   1.306 -#define SDL_toupper(X)  (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X))
   1.307 -#define SDL_tolower(X)  (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X))
   1.308 -#endif
   1.309 -
   1.310 -#ifdef HAVE_MEMSET
   1.311 -#define SDL_memset      memset
   1.312 -#else
   1.313 -extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len);
   1.314 -#endif
   1.315 -#define SDL_zero(x)	SDL_memset(&(x), 0, sizeof((x)))
   1.316 -#define SDL_zerop(x)	SDL_memset((x), 0, sizeof(*(x)))
   1.317 -
   1.318 -#if defined(__GNUC__) && defined(i386)
   1.319 -#define SDL_memset4(dst, val, len)				\
   1.320 -do {								\
   1.321 -	int u0, u1, u2;						\
   1.322 -	__asm__ __volatile__ (					\
   1.323 -		"cld\n\t"					\
   1.324 -		"rep ; stosl\n\t"				\
   1.325 -		: "=&D" (u0), "=&a" (u1), "=&c" (u2)		\
   1.326 -		: "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len))	\
   1.327 -		: "memory" );					\
   1.328 -} while(0)
   1.329 -#endif
   1.330 -#ifndef SDL_memset4
   1.331 -#define SDL_memset4(dst, val, len)		\
   1.332 -do {						\
   1.333 -	unsigned _count = (len);		\
   1.334 -	unsigned _n = (_count + 3) / 4;		\
   1.335 -	Uint32 *_p = SDL_static_cast(Uint32 *, dst);		\
   1.336 -	Uint32 _val = (val);			\
   1.337 -	if (len == 0) break;			\
   1.338 -        switch (_count % 4) {			\
   1.339 -        case 0: do {    *_p++ = _val;		\
   1.340 -        case 3:         *_p++ = _val;		\
   1.341 -        case 2:         *_p++ = _val;		\
   1.342 -        case 1:         *_p++ = _val;		\
   1.343 -		} while ( --_n );		\
   1.344 -	}					\
   1.345 -} while(0)
   1.346 -#endif
   1.347 -
   1.348 -/* We can count on memcpy existing on Mac OS X and being well-tuned. */
   1.349 -#if defined(__MACH__) && defined(__APPLE__)
   1.350 -#define SDL_memcpy(dst, src, len) memcpy(dst, src, len)
   1.351 -#elif defined(__GNUC__) && defined(i386)
   1.352 -#define SDL_memcpy(dst, src, len)					  \
   1.353 -do {									  \
   1.354 -	int u0, u1, u2;						  	  \
   1.355 -	__asm__ __volatile__ (						  \
   1.356 -		"cld\n\t"						  \
   1.357 -		"rep ; movsl\n\t"					  \
   1.358 -		"testb $2,%b4\n\t"					  \
   1.359 -		"je 1f\n\t"						  \
   1.360 -		"movsw\n"						  \
   1.361 -		"1:\ttestb $1,%b4\n\t"					  \
   1.362 -		"je 2f\n\t"						  \
   1.363 -		"movsb\n"						  \
   1.364 -		"2:"							  \
   1.365 -		: "=&c" (u0), "=&D" (u1), "=&S" (u2)			  \
   1.366 -		: "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst),"2" (src) \
   1.367 -		: "memory" );						  \
   1.368 -} while(0)
   1.369 -#endif
   1.370 -#ifndef SDL_memcpy
   1.371 -#ifdef HAVE_MEMCPY
   1.372 -#define SDL_memcpy      memcpy
   1.373 -#elif defined(HAVE_BCOPY)
   1.374 -#define SDL_memcpy(d, s, n)	bcopy((s), (d), (n))
   1.375 -#else
   1.376 -extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src,
   1.377 -                                         size_t len);
   1.378 -#endif
   1.379 -#endif
   1.380 -
   1.381 -/* We can count on memcpy existing on Mac OS X and being well-tuned. */
   1.382 -#if defined(__MACH__) && defined(__APPLE__)
   1.383 -#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4)
   1.384 -#elif defined(__GNUC__) && defined(i386)
   1.385 -#define SDL_memcpy4(dst, src, len)				\
   1.386 -do {								\
   1.387 -	int ecx, edi, esi;					\
   1.388 -	__asm__ __volatile__ (					\
   1.389 -		"cld\n\t"					\
   1.390 -		"rep ; movsl"					\
   1.391 -		: "=&c" (ecx), "=&D" (edi), "=&S" (esi)		\
   1.392 -		: "0" (SDL_static_cast(unsigned, len)), "1" (dst), "2" (src)	\
   1.393 -		: "memory" );					\
   1.394 -} while(0)
   1.395 -#endif
   1.396 -#ifndef SDL_memcpy4
   1.397 -#define SDL_memcpy4(dst, src, len)	SDL_memcpy(dst, src, (len) << 2)
   1.398 -#endif
   1.399 -
   1.400 -#if defined(__GNUC__) && defined(i386)
   1.401 -#define SDL_revcpy(dst, src, len)			\
   1.402 -do {							\
   1.403 -	int u0, u1, u2;					\
   1.404 -	char *dstp = SDL_static_cast(char *, dst);			\
   1.405 -	char *srcp = SDL_static_cast(char *, src);			\
   1.406 -	int n = (len);					\
   1.407 -	if ( n >= 4 ) {					\
   1.408 -	__asm__ __volatile__ (				\
   1.409 -		"std\n\t"				\
   1.410 -		"rep ; movsl\n\t"			\
   1.411 -		"cld\n\t"				\
   1.412 -		: "=&c" (u0), "=&D" (u1), "=&S" (u2)	\
   1.413 -		: "0" (n >> 2),				\
   1.414 -		  "1" (dstp+(n-4)), "2" (srcp+(n-4))	\
   1.415 -		: "memory" );				\
   1.416 -	}						\
   1.417 -	switch (n & 3) {				\
   1.418 -		case 3: dstp[2] = srcp[2];		\
   1.419 -		case 2: dstp[1] = srcp[1];		\
   1.420 -		case 1: dstp[0] = srcp[0];		\
   1.421 -			break;				\
   1.422 -		default:				\
   1.423 -			break;				\
   1.424 -	}						\
   1.425 -} while(0)
   1.426 -#endif
   1.427 -#ifndef SDL_revcpy
   1.428 -extern DECLSPEC void *SDLCALL SDL_revcpy(void *dst, const void *src,
   1.429 -                                         size_t len);
   1.430 -#endif
   1.431 -
   1.432 -#ifdef HAVE_MEMMOVE
   1.433 -#define SDL_memmove     memmove
   1.434 -#elif defined(HAVE_BCOPY)
   1.435 -#define SDL_memmove(d, s, n)	bcopy((s), (d), (n))
   1.436 -#else
   1.437 -#define SDL_memmove(dst, src, len)			\
   1.438 -do {							\
   1.439 -	if ( dst < src ) {				\
   1.440 -		SDL_memcpy(dst, src, len);		\
   1.441 -	} else {					\
   1.442 -		SDL_revcpy(dst, src, len);		\
   1.443 -	}						\
   1.444 -} while(0)
   1.445 -#endif
   1.446 -
   1.447 -#ifdef HAVE_MEMCMP
   1.448 -#define SDL_memcmp      memcmp
   1.449 -#else
   1.450 -extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2,
   1.451 -                                       size_t len);
   1.452 -#endif
   1.453 -
   1.454 -#ifdef HAVE_STRLEN
   1.455 -#define SDL_strlen      strlen
   1.456 -#else
   1.457 -extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
   1.458 -#endif
   1.459 -
   1.460 -#ifdef HAVE_WCSLEN
   1.461 -#define SDL_wcslen      wcslen
   1.462 -#else
   1.463 -#if !defined(wchar_t) && defined(__NINTENDODS__)
   1.464 -#define wchar_t short           /* TODO: figure out why libnds doesn't have this */
   1.465 -#endif
   1.466 -extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t * string);
   1.467 -#endif
   1.468 -
   1.469 -#ifdef HAVE_STRLCPY
   1.470 -#define SDL_strlcpy     strlcpy
   1.471 -#else
   1.472 -extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src,
   1.473 -                                           size_t maxlen);
   1.474 -#endif
   1.475 -
   1.476 +/*
   1.477 +    SDL - Simple DirectMedia Layer
   1.478 +    Copyright (C) 1997-2010 Sam Lantinga
   1.479 +
   1.480 +    This library is free software; you can redistribute it and/or
   1.481 +    modify it under the terms of the GNU Lesser General Public
   1.482 +    License as published by the Free Software Foundation; either
   1.483 +    version 2.1 of the License, or (at your option) any later version.
   1.484 +
   1.485 +    This library is distributed in the hope that it will be useful,
   1.486 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   1.487 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   1.488 +    Lesser General Public License for more details.
   1.489 +
   1.490 +    You should have received a copy of the GNU Lesser General Public
   1.491 +    License along with this library; if not, write to the Free Software
   1.492 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   1.493 +
   1.494 +    Sam Lantinga
   1.495 +    slouken@libsdl.org
   1.496 +*/
   1.497 +
   1.498 +/**
   1.499 + *  \file SDL_stdinc.h
   1.500 + *  
   1.501 + *  This is a general header that includes C language support.
   1.502 + */
   1.503 +
   1.504 +#ifndef _SDL_stdinc_h
   1.505 +#define _SDL_stdinc_h
   1.506 +
   1.507 +#include "SDL_config.h"
   1.508 +
   1.509 +
   1.510 +#ifdef HAVE_SYS_TYPES_H
   1.511 +#include <sys/types.h>
   1.512 +#endif
   1.513 +#ifdef HAVE_STDIO_H
   1.514 +#include <stdio.h>
   1.515 +#endif
   1.516 +#if defined(STDC_HEADERS)
   1.517 +# include <stdlib.h>
   1.518 +# include <stddef.h>
   1.519 +# include <stdarg.h>
   1.520 +#else
   1.521 +# if defined(HAVE_STDLIB_H)
   1.522 +#  include <stdlib.h>
   1.523 +# elif defined(HAVE_MALLOC_H)
   1.524 +#  include <malloc.h>
   1.525 +# endif
   1.526 +# if defined(HAVE_STDDEF_H)
   1.527 +#  include <stddef.h>
   1.528 +# endif
   1.529 +# if defined(HAVE_STDARG_H)
   1.530 +#  include <stdarg.h>
   1.531 +# endif
   1.532 +#endif
   1.533 +#ifdef HAVE_STRING_H
   1.534 +# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
   1.535 +#  include <memory.h>
   1.536 +# endif
   1.537 +# include <string.h>
   1.538 +#endif
   1.539 +#ifdef HAVE_STRINGS_H
   1.540 +# include <strings.h>
   1.541 +#endif
   1.542 +#if defined(HAVE_INTTYPES_H)
   1.543 +# include <inttypes.h>
   1.544 +#elif defined(HAVE_STDINT_H)
   1.545 +# include <stdint.h>
   1.546 +#endif
   1.547 +#ifdef HAVE_CTYPE_H
   1.548 +# include <ctype.h>
   1.549 +#endif
   1.550 +#ifdef HAVE_MATH_H
   1.551 +# include <math.h>
   1.552 +#endif
   1.553 +#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
   1.554 +# include <iconv.h>
   1.555 +#endif
   1.556 +
   1.557 +/**
   1.558 + *  The number of elements in an array.
   1.559 + */
   1.560 +#define SDL_arraysize(array)	(sizeof(array)/sizeof(array[0]))
   1.561 +#define SDL_TABLESIZE(table)	SDL_arraysize(table)
   1.562 +
   1.563 +/**
   1.564 + *  \name Cast operators
   1.565 + *  
   1.566 + *  Use proper C++ casts when compiled as C++ to be compatible with the option
   1.567 + *  -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above).
   1.568 + */
   1.569 +/*@{*/
   1.570 +#ifdef __cplusplus
   1.571 +#define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
   1.572 +#define SDL_static_cast(type, expression) static_cast<type>(expression)
   1.573 +#else
   1.574 +#define SDL_reinterpret_cast(type, expression) ((type)(expression))
   1.575 +#define SDL_static_cast(type, expression) ((type)(expression))
   1.576 +#endif
   1.577 +/*@}*//*Cast operators*/
   1.578 +
   1.579 +/* Define a four character code as a Uint32 */
   1.580 +#define SDL_FOURCC(A, B, C, D) \
   1.581 +    ((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \
   1.582 +     (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \
   1.583 +     (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \
   1.584 +     (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24))
   1.585 +
   1.586 +/**
   1.587 + *  \name Basic data types
   1.588 + */
   1.589 +/*@{*/
   1.590 +
   1.591 +typedef enum
   1.592 +{
   1.593 +    SDL_FALSE = 0,
   1.594 +    SDL_TRUE = 1
   1.595 +} SDL_bool;
   1.596 +
   1.597 +/**
   1.598 + * \brief A signed 8-bit integer type.
   1.599 + */
   1.600 +typedef int8_t Sint8;
   1.601 +/**
   1.602 + * \brief An unsigned 8-bit integer type.
   1.603 + */
   1.604 +typedef uint8_t Uint8;
   1.605 +/**
   1.606 + * \brief A signed 16-bit integer type.
   1.607 + */
   1.608 +typedef int16_t Sint16;
   1.609 +/**
   1.610 + * \brief An unsigned 16-bit integer type.
   1.611 + */
   1.612 +typedef uint16_t Uint16;
   1.613 +/**
   1.614 + * \brief A signed 32-bit integer type.
   1.615 + */
   1.616 +typedef int32_t Sint32;
   1.617 +/**
   1.618 + * \brief An unsigned 32-bit integer type.
   1.619 + */
   1.620 +typedef uint32_t Uint32;
   1.621 +
   1.622 +#ifdef SDL_HAS_64BIT_TYPE
   1.623 +/**
   1.624 + * \brief A signed 64-bit integer type.
   1.625 + * \warning On platforms without any sort of 64-bit datatype, this is equivalent to Sint32!
   1.626 + */
   1.627 +typedef int64_t Sint64;
   1.628 +/**
   1.629 + * \brief An unsigned 64-bit integer type.
   1.630 + * \warning On platforms without any sort of 64-bit datatype, this is equivalent to Uint32!
   1.631 + */
   1.632 +typedef uint64_t Uint64;
   1.633 +#else
   1.634 +/* This is really just a hack to prevent the compiler from complaining */
   1.635 +typedef Sint32 Sint64;
   1.636 +typedef Uint32 Uint64;
   1.637 +#endif
   1.638 +
   1.639 +/*@}*//*Basic data types*/
   1.640 +
   1.641 +
   1.642 +#define SDL_COMPILE_TIME_ASSERT(name, x)               \
   1.643 +       typedef int SDL_dummy_ ## name[(x) * 2 - 1]
   1.644 +/** \cond */
   1.645 +#ifndef DOXYGEN_SHOULD_IGNORE_THIS
   1.646 +SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
   1.647 +SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
   1.648 +SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
   1.649 +SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
   1.650 +SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
   1.651 +SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
   1.652 +#ifndef __NINTENDODS__          /* TODO: figure out why the following happens:
   1.653 +                                   include/SDL_stdinc.h:150: error: size of array 'SDL_dummy_uint64' is negative
   1.654 +                                   include/SDL_stdinc.h:151: error: size of array 'SDL_dummy_sint64' is negative */
   1.655 +SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
   1.656 +SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
   1.657 +#endif
   1.658 +#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
   1.659 +/** \endcond */
   1.660 +
   1.661 +/* Check to make sure enums are the size of ints, for structure packing.
   1.662 +   For both Watcom C/C++ and Borland C/C++ the compiler option that makes
   1.663 +   enums having the size of an int must be enabled.
   1.664 +   This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).
   1.665 +*/
   1.666 +/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */
   1.667 +#ifdef __MWERKS__
   1.668 +#pragma enumsalwaysint on
   1.669 +#endif
   1.670 +
   1.671 +/** \cond */
   1.672 +#ifndef DOXYGEN_SHOULD_IGNORE_THIS
   1.673 +#ifndef __NINTENDODS__          /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */
   1.674 +typedef enum
   1.675 +{
   1.676 +    DUMMY_ENUM_VALUE
   1.677 +} SDL_DUMMY_ENUM;
   1.678 +
   1.679 +SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
   1.680 +#endif
   1.681 +#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
   1.682 +/** \endcond */
   1.683 +
   1.684 +#include "begin_code.h"
   1.685 +/* Set up for C function definitions, even when using C++ */
   1.686 +#ifdef __cplusplus
   1.687 +/* *INDENT-OFF* */
   1.688 +extern "C" {
   1.689 +/* *INDENT-ON* */
   1.690 +#endif
   1.691 +
   1.692 +#ifdef HAVE_MALLOC
   1.693 +#define SDL_malloc	malloc
   1.694 +#else
   1.695 +extern DECLSPEC void *SDLCALL SDL_malloc(size_t size);
   1.696 +#endif
   1.697 +
   1.698 +#ifdef HAVE_CALLOC
   1.699 +#define SDL_calloc	calloc
   1.700 +#else
   1.701 +extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size);
   1.702 +#endif
   1.703 +
   1.704 +#ifdef HAVE_REALLOC
   1.705 +#define SDL_realloc	realloc
   1.706 +#else
   1.707 +extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size);
   1.708 +#endif
   1.709 +
   1.710 +#ifdef HAVE_FREE
   1.711 +#define SDL_free	free
   1.712 +#else
   1.713 +extern DECLSPEC void SDLCALL SDL_free(void *mem);
   1.714 +#endif
   1.715 +
   1.716 +#if defined(HAVE_ALLOCA) && !defined(alloca)
   1.717 +# if defined(HAVE_ALLOCA_H)
   1.718 +#  include <alloca.h>
   1.719 +# elif defined(__GNUC__)
   1.720 +#  define alloca __builtin_alloca
   1.721 +# elif defined(_MSC_VER)
   1.722 +#  include <malloc.h>
   1.723 +#  define alloca _alloca
   1.724 +# elif defined(__WATCOMC__)
   1.725 +#  include <malloc.h>
   1.726 +# elif defined(__BORLANDC__)
   1.727 +#  include <malloc.h>
   1.728 +# elif defined(__DMC__)
   1.729 +#  include <stdlib.h>
   1.730 +# elif defined(__AIX__)
   1.731 +#pragma alloca
   1.732 +# elif defined(__MRC__)
   1.733 +void *alloca(unsigned);
   1.734 +# else
   1.735 +char *alloca();
   1.736 +# endif
   1.737 +#endif
   1.738 +#ifdef HAVE_ALLOCA
   1.739 +#define SDL_stack_alloc(type, count)    (type*)alloca(sizeof(type)*(count))
   1.740 +#define SDL_stack_free(data)
   1.741 +#else
   1.742 +#define SDL_stack_alloc(type, count)    (type*)SDL_malloc(sizeof(type)*(count))
   1.743 +#define SDL_stack_free(data)            SDL_free(data)
   1.744 +#endif
   1.745 +
   1.746 +#ifdef HAVE_GETENV
   1.747 +#define SDL_getenv	getenv
   1.748 +#else
   1.749 +extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
   1.750 +#endif
   1.751 +
   1.752 +/* SDL_putenv() has moved to SDL_compat. */
   1.753 +#ifdef HAVE_SETENV
   1.754 +#define SDL_setenv	setenv
   1.755 +#else
   1.756 +extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value,
   1.757 +                                       int overwrite);
   1.758 +#endif
   1.759 +
   1.760 +#ifdef HAVE_QSORT
   1.761 +#define SDL_qsort	qsort
   1.762 +#else
   1.763 +extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
   1.764 +                                       int (*compare) (const void *,
   1.765 +                                                       const void *));
   1.766 +#endif
   1.767 +
   1.768 +#ifdef HAVE_ABS
   1.769 +#define SDL_abs		abs
   1.770 +#else
   1.771 +#define SDL_abs(X)	((X) < 0 ? -(X) : (X))
   1.772 +#endif
   1.773 +
   1.774 +#define SDL_min(x, y)	(((x) < (y)) ? (x) : (y))
   1.775 +#define SDL_max(x, y)	(((x) > (y)) ? (x) : (y))
   1.776 +
   1.777 +#ifdef HAVE_CTYPE_H
   1.778 +#define SDL_isdigit(X)  isdigit(X)
   1.779 +#define SDL_isspace(X)  isspace(X)
   1.780 +#define SDL_toupper(X)  toupper(X)
   1.781 +#define SDL_tolower(X)  tolower(X)
   1.782 +#else
   1.783 +#define SDL_isdigit(X)  (((X) >= '0') && ((X) <= '9'))
   1.784 +#define SDL_isspace(X)  (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n'))
   1.785 +#define SDL_toupper(X)  (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X))
   1.786 +#define SDL_tolower(X)  (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X))
   1.787 +#endif
   1.788 +
   1.789 +#ifdef HAVE_MEMSET
   1.790 +#define SDL_memset      memset
   1.791 +#else
   1.792 +extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len);
   1.793 +#endif
   1.794 +#define SDL_zero(x)	SDL_memset(&(x), 0, sizeof((x)))
   1.795 +#define SDL_zerop(x)	SDL_memset((x), 0, sizeof(*(x)))
   1.796 +
   1.797 +#if defined(__GNUC__) && defined(i386)
   1.798 +#define SDL_memset4(dst, val, len)				\
   1.799 +do {								\
   1.800 +	int u0, u1, u2;						\
   1.801 +	__asm__ __volatile__ (					\
   1.802 +		"cld\n\t"					\
   1.803 +		"rep ; stosl\n\t"				\
   1.804 +		: "=&D" (u0), "=&a" (u1), "=&c" (u2)		\
   1.805 +		: "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len))	\
   1.806 +		: "memory" );					\
   1.807 +} while(0)
   1.808 +#endif
   1.809 +#ifndef SDL_memset4
   1.810 +#define SDL_memset4(dst, val, len)		\
   1.811 +do {						\
   1.812 +	unsigned _count = (len);		\
   1.813 +	unsigned _n = (_count + 3) / 4;		\
   1.814 +	Uint32 *_p = SDL_static_cast(Uint32 *, dst);		\
   1.815 +	Uint32 _val = (val);			\
   1.816 +	if (len == 0) break;			\
   1.817 +        switch (_count % 4) {			\
   1.818 +        case 0: do {    *_p++ = _val;		\
   1.819 +        case 3:         *_p++ = _val;		\
   1.820 +        case 2:         *_p++ = _val;		\
   1.821 +        case 1:         *_p++ = _val;		\
   1.822 +		} while ( --_n );		\
   1.823 +	}					\
   1.824 +} while(0)
   1.825 +#endif
   1.826 +
   1.827 +/* We can count on memcpy existing on Mac OS X and being well-tuned. */
   1.828 +#if defined(__MACH__) && defined(__APPLE__)
   1.829 +#define SDL_memcpy(dst, src, len) memcpy(dst, src, len)
   1.830 +#elif defined(__GNUC__) && defined(i386)
   1.831 +#define SDL_memcpy(dst, src, len)					  \
   1.832 +do {									  \
   1.833 +	int u0, u1, u2;						  	  \
   1.834 +	__asm__ __volatile__ (						  \
   1.835 +		"cld\n\t"						  \
   1.836 +		"rep ; movsl\n\t"					  \
   1.837 +		"testb $2,%b4\n\t"					  \
   1.838 +		"je 1f\n\t"						  \
   1.839 +		"movsw\n"						  \
   1.840 +		"1:\ttestb $1,%b4\n\t"					  \
   1.841 +		"je 2f\n\t"						  \
   1.842 +		"movsb\n"						  \
   1.843 +		"2:"							  \
   1.844 +		: "=&c" (u0), "=&D" (u1), "=&S" (u2)			  \
   1.845 +		: "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst),"2" (src) \
   1.846 +		: "memory" );						  \
   1.847 +} while(0)
   1.848 +#endif
   1.849 +#ifndef SDL_memcpy
   1.850 +#ifdef HAVE_MEMCPY
   1.851 +#define SDL_memcpy      memcpy
   1.852 +#elif defined(HAVE_BCOPY)
   1.853 +#define SDL_memcpy(d, s, n)	bcopy((s), (d), (n))
   1.854 +#else
   1.855 +extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src,
   1.856 +                                         size_t len);
   1.857 +#endif
   1.858 +#endif
   1.859 +
   1.860 +/* We can count on memcpy existing on Mac OS X and being well-tuned. */
   1.861 +#if defined(__MACH__) && defined(__APPLE__)
   1.862 +#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4)
   1.863 +#elif defined(__GNUC__) && defined(i386)
   1.864 +#define SDL_memcpy4(dst, src, len)				\
   1.865 +do {								\
   1.866 +	int ecx, edi, esi;					\
   1.867 +	__asm__ __volatile__ (					\
   1.868 +		"cld\n\t"					\
   1.869 +		"rep ; movsl"					\
   1.870 +		: "=&c" (ecx), "=&D" (edi), "=&S" (esi)		\
   1.871 +		: "0" (SDL_static_cast(unsigned, len)), "1" (dst), "2" (src)	\
   1.872 +		: "memory" );					\
   1.873 +} while(0)
   1.874 +#endif
   1.875 +#ifndef SDL_memcpy4
   1.876 +#define SDL_memcpy4(dst, src, len)	SDL_memcpy(dst, src, (len) << 2)
   1.877 +#endif
   1.878 +
   1.879 +#if defined(__GNUC__) && defined(i386)
   1.880 +#define SDL_revcpy(dst, src, len)			\
   1.881 +do {							\
   1.882 +	int u0, u1, u2;					\
   1.883 +	char *dstp = SDL_static_cast(char *, dst);			\
   1.884 +	char *srcp = SDL_static_cast(char *, src);			\
   1.885 +	int n = (len);					\
   1.886 +	if ( n >= 4 ) {					\
   1.887 +	__asm__ __volatile__ (				\
   1.888 +		"std\n\t"				\
   1.889 +		"rep ; movsl\n\t"			\
   1.890 +		"cld\n\t"				\
   1.891 +		: "=&c" (u0), "=&D" (u1), "=&S" (u2)	\
   1.892 +		: "0" (n >> 2),				\
   1.893 +		  "1" (dstp+(n-4)), "2" (srcp+(n-4))	\
   1.894 +		: "memory" );				\
   1.895 +	}						\
   1.896 +	switch (n & 3) {				\
   1.897 +		case 3: dstp[2] = srcp[2];		\
   1.898 +		case 2: dstp[1] = srcp[1];		\
   1.899 +		case 1: dstp[0] = srcp[0];		\
   1.900 +			break;				\
   1.901 +		default:				\
   1.902 +			break;				\
   1.903 +	}						\
   1.904 +} while(0)
   1.905 +#endif
   1.906 +#ifndef SDL_revcpy
   1.907 +extern DECLSPEC void *SDLCALL SDL_revcpy(void *dst, const void *src,
   1.908 +                                         size_t len);
   1.909 +#endif
   1.910 +
   1.911 +#ifdef HAVE_MEMMOVE
   1.912 +#define SDL_memmove     memmove
   1.913 +#elif defined(HAVE_BCOPY)
   1.914 +#define SDL_memmove(d, s, n)	bcopy((s), (d), (n))
   1.915 +#else
   1.916 +#define SDL_memmove(dst, src, len)			\
   1.917 +do {							\
   1.918 +	if ( dst < src ) {				\
   1.919 +		SDL_memcpy(dst, src, len);		\
   1.920 +	} else {					\
   1.921 +		SDL_revcpy(dst, src, len);		\
   1.922 +	}						\
   1.923 +} while(0)
   1.924 +#endif
   1.925 +
   1.926 +#ifdef HAVE_MEMCMP
   1.927 +#define SDL_memcmp      memcmp
   1.928 +#else
   1.929 +extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2,
   1.930 +                                       size_t len);
   1.931 +#endif
   1.932 +
   1.933 +#ifdef HAVE_STRLEN
   1.934 +#define SDL_strlen      strlen
   1.935 +#else
   1.936 +extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
   1.937 +#endif
   1.938 +
   1.939 +#ifdef HAVE_WCSLEN
   1.940 +#define SDL_wcslen      wcslen
   1.941 +#else
   1.942 +#if !defined(wchar_t) && defined(__NINTENDODS__)
   1.943 +#define wchar_t short           /* TODO: figure out why libnds doesn't have this */
   1.944 +#endif
   1.945 +extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t * string);
   1.946 +#endif
   1.947 +
   1.948 +#ifdef HAVE_STRLCPY
   1.949 +#define SDL_strlcpy     strlcpy
   1.950 +#else
   1.951 +extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src,
   1.952 +                                           size_t maxlen);
   1.953 +#endif
   1.954 +
   1.955  extern DECLSPEC size_t SDLCALL SDL_utf8strlcpy(char *dst, const char *src,
   1.956                                              size_t dst_bytes);
   1.957 -
   1.958 -#ifdef HAVE_STRLCAT
   1.959 -#define SDL_strlcat    strlcat
   1.960 -#else
   1.961 -extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src,
   1.962 -                                           size_t maxlen);
   1.963 -#endif
   1.964 -
   1.965 -#ifdef HAVE_STRDUP
   1.966 -#define SDL_strdup     strdup
   1.967 -#else
   1.968 -extern DECLSPEC char *SDLCALL SDL_strdup(const char *string);
   1.969 -#endif
   1.970 -
   1.971 -#ifdef HAVE__STRREV
   1.972 -#define SDL_strrev      _strrev
   1.973 -#else
   1.974 -extern DECLSPEC char *SDLCALL SDL_strrev(char *string);
   1.975 -#endif
   1.976 -
   1.977 -#ifdef HAVE__STRUPR
   1.978 -#define SDL_strupr      _strupr
   1.979 -#else
   1.980 -extern DECLSPEC char *SDLCALL SDL_strupr(char *string);
   1.981 -#endif
   1.982 -
   1.983 -#ifdef HAVE__STRLWR
   1.984 -#define SDL_strlwr      _strlwr
   1.985 -#else
   1.986 -extern DECLSPEC char *SDLCALL SDL_strlwr(char *string);
   1.987 -#endif
   1.988 -
   1.989 -#ifdef HAVE_STRCHR
   1.990 -#define SDL_strchr      strchr
   1.991 -#elif defined(HAVE_INDEX)
   1.992 -#define SDL_strchr      index
   1.993 -#else
   1.994 -extern DECLSPEC char *SDLCALL SDL_strchr(const char *string, int c);
   1.995 -#endif
   1.996 -
   1.997 -#ifdef HAVE_STRRCHR
   1.998 -#define SDL_strrchr     strrchr
   1.999 -#elif defined(HAVE_RINDEX)
  1.1000 -#define SDL_strrchr     rindex
  1.1001 -#else
  1.1002 -extern DECLSPEC char *SDLCALL SDL_strrchr(const char *string, int c);
  1.1003 -#endif
  1.1004 -
  1.1005 -#ifdef HAVE_STRSTR
  1.1006 -#define SDL_strstr      strstr
  1.1007 -#else
  1.1008 -extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack,
  1.1009 -                                         const char *needle);
  1.1010 -#endif
  1.1011 -
  1.1012 -#ifdef HAVE_ITOA
  1.1013 -#define SDL_itoa        itoa
  1.1014 -#else
  1.1015 -#define SDL_itoa(value, string, radix)	SDL_ltoa((long)value, string, radix)
  1.1016 -#endif
  1.1017 -
  1.1018 -#ifdef HAVE__LTOA
  1.1019 -#define SDL_ltoa        _ltoa
  1.1020 -#else
  1.1021 -extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *string, int radix);
  1.1022 -#endif
  1.1023 -
  1.1024 -#ifdef HAVE__UITOA
  1.1025 -#define SDL_uitoa       _uitoa
  1.1026 -#else
  1.1027 -#define SDL_uitoa(value, string, radix)	SDL_ultoa((long)value, string, radix)
  1.1028 -#endif
  1.1029 -
  1.1030 -#ifdef HAVE__ULTOA
  1.1031 -#define SDL_ultoa       _ultoa
  1.1032 -#else
  1.1033 -extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *string,
  1.1034 -                                        int radix);
  1.1035 -#endif
  1.1036 -
  1.1037 -#ifdef HAVE_STRTOL
  1.1038 -#define SDL_strtol      strtol
  1.1039 -#else
  1.1040 -extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp,
  1.1041 -                                        int base);
  1.1042 -#endif
  1.1043 -
  1.1044 -#ifdef HAVE_STRTOUL
  1.1045 -#define SDL_strtoul      strtoul
  1.1046 -#else
  1.1047 -extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string,
  1.1048 -                                                  char **endp, int base);
  1.1049 -#endif
  1.1050 -
  1.1051 -#ifdef SDL_HAS_64BIT_TYPE
  1.1052 -
  1.1053 -#ifdef HAVE__I64TOA
  1.1054 -#define SDL_lltoa       _i64toa
  1.1055 -#else
  1.1056 -extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *string,
  1.1057 -                                        int radix);
  1.1058 -#endif
  1.1059 -
  1.1060 -#ifdef HAVE__UI64TOA
  1.1061 -#define SDL_ulltoa      _ui64toa
  1.1062 -#else
  1.1063 -extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *string,
  1.1064 -                                         int radix);
  1.1065 -#endif
  1.1066 -
  1.1067 -#ifdef HAVE_STRTOLL
  1.1068 -#define SDL_strtoll     strtoll
  1.1069 -#else
  1.1070 -extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp,
  1.1071 -                                           int base);
  1.1072 -#endif
  1.1073 -
  1.1074 -#ifdef HAVE_STRTOULL
  1.1075 -#define SDL_strtoull     strtoull
  1.1076 -#else
  1.1077 -extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp,
  1.1078 -                                            int base);
  1.1079 -#endif
  1.1080 -
  1.1081 -#endif /* SDL_HAS_64BIT_TYPE */
  1.1082 -
  1.1083 -#ifdef HAVE_STRTOD
  1.1084 -#define SDL_strtod      strtod
  1.1085 -#else
  1.1086 -extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp);
  1.1087 -#endif
  1.1088 -
  1.1089 -#ifdef HAVE_ATOI
  1.1090 -#define SDL_atoi        atoi
  1.1091 -#else
  1.1092 -#define SDL_atoi(X)     SDL_strtol(X, NULL, 0)
  1.1093 -#endif
  1.1094 -
  1.1095 -#ifdef HAVE_ATOF
  1.1096 -#define SDL_atof        atof
  1.1097 -#else
  1.1098 -#define SDL_atof(X)     SDL_strtod(X, NULL)
  1.1099 -#endif
  1.1100 -
  1.1101 -#ifdef HAVE_STRCMP
  1.1102 -#define SDL_strcmp      strcmp
  1.1103 -#else
  1.1104 -extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
  1.1105 -#endif
  1.1106 -
  1.1107 -#ifdef HAVE_STRNCMP
  1.1108 -#define SDL_strncmp     strncmp
  1.1109 -#else
  1.1110 -extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2,
  1.1111 -                                        size_t maxlen);
  1.1112 -#endif
  1.1113 -
  1.1114 -#ifdef HAVE_STRCASECMP
  1.1115 -#define SDL_strcasecmp  strcasecmp
  1.1116 -#elif defined(HAVE__STRICMP)
  1.1117 -#define SDL_strcasecmp  _stricmp
  1.1118 -#else
  1.1119 -extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1,
  1.1120 -                                           const char *str2);
  1.1121 -#endif
  1.1122 -
  1.1123 -#ifdef HAVE_STRNCASECMP
  1.1124 -#define SDL_strncasecmp strncasecmp
  1.1125 -#elif defined(HAVE__STRNICMP)
  1.1126 -#define SDL_strncasecmp _strnicmp
  1.1127 -#else
  1.1128 -extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1,
  1.1129 -                                            const char *str2, size_t maxlen);
  1.1130 -#endif
  1.1131 -
  1.1132 -#ifdef HAVE_SSCANF
  1.1133 -#define SDL_sscanf      sscanf
  1.1134 -#else
  1.1135 -extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt,
  1.1136 -                                       ...);
  1.1137 -#endif
  1.1138 -
  1.1139 -#ifdef HAVE_SNPRINTF
  1.1140 -#define SDL_snprintf    snprintf
  1.1141 -#else
  1.1142 -extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen,
  1.1143 -                                         const char *fmt, ...);
  1.1144 -#endif
  1.1145 -
  1.1146 -#ifdef HAVE_VSNPRINTF
  1.1147 -#define SDL_vsnprintf   vsnprintf
  1.1148 -#else
  1.1149 -extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen,
  1.1150 -                                          const char *fmt, va_list ap);
  1.1151 -#endif
  1.1152 -
  1.1153 -#ifndef HAVE_M_PI
  1.1154 -#define M_PI    3.14159265358979323846264338327950288   /* pi */
  1.1155 -#endif
  1.1156 -
  1.1157 -#ifdef HAVE_CEIL
  1.1158 -#define SDL_ceil        ceil
  1.1159 -#else
  1.1160 -#define SDL_ceil(x)     ((double)(int)((x)+0.5))
  1.1161 -#endif
  1.1162 -
  1.1163 -#ifdef HAVE_COPYSIGN
  1.1164 -#define SDL_copysign    copysign
  1.1165 -#else
  1.1166 -extern DECLSPEC double SDLCALL SDL_copysign(double x, double y);
  1.1167 -#endif
  1.1168 -
  1.1169 -#ifdef HAVE_COS
  1.1170 -#define SDL_cos         cos
  1.1171 -#else
  1.1172 -extern DECLSPEC double SDLCALL SDL_cos(double x);
  1.1173 -#endif
  1.1174 -
  1.1175 -#ifdef HAVE_COSF
  1.1176 -#define SDL_cosf        cosf
  1.1177 -#else
  1.1178 -#define SDL_cosf(x) (float)SDL_cos((double)x)
  1.1179 -#endif
  1.1180 -
  1.1181 -#ifdef HAVE_FABS
  1.1182 -#define SDL_fabs        fabs
  1.1183 -#else
  1.1184 -extern DECLSPEC double SDLCALL SDL_fabs(double x);
  1.1185 -#endif
  1.1186 -
  1.1187 -#ifdef HAVE_FLOOR
  1.1188 -#define SDL_floor       floor
  1.1189 -#else
  1.1190 -extern DECLSPEC double SDLCALL SDL_floor(double x);
  1.1191 -#endif
  1.1192 -
  1.1193 -#ifdef HAVE_LOG
  1.1194 -#define SDL_log         log
  1.1195 -#else
  1.1196 -extern DECLSPEC double SDLCALL SDL_log(double x);
  1.1197 -#endif
  1.1198 -
  1.1199 -#ifdef HAVE_POW
  1.1200 -#define SDL_pow         pow
  1.1201 -#else
  1.1202 -extern DECLSPEC double SDLCALL SDL_pow(double x, double y);
  1.1203 -#endif
  1.1204 -
  1.1205 -#ifdef HAVE_SCALBN
  1.1206 -#define SDL_scalbn      scalbn
  1.1207 -#else
  1.1208 -extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n);
  1.1209 -#endif
  1.1210 -
  1.1211 -#ifdef HAVE_SIN
  1.1212 -#define SDL_sin         sin
  1.1213 -#else
  1.1214 -extern DECLSPEC double SDLCALL SDL_sin(double x);
  1.1215 -#endif
  1.1216 -
  1.1217 -#ifdef HAVE_SINF
  1.1218 -#define SDL_sinf        sinf
  1.1219 -#else
  1.1220 -#define SDL_sinf(x) (float)SDL_sin((double)x)
  1.1221 -#endif
  1.1222 -
  1.1223 -#ifdef HAVE_SQRT
  1.1224 -#define SDL_sqrt        sqrt
  1.1225 -#else
  1.1226 -extern DECLSPEC double SDLCALL SDL_sqrt(double x);
  1.1227 -#endif
  1.1228 -
  1.1229 -/* The SDL implementation of iconv() returns these error codes */
  1.1230 -#define SDL_ICONV_ERROR		(size_t)-1
  1.1231 -#define SDL_ICONV_E2BIG		(size_t)-2
  1.1232 -#define SDL_ICONV_EILSEQ	(size_t)-3
  1.1233 -#define SDL_ICONV_EINVAL	(size_t)-4
  1.1234 -
  1.1235 -#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
  1.1236 -#define SDL_iconv_t     iconv_t
  1.1237 -#define SDL_iconv_open  iconv_open
  1.1238 -#define SDL_iconv_close iconv_close
  1.1239 -#else
  1.1240 -typedef struct _SDL_iconv_t *SDL_iconv_t;
  1.1241 -extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode,
  1.1242 -                                                   const char *fromcode);
  1.1243 -extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
  1.1244 -#endif
  1.1245 -extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
  1.1246 -                                         size_t * inbytesleft, char **outbuf,
  1.1247 -                                         size_t * outbytesleft);
  1.1248 -/**
  1.1249 - *  This function converts a string between encodings in one pass, returning a
  1.1250 - *  string that must be freed with SDL_free() or NULL on error.
  1.1251 - */
  1.1252 -extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
  1.1253 -                                               const char *fromcode,
  1.1254 -                                               const char *inbuf,
  1.1255 -                                               size_t inbytesleft);
  1.1256 -#define SDL_iconv_utf8_locale(S)	SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
  1.1257 -#define SDL_iconv_utf8_ucs2(S)		(Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
  1.1258 -#define SDL_iconv_utf8_ucs4(S)		(Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
  1.1259 -
  1.1260 -/* Ends C function definitions when using C++ */
  1.1261 -#ifdef __cplusplus
  1.1262 -/* *INDENT-OFF* */
  1.1263 -}
  1.1264 -/* *INDENT-ON* */
  1.1265 -#endif
  1.1266 -#include "close_code.h"
  1.1267 -
  1.1268 -#endif /* _SDL_stdinc_h */
  1.1269 -
  1.1270 -/* vi: set ts=4 sw=4 expandtab: */
  1.1271 +
  1.1272 +#ifdef HAVE_STRLCAT
  1.1273 +#define SDL_strlcat    strlcat
  1.1274 +#else
  1.1275 +extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src,
  1.1276 +                                           size_t maxlen);
  1.1277 +#endif
  1.1278 +
  1.1279 +#ifdef HAVE_STRDUP
  1.1280 +#define SDL_strdup     strdup
  1.1281 +#else
  1.1282 +extern DECLSPEC char *SDLCALL SDL_strdup(const char *string);
  1.1283 +#endif
  1.1284 +
  1.1285 +#ifdef HAVE__STRREV
  1.1286 +#define SDL_strrev      _strrev
  1.1287 +#else
  1.1288 +extern DECLSPEC char *SDLCALL SDL_strrev(char *string);
  1.1289 +#endif
  1.1290 +
  1.1291 +#ifdef HAVE__STRUPR
  1.1292 +#define SDL_strupr      _strupr
  1.1293 +#else
  1.1294 +extern DECLSPEC char *SDLCALL SDL_strupr(char *string);
  1.1295 +#endif
  1.1296 +
  1.1297 +#ifdef HAVE__STRLWR
  1.1298 +#define SDL_strlwr      _strlwr
  1.1299 +#else
  1.1300 +extern DECLSPEC char *SDLCALL SDL_strlwr(char *string);
  1.1301 +#endif
  1.1302 +
  1.1303 +#ifdef HAVE_STRCHR
  1.1304 +#define SDL_strchr      strchr
  1.1305 +#elif defined(HAVE_INDEX)
  1.1306 +#define SDL_strchr      index
  1.1307 +#else
  1.1308 +extern DECLSPEC char *SDLCALL SDL_strchr(const char *string, int c);
  1.1309 +#endif
  1.1310 +
  1.1311 +#ifdef HAVE_STRRCHR
  1.1312 +#define SDL_strrchr     strrchr
  1.1313 +#elif defined(HAVE_RINDEX)
  1.1314 +#define SDL_strrchr     rindex
  1.1315 +#else
  1.1316 +extern DECLSPEC char *SDLCALL SDL_strrchr(const char *string, int c);
  1.1317 +#endif
  1.1318 +
  1.1319 +#ifdef HAVE_STRSTR
  1.1320 +#define SDL_strstr      strstr
  1.1321 +#else
  1.1322 +extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack,
  1.1323 +                                         const char *needle);
  1.1324 +#endif
  1.1325 +
  1.1326 +#ifdef HAVE_ITOA
  1.1327 +#define SDL_itoa        itoa
  1.1328 +#else
  1.1329 +#define SDL_itoa(value, string, radix)	SDL_ltoa((long)value, string, radix)
  1.1330 +#endif
  1.1331 +
  1.1332 +#ifdef HAVE__LTOA
  1.1333 +#define SDL_ltoa        _ltoa
  1.1334 +#else
  1.1335 +extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *string, int radix);
  1.1336 +#endif
  1.1337 +
  1.1338 +#ifdef HAVE__UITOA
  1.1339 +#define SDL_uitoa       _uitoa
  1.1340 +#else
  1.1341 +#define SDL_uitoa(value, string, radix)	SDL_ultoa((long)value, string, radix)
  1.1342 +#endif
  1.1343 +
  1.1344 +#ifdef HAVE__ULTOA
  1.1345 +#define SDL_ultoa       _ultoa
  1.1346 +#else
  1.1347 +extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *string,
  1.1348 +                                        int radix);
  1.1349 +#endif
  1.1350 +
  1.1351 +#ifdef HAVE_STRTOL
  1.1352 +#define SDL_strtol      strtol
  1.1353 +#else
  1.1354 +extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp,
  1.1355 +                                        int base);
  1.1356 +#endif
  1.1357 +
  1.1358 +#ifdef HAVE_STRTOUL
  1.1359 +#define SDL_strtoul      strtoul
  1.1360 +#else
  1.1361 +extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string,
  1.1362 +                                                  char **endp, int base);
  1.1363 +#endif
  1.1364 +
  1.1365 +#ifdef SDL_HAS_64BIT_TYPE
  1.1366 +
  1.1367 +#ifdef HAVE__I64TOA
  1.1368 +#define SDL_lltoa       _i64toa
  1.1369 +#else
  1.1370 +extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *string,
  1.1371 +                                        int radix);
  1.1372 +#endif
  1.1373 +
  1.1374 +#ifdef HAVE__UI64TOA
  1.1375 +#define SDL_ulltoa      _ui64toa
  1.1376 +#else
  1.1377 +extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *string,
  1.1378 +                                         int radix);
  1.1379 +#endif
  1.1380 +
  1.1381 +#ifdef HAVE_STRTOLL
  1.1382 +#define SDL_strtoll     strtoll
  1.1383 +#else
  1.1384 +extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp,
  1.1385 +                                           int base);
  1.1386 +#endif
  1.1387 +
  1.1388 +#ifdef HAVE_STRTOULL
  1.1389 +#define SDL_strtoull     strtoull
  1.1390 +#else
  1.1391 +extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp,
  1.1392 +                                            int base);
  1.1393 +#endif
  1.1394 +
  1.1395 +#endif /* SDL_HAS_64BIT_TYPE */
  1.1396 +
  1.1397 +#ifdef HAVE_STRTOD
  1.1398 +#define SDL_strtod      strtod
  1.1399 +#else
  1.1400 +extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp);
  1.1401 +#endif
  1.1402 +
  1.1403 +#ifdef HAVE_ATOI
  1.1404 +#define SDL_atoi        atoi
  1.1405 +#else
  1.1406 +#define SDL_atoi(X)     SDL_strtol(X, NULL, 0)
  1.1407 +#endif
  1.1408 +
  1.1409 +#ifdef HAVE_ATOF
  1.1410 +#define SDL_atof        atof
  1.1411 +#else
  1.1412 +#define SDL_atof(X)     SDL_strtod(X, NULL)
  1.1413 +#endif
  1.1414 +
  1.1415 +#ifdef HAVE_STRCMP
  1.1416 +#define SDL_strcmp      strcmp
  1.1417 +#else
  1.1418 +extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
  1.1419 +#endif
  1.1420 +
  1.1421 +#ifdef HAVE_STRNCMP
  1.1422 +#define SDL_strncmp     strncmp
  1.1423 +#else
  1.1424 +extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2,
  1.1425 +                                        size_t maxlen);
  1.1426 +#endif
  1.1427 +
  1.1428 +#ifdef HAVE_STRCASECMP
  1.1429 +#define SDL_strcasecmp  strcasecmp
  1.1430 +#elif defined(HAVE__STRICMP)
  1.1431 +#define SDL_strcasecmp  _stricmp
  1.1432 +#else
  1.1433 +extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1,
  1.1434 +                                           const char *str2);
  1.1435 +#endif
  1.1436 +
  1.1437 +#ifdef HAVE_STRNCASECMP
  1.1438 +#define SDL_strncasecmp strncasecmp
  1.1439 +#elif defined(HAVE__STRNICMP)
  1.1440 +#define SDL_strncasecmp _strnicmp
  1.1441 +#else
  1.1442 +extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1,
  1.1443 +                                            const char *str2, size_t maxlen);
  1.1444 +#endif
  1.1445 +
  1.1446 +#ifdef HAVE_SSCANF
  1.1447 +#define SDL_sscanf      sscanf
  1.1448 +#else
  1.1449 +extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt,
  1.1450 +                                       ...);
  1.1451 +#endif
  1.1452 +
  1.1453 +#ifdef HAVE_SNPRINTF
  1.1454 +#define SDL_snprintf    snprintf
  1.1455 +#else
  1.1456 +extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen,
  1.1457 +                                         const char *fmt, ...);
  1.1458 +#endif
  1.1459 +
  1.1460 +#ifdef HAVE_VSNPRINTF
  1.1461 +#define SDL_vsnprintf   vsnprintf
  1.1462 +#else
  1.1463 +extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen,
  1.1464 +                                          const char *fmt, va_list ap);
  1.1465 +#endif
  1.1466 +
  1.1467 +#ifndef HAVE_M_PI
  1.1468 +#define M_PI    3.14159265358979323846264338327950288   /* pi */
  1.1469 +#endif
  1.1470 +
  1.1471 +#ifdef HAVE_CEIL
  1.1472 +#define SDL_ceil        ceil
  1.1473 +#else
  1.1474 +#define SDL_ceil(x)     ((double)(int)((x)+0.5))
  1.1475 +#endif
  1.1476 +
  1.1477 +#ifdef HAVE_COPYSIGN
  1.1478 +#define SDL_copysign    copysign
  1.1479 +#else
  1.1480 +extern DECLSPEC double SDLCALL SDL_copysign(double x, double y);
  1.1481 +#endif
  1.1482 +
  1.1483 +#ifdef HAVE_COS
  1.1484 +#define SDL_cos         cos
  1.1485 +#else
  1.1486 +extern DECLSPEC double SDLCALL SDL_cos(double x);
  1.1487 +#endif
  1.1488 +
  1.1489 +#ifdef HAVE_COSF
  1.1490 +#define SDL_cosf        cosf
  1.1491 +#else
  1.1492 +#define SDL_cosf(x) (float)SDL_cos((double)x)
  1.1493 +#endif
  1.1494 +
  1.1495 +#ifdef HAVE_FABS
  1.1496 +#define SDL_fabs        fabs
  1.1497 +#else
  1.1498 +extern DECLSPEC double SDLCALL SDL_fabs(double x);
  1.1499 +#endif
  1.1500 +
  1.1501 +#ifdef HAVE_FLOOR
  1.1502 +#define SDL_floor       floor
  1.1503 +#else
  1.1504 +extern DECLSPEC double SDLCALL SDL_floor(double x);
  1.1505 +#endif
  1.1506 +
  1.1507 +#ifdef HAVE_LOG
  1.1508 +#define SDL_log         log
  1.1509 +#else
  1.1510 +extern DECLSPEC double SDLCALL SDL_log(double x);
  1.1511 +#endif
  1.1512 +
  1.1513 +#ifdef HAVE_POW
  1.1514 +#define SDL_pow         pow
  1.1515 +#else
  1.1516 +extern DECLSPEC double SDLCALL SDL_pow(double x, double y);
  1.1517 +#endif
  1.1518 +
  1.1519 +#ifdef HAVE_SCALBN
  1.1520 +#define SDL_scalbn      scalbn
  1.1521 +#else
  1.1522 +extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n);
  1.1523 +#endif
  1.1524 +
  1.1525 +#ifdef HAVE_SIN
  1.1526 +#define SDL_sin         sin
  1.1527 +#else
  1.1528 +extern DECLSPEC double SDLCALL SDL_sin(double x);
  1.1529 +#endif
  1.1530 +
  1.1531 +#ifdef HAVE_SINF
  1.1532 +#define SDL_sinf        sinf
  1.1533 +#else
  1.1534 +#define SDL_sinf(x) (float)SDL_sin((double)x)
  1.1535 +#endif
  1.1536 +
  1.1537 +#ifdef HAVE_SQRT
  1.1538 +#define SDL_sqrt        sqrt
  1.1539 +#else
  1.1540 +extern DECLSPEC double SDLCALL SDL_sqrt(double x);
  1.1541 +#endif
  1.1542 +
  1.1543 +/* The SDL implementation of iconv() returns these error codes */
  1.1544 +#define SDL_ICONV_ERROR		(size_t)-1
  1.1545 +#define SDL_ICONV_E2BIG		(size_t)-2
  1.1546 +#define SDL_ICONV_EILSEQ	(size_t)-3
  1.1547 +#define SDL_ICONV_EINVAL	(size_t)-4
  1.1548 +
  1.1549 +#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
  1.1550 +#define SDL_iconv_t     iconv_t
  1.1551 +#define SDL_iconv_open  iconv_open
  1.1552 +#define SDL_iconv_close iconv_close
  1.1553 +#else
  1.1554 +typedef struct _SDL_iconv_t *SDL_iconv_t;
  1.1555 +extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode,
  1.1556 +                                                   const char *fromcode);
  1.1557 +extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
  1.1558 +#endif
  1.1559 +extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
  1.1560 +                                         size_t * inbytesleft, char **outbuf,
  1.1561 +                                         size_t * outbytesleft);
  1.1562 +/**
  1.1563 + *  This function converts a string between encodings in one pass, returning a
  1.1564 + *  string that must be freed with SDL_free() or NULL on error.
  1.1565 + */
  1.1566 +extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
  1.1567 +                                               const char *fromcode,
  1.1568 +                                               const char *inbuf,
  1.1569 +                                               size_t inbytesleft);
  1.1570 +#define SDL_iconv_utf8_locale(S)	SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
  1.1571 +#define SDL_iconv_utf8_ucs2(S)		(Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
  1.1572 +#define SDL_iconv_utf8_ucs4(S)		(Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
  1.1573 +
  1.1574 +/* Ends C function definitions when using C++ */
  1.1575 +#ifdef __cplusplus
  1.1576 +/* *INDENT-OFF* */
  1.1577 +}
  1.1578 +/* *INDENT-ON* */
  1.1579 +#endif
  1.1580 +#include "close_code.h"
  1.1581 +
  1.1582 +#endif /* _SDL_stdinc_h */
  1.1583 +
  1.1584 +/* vi: set ts=4 sw=4 expandtab: */