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