Removed spurious carriage returns
authorSam Lantinga <slouken@libsdl.org>
Sun, 22 Aug 2010 12:34:31 -0700
changeset 4761bb2e32f5a556
parent 4760 c40027ee6d47
child 4763 518d1679d2d0
Removed spurious carriage returns
include/SDL_stdinc.h
src/haptic/nds/SDL_syshaptic.c
src/joystick/nds/SDL_sysjoystick.c
src/video/win32/SDL_win32video.c
     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: */
     2.1 --- a/src/haptic/nds/SDL_syshaptic.c	Wed Aug 04 23:17:12 2010 -0400
     2.2 +++ b/src/haptic/nds/SDL_syshaptic.c	Sun Aug 22 12:34:31 2010 -0700
     2.3 @@ -43,35 +43,35 @@
     2.4  } NDS_HapticData;
     2.5  
     2.6  
     2.7 -
     2.8 void
     2.9 -NDS_EZF_OpenNorWrite() 
    2.10 +void
    2.11 +NDS_EZF_OpenNorWrite() 
    2.12  {
    2.13 -    
    2.14 GBA_BUS[0x0FF0000] = 0xD200;
    2.15 -    
    2.16 GBA_BUS[0x0000000] = 0x1500;
    2.17 -    
    2.18 GBA_BUS[0x0010000] = 0xD200;
    2.19 -    
    2.20 GBA_BUS[0x0020000] = 0x1500;
    2.21 -    
    2.22 GBA_BUS[0x0E20000] = 0x1500;
    2.23 -    
    2.24 GBA_BUS[0x0FE0000] = 0x1500;
    2.25 -
    2.26 } 
    2.27 
    2.28 
    2.29 void
    2.30 +    GBA_BUS[0x0FF0000] = 0xD200;
    2.31 +    GBA_BUS[0x0000000] = 0x1500;
    2.32 +    GBA_BUS[0x0010000] = 0xD200;
    2.33 +    GBA_BUS[0x0020000] = 0x1500;
    2.34 +    GBA_BUS[0x0E20000] = 0x1500;
    2.35 +    GBA_BUS[0x0FE0000] = 0x1500;
    2.36 +} 
    2.37 
    2.38 void
    2.39  
    2.40 -NDS_EZF_CloseNorWrite() 
    2.41 +NDS_EZF_CloseNorWrite() 
    2.42  {
    2.43 -    
    2.44 GBA_BUS[0x0FF0000] = 0xD200;
    2.45 -    
    2.46 GBA_BUS[0x0000000] = 0x1500;
    2.47 -    
    2.48 GBA_BUS[0x0010000] = 0xD200;
    2.49 -    
    2.50 GBA_BUS[0x0020000] = 0x1500;
    2.51 -    
    2.52 GBA_BUS[0x0E20000] = 0xD200;
    2.53 -    
    2.54 GBA_BUS[0x0FE0000] = 0x1500;
    2.55 -
    2.56 }
    2.57 +    GBA_BUS[0x0FF0000] = 0xD200;
    2.58 +    GBA_BUS[0x0000000] = 0x1500;
    2.59 +    GBA_BUS[0x0010000] = 0xD200;
    2.60 +    GBA_BUS[0x0020000] = 0x1500;
    2.61 +    GBA_BUS[0x0E20000] = 0xD200;
    2.62 +    GBA_BUS[0x0FE0000] = 0x1500;
    2.63 +}
    2.64  
    2.65  void
    2.66  NDS_EZF_ChipReset()
    2.67  {
    2.68 -    
    2.69 GBA_BUS[0x0000] = 0x00F0;
    2.70 -    
    2.71 GBA_BUS[0x1000] = 0x00F0;
    2.72 -} 
    2.73 uint32 NDS_EZF_IsPresent() 
    2.74 +    GBA_BUS[0x0000] = 0x00F0;
    2.75 +    GBA_BUS[0x1000] = 0x00F0;
    2.76 +} uint32 NDS_EZF_IsPresent() 
    2.77  {
    2.78 -    
    2.79 vuint16 id1, id2;
    2.80 +    vuint16 id1, id2;
    2.81  
    2.82      NDS_EZF_OpenNorWrite();
    2.83  
    2.84 @@ -81,35 +81,35 @@
    2.85      GBA_BUS[0x1555] = 0x00AA;
    2.86      GBA_BUS[0x12AA] = 0x0055;
    2.87      GBA_BUS[0x1555] = 0x0090;
    2.88 -    
    2.89 id1 = GBA_BUS[0x0001];
    2.90 -    
    2.91 id2 = GBA_BUS[0x1001];
    2.92 -    
    2.93 if ((id1 != 0x227E) || (id2 != 0x227E)) {
    2.94 +    id1 = GBA_BUS[0x0001];
    2.95 +    id2 = GBA_BUS[0x1001];
    2.96 +    if ((id1 != 0x227E) || (id2 != 0x227E)) {
    2.97          NDS_EZF_CloseNorWrite();
    2.98 -        
    2.99 return 0;
   2.100 +        return 0;
   2.101      }
   2.102 -    
   2.103 
   2.104 id1 = GBA_BUS[0x000E];
   2.105 -    
   2.106 id2 = GBA_BUS[0x100E];
   2.107 +    id1 = GBA_BUS[0x000E];
   2.108 +    id2 = GBA_BUS[0x100E];
   2.109  
   2.110      NDS_EZF_CloseNorWrite();
   2.111 -    
   2.112 if (id1 == 0x2218 && id2 == 0x2218) {
   2.113 -        
   2.114 return 1;
   2.115 +    if (id1 == 0x2218 && id2 == 0x2218) {
   2.116 +        return 1;
   2.117      }
   2.118 -    
   2.119 return 0;
   2.120 -
   2.121 }
   2.122 -
   2.123 void
   2.124 -NDS_EZF_SetShake(u8 pos) 
   2.125 +    return 0;
   2.126 +}
   2.127 +void
   2.128 +NDS_EZF_SetShake(u8 pos) 
   2.129  {
   2.130      u16 data = ((pos % 3) | 0x00F0);
   2.131 -    
   2.132 GBA_BUS[0x0FF0000] = 0xD200;
   2.133 -    
   2.134 GBA_BUS[0x0000000] = 0x1500;
   2.135 -    
   2.136 GBA_BUS[0x0010000] = 0xD200;
   2.137 -    
   2.138 GBA_BUS[0x0020000] = 0x1500;
   2.139 -    
   2.140 GBA_BUS[0x0F10000] = data;
   2.141 -    
   2.142 GBA_BUS[0x0FE0000] = 0x1500;
   2.143 +    GBA_BUS[0x0FF0000] = 0xD200;
   2.144 +    GBA_BUS[0x0000000] = 0x1500;
   2.145 +    GBA_BUS[0x0010000] = 0xD200;
   2.146 +    GBA_BUS[0x0020000] = 0x1500;
   2.147 +    GBA_BUS[0x0F10000] = data;
   2.148 +    GBA_BUS[0x0FE0000] = 0x1500;
   2.149  
   2.150      GBA_BUS[0] = 0x0000;        /* write any value for vibration. */
   2.151      GBA_BUS[0] = 0x0002;
   2.152 -
   2.153 }
   2.154 +}
   2.155  
   2.156  static int
   2.157  SDL_SYS_LogicError(void)
     3.1 --- a/src/joystick/nds/SDL_sysjoystick.c	Wed Aug 04 23:17:12 2010 -0400
     3.2 +++ b/src/joystick/nds/SDL_sysjoystick.c	Sun Aug 22 12:34:31 2010 -0700
     3.3 @@ -45,7 +45,7 @@
     3.4  SDL_SYS_JoystickInit(void)
     3.5  {
     3.6      SDL_numjoysticks = 1;
     3.7 -    
     3.8 return (1);
     3.9 +    return (1);
    3.10  }
    3.11  
    3.12  /* Function to get the device-dependent name of a joystick */
    3.13 @@ -73,7 +73,7 @@
    3.14      return 0;
    3.15  }
    3.16  
    3.17 -
    3.18 +
    3.19  /* Function to update the state of a joystick - called as a device poll.
    3.20   * This function shouldn't update the joystick structure directly,
    3.21   * but instead should call SDL_PrivateJoystick*() to deliver events
    3.22 @@ -84,8 +84,8 @@
    3.23  {
    3.24      u32 keysd, keysu;
    3.25      int magnitude = 16384;
    3.26 -    
    3.27 -        /*scanKeys(); - this is done in PumpEvents, because touch uses it too */ 
    3.28 +    
    3.29 +        /*scanKeys(); - this is done in PumpEvents, because touch uses it too */ 
    3.30          keysd = keysDown();
    3.31      keysu = keysUp();
    3.32  
    3.33 @@ -101,61 +101,61 @@
    3.34      if ((keysd & KEY_RIGHT)) {
    3.35          SDL_PrivateJoystickAxis(joystick, 0, magnitude);
    3.36      }
    3.37 -    
    3.38 if ((keysu & (KEY_UP | KEY_DOWN))) {
    3.39 +    if ((keysu & (KEY_UP | KEY_DOWN))) {
    3.40          SDL_PrivateJoystickAxis(joystick, 1, 0);
    3.41      }
    3.42 -    
    3.43 if ((keysu & (KEY_LEFT | KEY_RIGHT))) {
    3.44 +    if ((keysu & (KEY_LEFT | KEY_RIGHT))) {
    3.45          SDL_PrivateJoystickAxis(joystick, 0, 0);
    3.46      }
    3.47 -    
    3.48 if ((keysd & KEY_A)) {
    3.49 +    if ((keysd & KEY_A)) {
    3.50          SDL_PrivateJoystickButton(joystick, 0, SDL_PRESSED);
    3.51      }
    3.52 -    
    3.53 if ((keysd & KEY_B)) {
    3.54 +    if ((keysd & KEY_B)) {
    3.55          SDL_PrivateJoystickButton(joystick, 1, SDL_PRESSED);
    3.56      }
    3.57 -    
    3.58 if ((keysd & KEY_X)) {
    3.59 +    if ((keysd & KEY_X)) {
    3.60          SDL_PrivateJoystickButton(joystick, 2, SDL_PRESSED);
    3.61      }
    3.62 -    
    3.63 if ((keysd & KEY_Y)) {
    3.64 +    if ((keysd & KEY_Y)) {
    3.65          SDL_PrivateJoystickButton(joystick, 3, SDL_PRESSED);
    3.66      }
    3.67 -    
    3.68 if ((keysd & KEY_L)) {
    3.69 +    if ((keysd & KEY_L)) {
    3.70          SDL_PrivateJoystickButton(joystick, 4, SDL_PRESSED);
    3.71      }
    3.72 -    
    3.73 if ((keysd & KEY_R)) {
    3.74 +    if ((keysd & KEY_R)) {
    3.75          SDL_PrivateJoystickButton(joystick, 5, SDL_PRESSED);
    3.76      }
    3.77 -    
    3.78 if ((keysd & KEY_SELECT)) {
    3.79 +    if ((keysd & KEY_SELECT)) {
    3.80          SDL_PrivateJoystickButton(joystick, 6, SDL_PRESSED);
    3.81      }
    3.82 -    
    3.83 if ((keysd & KEY_START)) {
    3.84 +    if ((keysd & KEY_START)) {
    3.85          SDL_PrivateJoystickButton(joystick, 7, SDL_PRESSED);
    3.86      }
    3.87 -    
    3.88 if ((keysu & KEY_A)) {
    3.89 +    if ((keysu & KEY_A)) {
    3.90          SDL_PrivateJoystickButton(joystick, 0, SDL_RELEASED);
    3.91      }
    3.92 -    
    3.93 if ((keysu & KEY_B)) {
    3.94 +    if ((keysu & KEY_B)) {
    3.95          SDL_PrivateJoystickButton(joystick, 1, SDL_RELEASED);
    3.96      }
    3.97 -    
    3.98 if ((keysu & KEY_X)) {
    3.99 +    if ((keysu & KEY_X)) {
   3.100          SDL_PrivateJoystickButton(joystick, 2, SDL_RELEASED);
   3.101      }
   3.102 -    
   3.103 if ((keysu & KEY_Y)) {
   3.104 +    if ((keysu & KEY_Y)) {
   3.105          SDL_PrivateJoystickButton(joystick, 3, SDL_RELEASED);
   3.106      }
   3.107 -    
   3.108 if ((keysu & KEY_L)) {
   3.109 +    if ((keysu & KEY_L)) {
   3.110          SDL_PrivateJoystickButton(joystick, 4, SDL_RELEASED);
   3.111      }
   3.112 -    
   3.113 if ((keysu & KEY_R)) {
   3.114 +    if ((keysu & KEY_R)) {
   3.115          SDL_PrivateJoystickButton(joystick, 5, SDL_RELEASED);
   3.116      }
   3.117 -    
   3.118 if ((keysu & KEY_SELECT)) {
   3.119 +    if ((keysu & KEY_SELECT)) {
   3.120          SDL_PrivateJoystickButton(joystick, 6, SDL_RELEASED);
   3.121      }
   3.122 -    
   3.123 if ((keysu & KEY_START)) {
   3.124 +    if ((keysu & KEY_START)) {
   3.125          SDL_PrivateJoystickButton(joystick, 7, SDL_RELEASED);
   3.126      }
   3.127 -
   3.128 }
   3.129 +}
   3.130  
   3.131  /* Function to close a joystick after use */
   3.132  void
     4.1 --- a/src/video/win32/SDL_win32video.c	Wed Aug 04 23:17:12 2010 -0400
     4.2 +++ b/src/video/win32/SDL_win32video.c	Sun Aug 22 12:34:31 2010 -0700
     4.3 @@ -1,230 +1,230 @@
     4.4 -/*
     4.5 -    SDL - Simple DirectMedia Layer
     4.6 -    Copyright (C) 1997-2010 Sam Lantinga
     4.7 -
     4.8 -    This library is free software; you can redistribute it and/or
     4.9 -    modify it under the terms of the GNU Lesser General Public
    4.10 -    License as published by the Free Software Foundation; either
    4.11 -    version 2.1 of the License, or (at your option) any later version.
    4.12 -
    4.13 -    This library is distributed in the hope that it will be useful,
    4.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 -    Lesser General Public License for more details.
    4.17 -
    4.18 -    You should have received a copy of the GNU Lesser General Public
    4.19 -    License along with this library; if not, write to the Free Software
    4.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.21 -
    4.22 -    Sam Lantinga
    4.23 -    slouken@libsdl.org
    4.24 -*/
    4.25 -#include "SDL_config.h"
    4.26 -
    4.27 -#include "SDL_main.h"
    4.28 -#include "SDL_video.h"
    4.29 -#include "SDL_mouse.h"
    4.30 -#include "../SDL_sysvideo.h"
    4.31 -#include "../SDL_pixels_c.h"
    4.32 -
    4.33 -#include "SDL_win32video.h"
    4.34 -#include "SDL_d3drender.h"
    4.35 -#include "SDL_gdirender.h"
    4.36 -
    4.37 -/* Initialization/Query functions */
    4.38 -static int WIN_VideoInit(_THIS);
    4.39 -static void WIN_VideoQuit(_THIS);
    4.40 -
    4.41 -/* Sets an error message based on GetLastError() */
    4.42 -void
    4.43 -WIN_SetError(const char *prefix)
    4.44 -{
    4.45 -    TCHAR buffer[1024];
    4.46 -    char *message;
    4.47 -    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
    4.48 -                  buffer, SDL_arraysize(buffer), NULL);
    4.49 -    message = WIN_StringToUTF8(buffer);
    4.50 -    SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
    4.51 -    SDL_free(message);
    4.52 -}
    4.53 -
    4.54 -/* WIN32 driver bootstrap functions */
    4.55 -
    4.56 -static int
    4.57 -WIN_Available(void)
    4.58 -{
    4.59 -    return (1);
    4.60 -}
    4.61 -
    4.62 -static void
    4.63 -WIN_DeleteDevice(SDL_VideoDevice * device)
    4.64 -{
    4.65 -    SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
    4.66 -
    4.67 -    SDL_UnregisterApp();
    4.68 -#if SDL_VIDEO_RENDER_D3D
    4.69 -    if (data->d3d) {
    4.70 -        IDirect3D9_Release(data->d3d);
    4.71 -        FreeLibrary(data->d3dDLL);
    4.72 -    }
    4.73 -#endif
    4.74 -#if SDL_VIDEO_RENDER_DDRAW
    4.75 -    if (data->ddraw) {
    4.76 -        data->ddraw->lpVtbl->Release(data->ddraw);
    4.77 -        FreeLibrary(data->ddrawDLL);
    4.78 -    }
    4.79 -#endif
    4.80 -    SDL_free(device->driverdata);
    4.81 -    SDL_free(device);
    4.82 -}
    4.83 -
    4.84 -static SDL_VideoDevice *
    4.85 -WIN_CreateDevice(int devindex)
    4.86 -{
    4.87 -    SDL_VideoDevice *device;
    4.88 -    SDL_VideoData *data;
    4.89 -
    4.90 -    SDL_RegisterApp(NULL, 0, NULL);
    4.91 -
    4.92 -    /* Initialize all variables that we clean on shutdown */
    4.93 -    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
    4.94 -    if (device) {
    4.95 -        data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
    4.96 -    } else {
    4.97 -        data = NULL;
    4.98 -    }
    4.99 -    if (!data) {
   4.100 -        SDL_OutOfMemory();
   4.101 -        if (device) {
   4.102 -            SDL_free(device);
   4.103 -        }
   4.104 -        return NULL;
   4.105 -    }
   4.106 -    device->driverdata = data;
   4.107 -
   4.108 -#if SDL_VIDEO_RENDER_D3D
   4.109 -    data->d3dDLL = LoadLibrary(TEXT("D3D9.DLL"));
   4.110 -    if (data->d3dDLL) {
   4.111 -        IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion);
   4.112 -
   4.113 -        D3DCreate =
   4.114 -            (IDirect3D9 * (WINAPI *) (UINT)) GetProcAddress(data->d3dDLL,
   4.115 -                                                            "Direct3DCreate9");
   4.116 -        if (D3DCreate) {
   4.117 -            data->d3d = D3DCreate(D3D_SDK_VERSION);
   4.118 -        }
   4.119 -        if (!data->d3d) {
   4.120 -            FreeLibrary(data->d3dDLL);
   4.121 -            data->d3dDLL = NULL;
   4.122 -        }
   4.123 -    }
   4.124 -#endif /* SDL_VIDEO_RENDER_D3D */
   4.125 -#if SDL_VIDEO_RENDER_DDRAW
   4.126 -    data->ddrawDLL = LoadLibrary(TEXT("ddraw.dll"));
   4.127 -    if (data->ddrawDLL) {
   4.128 -        IDirectDraw *(WINAPI * DDCreate) (GUID FAR * lpGUID,
   4.129 -                                          LPDIRECTDRAW FAR * lplpDD,
   4.130 -                                          IUnknown FAR * pUnkOuter);
   4.131 -
   4.132 -        DDCreate =
   4.133 -            (IDirectDraw *
   4.134 -             (WINAPI *) (GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *))
   4.135 -            GetProcAddress(data->ddrawDLL, TEXT("DirectDrawCreate"));
   4.136 -        if (!DDCreate || DDCreate(NULL, &data->ddraw, NULL) != DD_OK) {
   4.137 -            FreeLibrary(data->ddrawDLL);
   4.138 -            data->ddrawDLL = NULL;
   4.139 -            data->ddraw = NULL;
   4.140 -        }
   4.141 -    }
   4.142 -#endif /* SDL_VIDEO_RENDER_DDRAW */
   4.143 -
   4.144 -    /* Set the function pointers */
   4.145 -    device->VideoInit = WIN_VideoInit;
   4.146 -    device->VideoQuit = WIN_VideoQuit;
   4.147 -    device->GetDisplayBounds = WIN_GetDisplayBounds;
   4.148 -    device->GetDisplayModes = WIN_GetDisplayModes;
   4.149 -    device->SetDisplayMode = WIN_SetDisplayMode;
   4.150 -    device->SetDisplayGammaRamp = WIN_SetDisplayGammaRamp;
   4.151 -    device->GetDisplayGammaRamp = WIN_GetDisplayGammaRamp;
   4.152 -    device->PumpEvents = WIN_PumpEvents;
   4.153 -
   4.154 -#undef CreateWindow
   4.155 -    device->CreateWindow = WIN_CreateWindow;
   4.156 -    device->CreateWindowFrom = WIN_CreateWindowFrom;
   4.157 -    device->SetWindowTitle = WIN_SetWindowTitle;
   4.158 -    device->SetWindowIcon = WIN_SetWindowIcon;
   4.159 -    device->SetWindowPosition = WIN_SetWindowPosition;
   4.160 -    device->SetWindowSize = WIN_SetWindowSize;
   4.161 -    device->ShowWindow = WIN_ShowWindow;
   4.162 -    device->HideWindow = WIN_HideWindow;
   4.163 -    device->RaiseWindow = WIN_RaiseWindow;
   4.164 -    device->MaximizeWindow = WIN_MaximizeWindow;
   4.165 -    device->MinimizeWindow = WIN_MinimizeWindow;
   4.166 -    device->RestoreWindow = WIN_RestoreWindow;
   4.167 -    device->SetWindowGrab = WIN_SetWindowGrab;
   4.168 -    device->DestroyWindow = WIN_DestroyWindow;
   4.169 -    device->GetWindowWMInfo = WIN_GetWindowWMInfo;
   4.170 -#ifdef SDL_VIDEO_OPENGL_WGL
   4.171 -    device->GL_LoadLibrary = WIN_GL_LoadLibrary;
   4.172 -    device->GL_GetProcAddress = WIN_GL_GetProcAddress;
   4.173 -    device->GL_UnloadLibrary = WIN_GL_UnloadLibrary;
   4.174 -    device->GL_CreateContext = WIN_GL_CreateContext;
   4.175 -    device->GL_MakeCurrent = WIN_GL_MakeCurrent;
   4.176 -    device->GL_SetSwapInterval = WIN_GL_SetSwapInterval;
   4.177 -    device->GL_GetSwapInterval = WIN_GL_GetSwapInterval;
   4.178 -    device->GL_SwapWindow = WIN_GL_SwapWindow;
   4.179 -    device->GL_DeleteContext = WIN_GL_DeleteContext;
   4.180 -#endif
   4.181 -    device->StartTextInput = WIN_StartTextInput;
   4.182 -    device->StopTextInput = WIN_StopTextInput;
   4.183 -    device->SetTextInputRect = WIN_SetTextInputRect;
   4.184 -
   4.185 -    device->SetClipboardText = WIN_SetClipboardText;
   4.186 -    device->GetClipboardText = WIN_GetClipboardText;
   4.187 -    device->HasClipboardText = WIN_HasClipboardText;
   4.188 -
   4.189 -    device->free = WIN_DeleteDevice;
   4.190 -
   4.191 -    return device;
   4.192 -}
   4.193 -
   4.194 -VideoBootStrap WIN32_bootstrap = {
   4.195 -    "win32", "SDL Win32/64 video driver", WIN_Available, WIN_CreateDevice
   4.196 -};
   4.197 -
   4.198 -
   4.199 -int
   4.200 -WIN_VideoInit(_THIS)
   4.201 -{
   4.202 -    if (WIN_InitModes(_this) < 0) {
   4.203 -        return -1;
   4.204 -    }
   4.205 -
   4.206 -#if SDL_VIDEO_RENDER_D3D
   4.207 -    D3D_AddRenderDriver(_this);
   4.208 -#endif
   4.209 -#if SDL_VIDEO_RENDER_DDRAW
   4.210 -    DDRAW_AddRenderDriver(_this);
   4.211 -#endif
   4.212 -#if SDL_VIDEO_RENDER_GDI
   4.213 -    GDI_AddRenderDriver(_this);
   4.214 -#endif
   4.215 -#if SDL_VIDEO_RENDER_GAPI
   4.216 -    GAPI_AddRenderDriver(_this);
   4.217 -#endif
   4.218 -
   4.219 -    WIN_InitKeyboard(_this);
   4.220 -    WIN_InitMouse(_this);
   4.221 -
   4.222 -    return 0;
   4.223 -}
   4.224 -
   4.225 -void
   4.226 -WIN_VideoQuit(_THIS)
   4.227 -{
   4.228 -    WIN_QuitModes(_this);
   4.229 -    WIN_QuitKeyboard(_this);
   4.230 -    WIN_QuitMouse(_this);
   4.231 -}
   4.232 -
   4.233 -/* vim: set ts=4 sw=4 expandtab: */
   4.234 +/*
   4.235 +    SDL - Simple DirectMedia Layer
   4.236 +    Copyright (C) 1997-2010 Sam Lantinga
   4.237 +
   4.238 +    This library is free software; you can redistribute it and/or
   4.239 +    modify it under the terms of the GNU Lesser General Public
   4.240 +    License as published by the Free Software Foundation; either
   4.241 +    version 2.1 of the License, or (at your option) any later version.
   4.242 +
   4.243 +    This library is distributed in the hope that it will be useful,
   4.244 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   4.245 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   4.246 +    Lesser General Public License for more details.
   4.247 +
   4.248 +    You should have received a copy of the GNU Lesser General Public
   4.249 +    License along with this library; if not, write to the Free Software
   4.250 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   4.251 +
   4.252 +    Sam Lantinga
   4.253 +    slouken@libsdl.org
   4.254 +*/
   4.255 +#include "SDL_config.h"
   4.256 +
   4.257 +#include "SDL_main.h"
   4.258 +#include "SDL_video.h"
   4.259 +#include "SDL_mouse.h"
   4.260 +#include "../SDL_sysvideo.h"
   4.261 +#include "../SDL_pixels_c.h"
   4.262 +
   4.263 +#include "SDL_win32video.h"
   4.264 +#include "SDL_d3drender.h"
   4.265 +#include "SDL_gdirender.h"
   4.266 +
   4.267 +/* Initialization/Query functions */
   4.268 +static int WIN_VideoInit(_THIS);
   4.269 +static void WIN_VideoQuit(_THIS);
   4.270 +
   4.271 +/* Sets an error message based on GetLastError() */
   4.272 +void
   4.273 +WIN_SetError(const char *prefix)
   4.274 +{
   4.275 +    TCHAR buffer[1024];
   4.276 +    char *message;
   4.277 +    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
   4.278 +                  buffer, SDL_arraysize(buffer), NULL);
   4.279 +    message = WIN_StringToUTF8(buffer);
   4.280 +    SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
   4.281 +    SDL_free(message);
   4.282 +}
   4.283 +
   4.284 +/* WIN32 driver bootstrap functions */
   4.285 +
   4.286 +static int
   4.287 +WIN_Available(void)
   4.288 +{
   4.289 +    return (1);
   4.290 +}
   4.291 +
   4.292 +static void
   4.293 +WIN_DeleteDevice(SDL_VideoDevice * device)
   4.294 +{
   4.295 +    SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
   4.296 +
   4.297 +    SDL_UnregisterApp();
   4.298 +#if SDL_VIDEO_RENDER_D3D
   4.299 +    if (data->d3d) {
   4.300 +        IDirect3D9_Release(data->d3d);
   4.301 +        FreeLibrary(data->d3dDLL);
   4.302 +    }
   4.303 +#endif
   4.304 +#if SDL_VIDEO_RENDER_DDRAW
   4.305 +    if (data->ddraw) {
   4.306 +        data->ddraw->lpVtbl->Release(data->ddraw);
   4.307 +        FreeLibrary(data->ddrawDLL);
   4.308 +    }
   4.309 +#endif
   4.310 +    SDL_free(device->driverdata);
   4.311 +    SDL_free(device);
   4.312 +}
   4.313 +
   4.314 +static SDL_VideoDevice *
   4.315 +WIN_CreateDevice(int devindex)
   4.316 +{
   4.317 +    SDL_VideoDevice *device;
   4.318 +    SDL_VideoData *data;
   4.319 +
   4.320 +    SDL_RegisterApp(NULL, 0, NULL);
   4.321 +
   4.322 +    /* Initialize all variables that we clean on shutdown */
   4.323 +    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
   4.324 +    if (device) {
   4.325 +        data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
   4.326 +    } else {
   4.327 +        data = NULL;
   4.328 +    }
   4.329 +    if (!data) {
   4.330 +        SDL_OutOfMemory();
   4.331 +        if (device) {
   4.332 +            SDL_free(device);
   4.333 +        }
   4.334 +        return NULL;
   4.335 +    }
   4.336 +    device->driverdata = data;
   4.337 +
   4.338 +#if SDL_VIDEO_RENDER_D3D
   4.339 +    data->d3dDLL = LoadLibrary(TEXT("D3D9.DLL"));
   4.340 +    if (data->d3dDLL) {
   4.341 +        IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion);
   4.342 +
   4.343 +        D3DCreate =
   4.344 +            (IDirect3D9 * (WINAPI *) (UINT)) GetProcAddress(data->d3dDLL,
   4.345 +                                                            "Direct3DCreate9");
   4.346 +        if (D3DCreate) {
   4.347 +            data->d3d = D3DCreate(D3D_SDK_VERSION);
   4.348 +        }
   4.349 +        if (!data->d3d) {
   4.350 +            FreeLibrary(data->d3dDLL);
   4.351 +            data->d3dDLL = NULL;
   4.352 +        }
   4.353 +    }
   4.354 +#endif /* SDL_VIDEO_RENDER_D3D */
   4.355 +#if SDL_VIDEO_RENDER_DDRAW
   4.356 +    data->ddrawDLL = LoadLibrary(TEXT("ddraw.dll"));
   4.357 +    if (data->ddrawDLL) {
   4.358 +        IDirectDraw *(WINAPI * DDCreate) (GUID FAR * lpGUID,
   4.359 +                                          LPDIRECTDRAW FAR * lplpDD,
   4.360 +                                          IUnknown FAR * pUnkOuter);
   4.361 +
   4.362 +        DDCreate =
   4.363 +            (IDirectDraw *
   4.364 +             (WINAPI *) (GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *))
   4.365 +            GetProcAddress(data->ddrawDLL, TEXT("DirectDrawCreate"));
   4.366 +        if (!DDCreate || DDCreate(NULL, &data->ddraw, NULL) != DD_OK) {
   4.367 +            FreeLibrary(data->ddrawDLL);
   4.368 +            data->ddrawDLL = NULL;
   4.369 +            data->ddraw = NULL;
   4.370 +        }
   4.371 +    }
   4.372 +#endif /* SDL_VIDEO_RENDER_DDRAW */
   4.373 +
   4.374 +    /* Set the function pointers */
   4.375 +    device->VideoInit = WIN_VideoInit;
   4.376 +    device->VideoQuit = WIN_VideoQuit;
   4.377 +    device->GetDisplayBounds = WIN_GetDisplayBounds;
   4.378 +    device->GetDisplayModes = WIN_GetDisplayModes;
   4.379 +    device->SetDisplayMode = WIN_SetDisplayMode;
   4.380 +    device->SetDisplayGammaRamp = WIN_SetDisplayGammaRamp;
   4.381 +    device->GetDisplayGammaRamp = WIN_GetDisplayGammaRamp;
   4.382 +    device->PumpEvents = WIN_PumpEvents;
   4.383 +
   4.384 +#undef CreateWindow
   4.385 +    device->CreateWindow = WIN_CreateWindow;
   4.386 +    device->CreateWindowFrom = WIN_CreateWindowFrom;
   4.387 +    device->SetWindowTitle = WIN_SetWindowTitle;
   4.388 +    device->SetWindowIcon = WIN_SetWindowIcon;
   4.389 +    device->SetWindowPosition = WIN_SetWindowPosition;
   4.390 +    device->SetWindowSize = WIN_SetWindowSize;
   4.391 +    device->ShowWindow = WIN_ShowWindow;
   4.392 +    device->HideWindow = WIN_HideWindow;
   4.393 +    device->RaiseWindow = WIN_RaiseWindow;
   4.394 +    device->MaximizeWindow = WIN_MaximizeWindow;
   4.395 +    device->MinimizeWindow = WIN_MinimizeWindow;
   4.396 +    device->RestoreWindow = WIN_RestoreWindow;
   4.397 +    device->SetWindowGrab = WIN_SetWindowGrab;
   4.398 +    device->DestroyWindow = WIN_DestroyWindow;
   4.399 +    device->GetWindowWMInfo = WIN_GetWindowWMInfo;
   4.400 +#ifdef SDL_VIDEO_OPENGL_WGL
   4.401 +    device->GL_LoadLibrary = WIN_GL_LoadLibrary;
   4.402 +    device->GL_GetProcAddress = WIN_GL_GetProcAddress;
   4.403 +    device->GL_UnloadLibrary = WIN_GL_UnloadLibrary;
   4.404 +    device->GL_CreateContext = WIN_GL_CreateContext;
   4.405 +    device->GL_MakeCurrent = WIN_GL_MakeCurrent;
   4.406 +    device->GL_SetSwapInterval = WIN_GL_SetSwapInterval;
   4.407 +    device->GL_GetSwapInterval = WIN_GL_GetSwapInterval;
   4.408 +    device->GL_SwapWindow = WIN_GL_SwapWindow;
   4.409 +    device->GL_DeleteContext = WIN_GL_DeleteContext;
   4.410 +#endif
   4.411 +    device->StartTextInput = WIN_StartTextInput;
   4.412 +    device->StopTextInput = WIN_StopTextInput;
   4.413 +    device->SetTextInputRect = WIN_SetTextInputRect;
   4.414 +
   4.415 +    device->SetClipboardText = WIN_SetClipboardText;
   4.416 +    device->GetClipboardText = WIN_GetClipboardText;
   4.417 +    device->HasClipboardText = WIN_HasClipboardText;
   4.418 +
   4.419 +    device->free = WIN_DeleteDevice;
   4.420 +
   4.421 +    return device;
   4.422 +}
   4.423 +
   4.424 +VideoBootStrap WIN32_bootstrap = {
   4.425 +    "win32", "SDL Win32/64 video driver", WIN_Available, WIN_CreateDevice
   4.426 +};
   4.427 +
   4.428 +
   4.429 +int
   4.430 +WIN_VideoInit(_THIS)
   4.431 +{
   4.432 +    if (WIN_InitModes(_this) < 0) {
   4.433 +        return -1;
   4.434 +    }
   4.435 +
   4.436 +#if SDL_VIDEO_RENDER_D3D
   4.437 +    D3D_AddRenderDriver(_this);
   4.438 +#endif
   4.439 +#if SDL_VIDEO_RENDER_DDRAW
   4.440 +    DDRAW_AddRenderDriver(_this);
   4.441 +#endif
   4.442 +#if SDL_VIDEO_RENDER_GDI
   4.443 +    GDI_AddRenderDriver(_this);
   4.444 +#endif
   4.445 +#if SDL_VIDEO_RENDER_GAPI
   4.446 +    GAPI_AddRenderDriver(_this);
   4.447 +#endif
   4.448 +
   4.449 +    WIN_InitKeyboard(_this);
   4.450 +    WIN_InitMouse(_this);
   4.451 +
   4.452 +    return 0;
   4.453 +}
   4.454 +
   4.455 +void
   4.456 +WIN_VideoQuit(_THIS)
   4.457 +{
   4.458 +    WIN_QuitModes(_this);
   4.459 +    WIN_QuitKeyboard(_this);
   4.460 +    WIN_QuitMouse(_this);
   4.461 +}
   4.462 +
   4.463 +/* vim: set ts=4 sw=4 expandtab: */