Commit 6c3f928c authored by Sam Lantinga's avatar Sam Lantinga

It's now possible to build SDL without any C runtime at all on Windows,

using Visual C++ 2005

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401334
parent 5372bfd3
No preview for this file type
...@@ -3008,6 +3008,7 @@ src/main/Makefile ...@@ -3008,6 +3008,7 @@ src/main/Makefile
src/main/macos/Makefile src/main/macos/Makefile
src/main/macosx/Makefile src/main/macosx/Makefile
src/main/macosx/Info.plist src/main/macosx/Info.plist
src/stdlib/Makefile
src/audio/Makefile src/audio/Makefile
src/audio/alsa/Makefile src/audio/alsa/Makefile
src/audio/arts/Makefile src/audio/arts/Makefile
......
...@@ -10,8 +10,10 @@ libSDLinclude_HEADERS = \ ...@@ -10,8 +10,10 @@ libSDLinclude_HEADERS = \
SDL_audio.h \ SDL_audio.h \
SDL_byteorder.h \ SDL_byteorder.h \
SDL_cdrom.h \ SDL_cdrom.h \
SDL_config.h \
SDL_copying.h \ SDL_copying.h \
SDL_cpuinfo.h \ SDL_cpuinfo.h \
SDL_ctype.h \
SDL_endian.h \ SDL_endian.h \
SDL_error.h \ SDL_error.h \
SDL_events.h \ SDL_events.h \
...@@ -27,11 +29,15 @@ libSDLinclude_HEADERS = \ ...@@ -27,11 +29,15 @@ libSDLinclude_HEADERS = \
SDL_opengl.h \ SDL_opengl.h \
SDL_quit.h \ SDL_quit.h \
SDL_rwops.h \ SDL_rwops.h \
SDL_stdarg.h \
SDL_stdlib.h \
SDL_string.h \
SDL_syswm.h \ SDL_syswm.h \
SDL_thread.h \ SDL_thread.h \
SDL_timer.h \ SDL_timer.h \
SDL_types.h \ SDL_types.h \
SDL_version.h \ SDL_version.h \
SDL_video.h \ SDL_video.h \
SDL_windows.h \
begin_code.h \ begin_code.h \
close_code.h close_code.h
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
#ifndef _SDL_audio_h #ifndef _SDL_audio_h
#define _SDL_audio_h #define _SDL_audio_h
#include <stdio.h>
#include "SDL_main.h" #include "SDL_main.h"
#include "SDL_types.h" #include "SDL_types.h"
#include "SDL_error.h" #include "SDL_error.h"
......
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifndef _SDL_config_h
#define _SDL_config_h
/* This is a set of defines to configure the SDL features */
#define HAVE_STDARG_H
/* Comment this if you want to build without any libc requirements */
#define HAVE_LIBC
#ifdef HAVE_LIBC
/* Various C library headers */
#define HAVE_CTYPE_H
#define HAVE_STDIO_H
#define HAVE_STDLIB_H
#define HAVE_MALLOC_H
#define HAVE_STRING_H
#if !defined(_WIN32_WCE)
#define HAVE_SIGNAL_H
#endif
/* Features provided by SDL_stdlib.h */
#if !defined(_WIN32) /* Don't use C runtime versions of these on Windows */
#define HAVE_GETENV
#define HAVE_PUTENV
#endif
#define HAVE_MALLOC
#define HAVE_REALLOC
#define HAVE_FREE
#define HAVE_ALLOCA
/*#define HAVE_QSORT*/
/* Features provided by SDL_string.h */
#define HAVE_MEMSET
#define HAVE_MEMCPY
#define HAVE_MEMMOVE
#define HAVE_MEMCMP
#define HAVE_STRLEN
#define HAVE_STRCPY
#define HAVE_STRNCPY
/*#define HAVE__STRREV*/
/*#define HAVE__STRUPR*/
/*#define HAVE__STRLWR*/
#define HAVE_STRCHR
#define HAVE_STRRCHR
#define HAVE_STRSTR
/*#define HAVE_ITOA*/
/*#define HAVE__LTOA*/
/*#define HAVE__UITOA*/
/*#define HAVE__ULTOA*/
/*#define HAVE_STRTOL*/
/*#define HAVE__I64TOA*/
/*#define HAVE__UI64TOA*/
/*#define HAVE_STRTOLL*/
#define HAVE_STRCMP
#define HAVE_STRNCMP
/*#define HAVE_STRICMP*/
/*#define HAVE_STRCASECMP*/
#define HAVE_SSCANF
/*#define HAVE_SNPRINTF*/
#define HAVE_VSNPRINTF
#endif /* HAVE_LIBC */
#endif /* _SDL_config_h */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/* This file contains portable character manipulation functions for SDL */
#ifndef _SDL_CTYPE_H_
#define _SDL_CTYPE_H_
#include "SDL_config.h"
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#else
#define isdigit(X) (((X) >= '0') && ((X) <= '9'))
#define isspace(X) (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n'))
#define toupper(X) (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X))
#define tolower(X) (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X))
#endif
#endif /* _SDL_CTYPE_H_ */
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
and other data sources. and other data sources.
*/ */
#include <stdio.h>
#include "SDL_types.h" #include "SDL_types.h"
#include "SDL_rwops.h" #include "SDL_rwops.h"
#include "SDL_byteorder.h" #include "SDL_byteorder.h"
......
...@@ -38,6 +38,10 @@ ...@@ -38,6 +38,10 @@
extern "C" { extern "C" {
#endif #endif
/* General keyboard/mouse state definitions */
#define SDL_RELEASED 0
#define SDL_PRESSED 1
/* Event enumerations */ /* Event enumerations */
typedef enum { typedef enum {
SDL_NOEVENT = 0, /* Unused (do not remove) */ SDL_NOEVENT = 0, /* Unused (do not remove) */
......
...@@ -23,29 +23,31 @@ ...@@ -23,29 +23,31 @@
#ifndef _SDL_getenv_h #ifndef _SDL_getenv_h
#define _SDL_getenv_h #define _SDL_getenv_h
#include "SDL_config.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* Not all environments have a working getenv()/putenv() */ #ifdef HAVE_GETENV
#define SDL_getenv getenv
#if defined(macintosh) || defined(WIN32) || defined(_WIN32_WCE) #else
#define NEED_SDL_GETENV #define getenv SDL_getenv
extern DECLSPEC char * SDLCALL SDL_getenv(const char *name);
#endif #endif
#ifdef NEED_SDL_GETENV #ifdef HAVE_PUTENV
#define SDL_putenv putenv
/* Put a variable of the form "name=value" into the environment */ #else
#define putenv SDL_putenv
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable); extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
#define putenv(X) SDL_putenv(X) #endif
/* Retrieve a variable named "name" from the environment */
extern DECLSPEC char * SDLCALL SDL_getenv(const char *name);
#define getenv(X) SDL_getenv(X)
#endif /* NEED_GETENV */
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -115,7 +115,7 @@ extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); ...@@ -115,7 +115,7 @@ extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
Button 4: Mouse wheel up (may also be a real button) Button 4: Mouse wheel up (may also be a real button)
Button 5: Mouse wheel down (may also be a real button) Button 5: Mouse wheel down (may also be a real button)
*/ */
#define SDL_BUTTON(X) (SDL_PRESSED << ((X)-1)) #define SDL_BUTTON(X) (1 << ((X)-1))
#define SDL_BUTTON_LEFT 1 #define SDL_BUTTON_LEFT 1
#define SDL_BUTTON_MIDDLE 2 #define SDL_BUTTON_MIDDLE 2
#define SDL_BUTTON_RIGHT 3 #define SDL_BUTTON_RIGHT 3
......
...@@ -27,7 +27,11 @@ ...@@ -27,7 +27,11 @@
#ifndef _SDL_RWops_h #ifndef _SDL_RWops_h
#define _SDL_RWops_h #define _SDL_RWops_h
#include "SDL_config.h"
#ifdef HAVE_STDIO_H
#include <stdio.h> #include <stdio.h>
#endif
#include "SDL_types.h" #include "SDL_types.h"
...@@ -63,10 +67,12 @@ typedef struct SDL_RWops { ...@@ -63,10 +67,12 @@ typedef struct SDL_RWops {
Uint32 type; Uint32 type;
union { union {
#ifdef HAVE_STDIO_H
struct { struct {
int autoclose; int autoclose;
FILE *fp; FILE *fp;
} stdio; } stdio;
#endif
struct { struct {
Uint8 *base; Uint8 *base;
Uint8 *here; Uint8 *here;
...@@ -84,7 +90,9 @@ typedef struct SDL_RWops { ...@@ -84,7 +90,9 @@ typedef struct SDL_RWops {
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode); extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode);
#ifdef HAVE_STDIO_H
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFP(FILE *fp, int autoclose); extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFP(FILE *fp, int autoclose);
#endif
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromMem(void *mem, int size); extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromMem(void *mem, int size);
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size); extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size);
...@@ -92,9 +100,13 @@ extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size ...@@ -92,9 +100,13 @@ extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size
extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void); extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void);
extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area); extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area);
#define RW_SEEK_SET 0 /* Seek from the beginning of data */
#define RW_SEEK_CUR 1 /* Seek relative to current read point */
#define RW_SEEK_END 2 /* Seek relative to the end of data */
/* Macros to easily read and write from an SDL_RWops structure */ /* Macros to easily read and write from an SDL_RWops structure */
#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) #define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence)
#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, SEEK_CUR) #define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR)
#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) #define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n)
#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) #define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n)
#define SDL_RWclose(ctx) (ctx)->close(ctx) #define SDL_RWclose(ctx) (ctx)->close(ctx)
......
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifndef _SDL_stdarg_h
#define _SDL_stdarg_h
#include "SDL_config.h"
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#else
#error Need stdarg.h equivalent for this platform
#endif
#endif /* _SDL_stdarg_h */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifndef _SDL_stdlib_h
#define _SDL_stdlib_h
#include "SDL_config.h"
/* AIX requires this to be the first thing in the file. */
#ifndef __GNUC__
# if HAVE_ALLOCA_H
# include <alloca.h>
# else
# ifdef _AIX
#pragma alloca
# else
# ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca ();
# endif
# endif
# endif
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#include "SDL_types.h"
#include "SDL_stdarg.h"
#include "SDL_getenv.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
#ifdef HAVE_MALLOC
#define SDL_malloc malloc
#else
#define malloc SDL_malloc
extern DECLSPEC void * SDLCALL SDL_malloc(size_t size);
#endif
#ifdef HAVE_REALLOC
#define SDL_realloc realloc
#else
#define realloc SDL_realloc
extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size);
#endif
#ifdef HAVE_FREE
#define SDL_free free
#else
#define free SDL_free
extern DECLSPEC void SDLCALL SDL_free(void *mem);
#endif
#ifdef HAVE_ALLOCA
#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*count)
#define SDL_stack_free(data)
#else
#define SDL_stack_alloc(type, count) SDL_malloc(sizeof(type)*count)
#define SDL_stack_free(data) SDL_free(data)
#endif
#ifdef HAVE_QSORT
#define SDL_qsort qsort
#else
#define qsort SDL_qsort
extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
int (*compare)(const void *, const void *));
#endif
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* _SDL_stdlib_h */
...@@ -20,19 +20,70 @@ ...@@ -20,19 +20,70 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
#ifndef _SDL_memops_h /* This file contains portable string manipulation functions for SDL */
#define _SDL_memops_h
/* System dependent optimized memory manipulation routines: #ifndef _SDL_string_h
*/ #define _SDL_string_h
#include "SDL_config.h"
#ifdef HAVE_STDIO_H
#include <stdio.h> /* For snprintf() and friends */
#endif
#ifdef HAVE_STRING_H
#include <string.h> #include <string.h>
#endif
#include "SDL_types.h"
#include "SDL_stdarg.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
#ifndef HAVE_MEMSET
#define memset SDL_memset
#endif
#ifndef SDL_memset
extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len);
#endif
#if defined(__GNUC__) && defined(i386)
#define SDL_memset4(dst, val, len) \
do { \
int u0, u1, u2; \
__asm__ __volatile__ ( \
"cld\n\t" \
"rep ; stosl\n\t" \
: "=&D" (u0), "=&a" (u1), "=&c" (u2) \
: "0" (dst), "1" (val), "2" ((Uint32)(len)) \
: "memory" ); \
} while(0)
#endif
#ifndef SDL_memset4
#define SDL_memset4(dst, val, len) \
do { \
unsigned _count = (len); \
unsigned _n = (_count + 3) / 4; \
Uint32 *_p = (Uint32 *)(dst); \
Uint32 _val = (val); \
switch (_count % 4) { \
case 0: do { *_p++ = _val; \
case 3: *_p++ = _val; \
case 2: *_p++ = _val; \
case 1: *_p++ = _val; \
} while ( --_n ); \
} \
} while(0)
#endif
#if defined(__GNUC__) && defined(i386) #if defined(__GNUC__) && defined(i386)
/* Thanks to Brennan "Bas" Underwood, for the inspiration. :)
*/
#define SDL_memcpy(dst, src, len) \ #define SDL_memcpy(dst, src, len) \
do { \ do { \
int u0, u1, u2; \ int u0, u1, u2; \
__asm__ __volatile__ ( \ __asm__ __volatile__ ( \
"cld\n\t" \ "cld\n\t" \
"rep ; movsl\n\t" \ "rep ; movsl\n\t" \
...@@ -47,7 +98,25 @@ do { \ ...@@ -47,7 +98,25 @@ do { \
: "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \ : "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \
: "memory" ); \ : "memory" ); \
} while(0) } while(0)
#define SDL_memcpy4(dst, src, len) \
do { \
int ecx, edi, esi; \
__asm__ __volatile__ ( \
"cld\n\t" \
"rep ; movsl" \
: "=&c" (ecx), "=&D" (edi), "=&S" (esi) \
: "0" ((unsigned)(len)), "1" (dst), "2" (src) \
: "memory" ); \
} while(0)
#endif
#ifndef HAVE_MEMCPY
#define memcpy SDL_memcpy
#endif
#ifndef SDL_memcpy
extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len);
#endif
#if defined(__GNUC__) && defined(i386)
#define SDL_memcpy4(dst, src, len) \ #define SDL_memcpy4(dst, src, len) \
do { \ do { \
int ecx, edi, esi; \ int ecx, edi, esi; \
...@@ -58,7 +127,12 @@ do { \ ...@@ -58,7 +127,12 @@ do { \
: "0" ((unsigned)(len)), "1" (dst), "2" (src) \ : "0" ((unsigned)(len)), "1" (dst), "2" (src) \
: "memory" ); \ : "memory" ); \
} while(0) } while(0)
#endif
#ifndef SDL_memcpy4
#define SDL_memcpy4(dst, src, len) SDL_memcpy(dst, src, (len) << 2)
#endif
#if defined(__GNUC__) && defined(i386)
#define SDL_revcpy(dst, src, len) \ #define SDL_revcpy(dst, src, len) \
do { \ do { \
int u0, u1, u2; \ int u0, u1, u2; \
...@@ -83,57 +157,203 @@ do { \ ...@@ -83,57 +157,203 @@ do { \
break; \ break; \
} \ } \
} while(0) } while(0)
#endif
#ifndef SDL_revcpy
extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len);
#endif
#ifndef HAVE_MEMMOVE
#define memmove SDL_memmove
#endif
#define SDL_memmove(dst, src, len) \ #define SDL_memmove(dst, src, len) \
do { \ do { \
if ( (dst) < (src) ) { \ if ( dst < src ) { \
SDL_memcpy((dst), (src), (len)); \ SDL_memcpy(dst, src, len); \
} else { \ } else { \
SDL_revcpy((dst), (src), (len)); \ SDL_revcpy(dst, src, len); \
} \ } \
} while(0) } while(0)
#define SDL_memset4(dst, val, len) \ #ifndef HAVE_MEMCMP
do { \ #define memcmp SDL_memcmp
int u0, u1, u2; \ #endif
__asm__ __volatile__ ( \ #ifndef SDL_memcmp
"cld\n\t" \ extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
"rep ; stosl\n\t" \ #endif
: "=&D" (u0), "=&a" (u1), "=&c" (u2) \
: "0" (dst), "1" (val), "2" ((Uint32)(len)) \
: "memory" ); \
} while(0)
#endif /* GNU C and x86 */ #ifdef HAVE_STRLEN
#define SDL_strlen strlen
#else
#define strlen SDL_strlen
extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
#endif
/* If there are no optimized versions, define the normal versions */ #ifdef HAVE_STRCPY
#ifndef SDL_memcpy #define SDL_strcpy strcpy
#define SDL_memcpy(dst, src, len) memcpy(dst, src, len) #else
#define strcpy SDL_strcpy
extern DECLSPEC char * SDLCALL SDL_strcpy(char *dst, const char *src);
#endif #endif
#ifndef SDL_memcpy4 #ifdef HAVE_STRNCPY
#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len) << 2) #define SDL_strncpy strncpy
#else
#define strncpy SDL_strncpy
extern DECLSPEC char * SDLCALL SDL_strncpy(char *dst, const char *src, size_t maxlen);
#endif #endif
#ifndef SDL_revcpy #ifdef HAVE__STRREV
#define SDL_revcpy(dst, src, len) memmove(dst, src, len) #define SDL_strrev _strrev
#else
#define _strrev SDL_strrev
extern DECLSPEC char * SDLCALL SDL_strrev(char *string);
#endif #endif
#ifndef SDL_memset4 #ifdef HAVE__STRUPR
#define SDL_memset4(dst, val, len) \ #define SDL_strupr _strupr
do { \ #else
unsigned _count = (len); \ #define _strupr SDL_strupr
unsigned _n = (_count + 3) / 4; \ extern DECLSPEC char * SDLCALL SDL_strupr(char *string);
Uint32 *_p = (Uint32 *)(dst); \ #endif
Uint32 _val = (val); \
switch (_count % 4) { \ #ifdef HAVE__STRLWR
case 0: do { *_p++ = _val; \ #define SDL_strlwr _strlwr
case 3: *_p++ = _val; \ #else
case 2: *_p++ = _val; \ #define _strlwr SDL_strlwr
case 1: *_p++ = _val; \ extern DECLSPEC char * SDLCALL SDL_strlwr(char *string);
} while ( --_n ); \ #endif
} \
} while(0) #ifdef HAVE_STRCHR
#define SDL_strchr strchr
#else
#define strchr SDL_strchr
extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c);
#endif
#ifdef HAVE_STRRCHR
#define SDL_strrchr strrchr
#else
#define strrchr SDL_strrchr
extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c);
#endif
#ifdef HAVE_STRSTR
#define SDL_strstr strstr
#else
#define strstr SDL_strstr
extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle);
#endif
#ifdef HAVE_ITOA
#define SDL_itoa itoa
#else
#define itoa SDL_itoa
#define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix)
#endif
#ifdef HAVE__LTOA
#define SDL_ltoa _ltoa
#else
#define _ltoa SDL_ltoa
extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix);
#endif
#ifdef HAVE__UITOA
#define SDL_uitoa _uitoa
#else
#define _uitoa SDL_uitoa
#define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix)
#endif
#ifdef HAVE__ULTOA
#define SDL_ultoa _ultoa
#else
#define _ultoa SDL_ultoa
extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix);
#endif
#ifdef HAVE_STRTOL
#define SDL_strtol strtol
#else
#define strtol SDL_strtol
extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base);
#endif
#ifdef SDL_HAS_64BIT_TYPE
#ifdef HAVE__I64TOA
#define SDL_lltoa _i64toa
#else
#define _i64toa SDL_lltoa
extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix);
#endif
#ifdef HAVE__UI64TOA
#define SDL_ulltoa _ui64toa
#else
#define _ui64toa SDL_ulltoa
extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix);
#endif
#ifdef HAVE_STRTOLL
#define SDL_strtoll strtoll
#else
#define strtoll SDL_strtoll
extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base);
#endif
#endif /* SDL_HAS_64BIT_TYPE */
#ifdef HAVE_STRCMP
#define SDL_strcmp strcmp
#else
#define strcmp SDL_strcmp
extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
#endif
#ifdef HAVE_STRNCMP
#define SDL_strncmp strncmp
#else
#define strncmp SDL_strncmp
extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen);
#endif
#if defined(HAVE_STRICMP) && !defined(HAVE_STRCASECMP)
#define strcasecmp stricmp
#define HAVE_STRCASECMP
#endif
#ifdef HAVE_STRCASECMP
#define SDL_strcasecmp strcasecmp
#else
#define strcasecmp SDL_strcasecmp
extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
#endif
#ifdef HAVE_SSCANF
#define SDL_sscanf sscanf
#else
#define sscanf SDL_sscanf
extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...);
#endif
#ifdef HAVE_SNPRINTF
#define SDL_snprintf snprintf
#else
#define snprintf SDL_snprintf
extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...);
#endif
#ifdef HAVE_VSNPRINTF
#define SDL_vsnprintf vsnprintf
#else
#define vsnprintf SDL_vsnprintf
extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
#endif
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif #endif
#include "close_code.h"
#endif /* _SDL_memops_h */ #endif /* _SDL_string_h */
...@@ -119,8 +119,7 @@ typedef struct SDL_SysWMinfo { ...@@ -119,8 +119,7 @@ typedef struct SDL_SysWMinfo {
} SDL_SysWMinfo; } SDL_SysWMinfo;
#elif defined(WIN32) #elif defined(WIN32)
#define WIN32_LEAN_AND_MEAN #include "SDL_windows.h"
#include <windows.h>
/* The windows custom event structure */ /* The windows custom event structure */
struct SDL_SysWMmsg { struct SDL_SysWMmsg {
......
...@@ -45,7 +45,7 @@ struct SDL_Thread; ...@@ -45,7 +45,7 @@ struct SDL_Thread;
typedef struct SDL_Thread SDL_Thread; typedef struct SDL_Thread SDL_Thread;
/* Create a thread */ /* Create a thread */
#ifdef __OS2__ #if defined(_WIN32) || defined(__OS2__)
/* /*
We compile SDL into a DLL on OS/2. This means, that it's the DLL which We compile SDL into a DLL on OS/2. This means, that it's the DLL which
creates a new thread for the calling process with the SDL_CreateThread() creates a new thread for the calling process with the SDL_CreateThread()
...@@ -53,39 +53,39 @@ typedef struct SDL_Thread SDL_Thread; ...@@ -53,39 +53,39 @@ typedef struct SDL_Thread SDL_Thread;
be initialized for those threads, and not the RTL of the calling application! be initialized for those threads, and not the RTL of the calling application!
To solve this, we make a little hack here. To solve this, we make a little hack here.
We'll always use the caller's _beginthread() and _endthread() APIs to We'll always use the caller's _beginthread() and _endthread() APIs to
start a new thread. This way, it it's the SDL.DLL which uses this API, start a new thread. This way, if it's the SDL.DLL which uses this API,
then the RTL of SDL.DLL will be used to create the new thread, and if it's then the RTL of SDL.DLL will be used to create the new thread, and if it's
the application, then the RTL of the application will be used. the application, then the RTL of the application will be used.
So, in short: So, in short:
Always use the _beginthread() and _endthread() of the calling runtime library! Always use the _beginthread() and _endthread() of the calling runtime library!
*/ */
#ifdef __WATCOMC__
#include <process.h> // This has _beginthread() and _endthread() defined! #include <process.h> // This has _beginthread() and _endthread() defined!
#endif
#ifdef __EMX__ #ifdef __EMX__
#include <stdlib.h> // This has _beginthread() and _endthread() defined, if -Zmt flag is used! #include <stdlib.h> // This has _beginthread() and _endthread() defined, if -Zmt flag is used!
#endif #endif
typedef Uint32 SDLCALL (*pfnSDL_CurrentBeginThread)(void (*pfnThreadFn)(void *), Uint32 uiStackSize, void *pParam); #ifdef __OS2__
typedef void SDLCALL (*pfnSDL_CurrentEndThread)(void); typedef int (__cdecl *pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void *arg);
typedef void (__cdecl *pfnSDL_CurrentEndThread)(void);
extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread_Core(int (*fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread); #else
#ifdef __GNUC__
// Disable warnings about unreferenced symbol! #include <stdint.h>
#pragma disable_message (202) #endif
static Uint32 SDLCALL SDL_CurrentBeginThread(void (*pfnThreadFn)(void *), Uint32 uiStackSize, void *pParam) typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
{ unsigned (__stdcall *func)(void *), void *arg,
return _beginthread(pfnThreadFn, NULL, uiStackSize, pParam); unsigned, unsigned *threadID);
} typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
#endif
static void SDLCALL SDL_CurrentEndThread(void)
{
_endthread();
}
#define SDL_CreateThread(fn, data) SDL_CreateThread_Core(fn, data, SDL_CurrentBeginThread, SDL_CurrentEndThread) extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread);
#ifdef __OS2__
#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread)
#elif defined(_WIN32_WCE)
#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL)
#else
#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex)
#endif
#else #else
extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data); extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data);
#endif #endif
......
...@@ -25,11 +25,17 @@ ...@@ -25,11 +25,17 @@
#ifndef _SDL_types_h #ifndef _SDL_types_h
#define _SDL_types_h #define _SDL_types_h
/* The number of elements in a table */ #include <sys/types.h>
#define SDL_TABLESIZE(table) (sizeof(table)/sizeof(table[0])) #ifdef _MSC_VER
#include <crtdefs.h> /* For size_t */
#endif
/* The number of elements in an array */
#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0]))
#define SDL_TABLESIZE(table) SDL_arraysize(table)
/* Basic data types */ /* Basic data types */
typedef enum { typedef enum SDL_bool {
SDL_FALSE = 0, SDL_FALSE = 0,
SDL_TRUE = 1 SDL_TRUE = 1
} SDL_bool; } SDL_bool;
...@@ -107,9 +113,4 @@ typedef enum { ...@@ -107,9 +113,4 @@ typedef enum {
SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
#undef SDL_COMPILE_TIME_ASSERT
/* General keyboard/mouse state definitions */
enum { SDL_PRESSED = 0x01, SDL_RELEASED = 0x00 };
#endif #endif
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
#ifndef _SDL_video_h #ifndef _SDL_video_h
#define _SDL_video_h #define _SDL_video_h
#include <stdio.h>
#include "SDL_types.h" #include "SDL_types.h"
#include "SDL_mutex.h" #include "SDL_mutex.h"
#include "SDL_rwops.h" #include "SDL_rwops.h"
......
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifndef _SDL_windows_h
#define _SDL_windows_h
#include "SDL_config.h"
/* This includes only the windows headers needed by SDL, with no C runtime */
#define WIN32_LEAN_AND_MEAN
#ifndef HAVE_LIBC
#ifdef _MSC_VER
#ifndef __FLTUSED__
#define __FLTUSED__
#ifdef __cplusplus
extern "C"
#endif
__declspec(selectany) int _fltused=1;
#endif
#endif /* _MSC_VER */
#define _INC_STDLIB
#define _INC_STRING
#define __STRALIGN_H_
#endif/* !HAVE_LIBC */
#include <windows.h>
#endif /* _SDL_windows_h */
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# These are the subdirectories that are always built # These are the subdirectories that are always built
CORE_SUBDIRS = \ CORE_SUBDIRS = \
main main stdlib
# These are the subdirectories which may be built # These are the subdirectories which may be built
EXTRA_SUBDIRS = \ EXTRA_SUBDIRS = \
...@@ -25,10 +25,12 @@ libSDL_la_LDFLAGS = \ ...@@ -25,10 +25,12 @@ libSDL_la_LDFLAGS = \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
libSDL_la_LIBADD = \ libSDL_la_LIBADD = \
main/libarch.la \ main/libarch.la \
stdlib/libstdlib.la \
@SDL_EXTRALIBS@ \ @SDL_EXTRALIBS@ \
@SYSTEM_LIBS@ @SYSTEM_LIBS@
libSDL_la_DEPENDENCIES = \ libSDL_la_DEPENDENCIES = \
main/libarch.la \ main/libarch.la \
stdlib/libstdlib.la \
@SDL_EXTRALIBS@ @SDL_EXTRALIBS@
# The SDL library sources # The SDL library sources
...@@ -38,6 +40,5 @@ GENERAL_SRCS = \ ...@@ -38,6 +40,5 @@ GENERAL_SRCS = \
SDL_error_c.h \ SDL_error_c.h \
SDL_fatal.c \ SDL_fatal.c \
SDL_fatal.h \ SDL_fatal.h \
SDL_getenv.c \
SDL_loadso.c SDL_loadso.c
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
/* Initialization code for SDL */ /* Initialization code for SDL */
#include <stdlib.h> /* For getenv() */
#ifdef ENABLE_PTH #ifdef ENABLE_PTH
#include <pth.h> #include <pth.h>
#endif #endif
...@@ -30,6 +29,7 @@ ...@@ -30,6 +29,7 @@
#include "SDL.h" #include "SDL.h"
#include "SDL_endian.h" #include "SDL_endian.h"
#include "SDL_fatal.h" #include "SDL_fatal.h"
#include "SDL_stdlib.h"
#ifndef DISABLE_VIDEO #ifndef DISABLE_VIDEO
#include "SDL_leaks.h" #include "SDL_leaks.h"
#endif #endif
...@@ -253,26 +253,7 @@ const SDL_version * SDL_Linked_Version(void) ...@@ -253,26 +253,7 @@ const SDL_version * SDL_Linked_Version(void)
return(&version); return(&version);
} }
#ifndef __OS2__ #if defined(__OS2__)
#if defined(_WIN32_WCE) || (defined(__WATCOMC__) && defined(BUILD_DLL))
/* Need to include DllMain() on Windows CE and Watcom C for some reason.. */
#include <windows.h>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved )
{
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
#endif /* _WIN32_WCE and building DLL with Watcom C */
#else
// Building for OS/2 // Building for OS/2
#ifdef __WATCOMC__ #ifdef __WATCOMC__
...@@ -341,6 +322,27 @@ unsigned _System LibMain(unsigned hmod, unsigned termination) ...@@ -341,6 +322,27 @@ unsigned _System LibMain(unsigned hmod, unsigned termination)
return 1; return 1;
} }
} }
#endif /* __WATCOMC__ */
#endif #elif defined(_WIN32)
#endif
#if !defined(HAVE_LIBC) || defined(_WIN32_WCE) || (defined(__WATCOMC__) && defined(BUILD_DLL))
/* Need to include DllMain() on Windows CE and Watcom C for some reason.. */
#include "SDL_windows.h"
BOOL APIENTRY _DllMainCRTStartup( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved )
{
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
#endif /* _WIN32_WCE and building DLL with Watcom C */
#endif /* OS/2 elif _WIN32 */
...@@ -22,13 +22,9 @@ ...@@ -22,13 +22,9 @@
/* Simple error handling in SDL */ /* Simple error handling in SDL */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include "SDL_types.h" #include "SDL_types.h"
#include "SDL_getenv.h" #include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_error_c.h" #include "SDL_error_c.h"
#ifndef DISABLE_THREADS #ifndef DISABLE_THREADS
...@@ -42,10 +38,6 @@ static SDL_error SDL_global_error; ...@@ -42,10 +38,6 @@ static SDL_error SDL_global_error;
#define SDL_GetErrBuf() (&SDL_global_error) #define SDL_GetErrBuf() (&SDL_global_error)
#endif /* DISABLE_THREADS */ #endif /* DISABLE_THREADS */
#ifdef __CYGWIN__
#define DISABLE_STDIO
#endif
#define SDL_ERRBUFIZE 1024 #define SDL_ERRBUFIZE 1024
/* Private functions */ /* Private functions */
...@@ -121,16 +113,10 @@ void SDL_SetError (const char *fmt, ...) ...@@ -121,16 +113,10 @@ void SDL_SetError (const char *fmt, ...)
} }
va_end(ap); va_end(ap);
#ifndef DISABLE_STDIO
/* If we are in debug mode, print out an error message */ /* If we are in debug mode, print out an error message */
#ifdef DEBUG_ERROR #ifdef DEBUG_ERROR
fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError()); fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError());
#else
if ( getenv("SDL_DEBUG") ) {
fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError());
}
#endif #endif
#endif /* !DISABLE_STDIO */
} }
/* Print out an integer value to a UNICODE buffer */ /* Print out an integer value to a UNICODE buffer */
...@@ -139,7 +125,7 @@ static int PrintInt(Uint16 *str, unsigned int maxlen, int value) ...@@ -139,7 +125,7 @@ static int PrintInt(Uint16 *str, unsigned int maxlen, int value)
char tmp[128]; char tmp[128];
int len, i; int len, i;
sprintf(tmp, "%d", value); snprintf(tmp, SDL_arraysize(tmp), "%d", value);
len = 0; len = 0;
if ( strlen(tmp) < maxlen ) { if ( strlen(tmp) < maxlen ) {
for ( i=0; tmp[i]; ++i ) { for ( i=0; tmp[i]; ++i ) {
...@@ -155,7 +141,7 @@ static int PrintDouble(Uint16 *str, unsigned int maxlen, double value) ...@@ -155,7 +141,7 @@ static int PrintDouble(Uint16 *str, unsigned int maxlen, double value)
char tmp[128]; char tmp[128];
int len, i; int len, i;
sprintf(tmp, "%f", value); snprintf(tmp, SDL_arraysize(tmp), "%f", value);
len = 0; len = 0;
if ( strlen(tmp) < maxlen ) { if ( strlen(tmp) < maxlen ) {
for ( i=0; tmp[i]; ++i ) { for ( i=0; tmp[i]; ++i ) {
...@@ -171,7 +157,7 @@ static int PrintPointer(Uint16 *str, unsigned int maxlen, void *value) ...@@ -171,7 +157,7 @@ static int PrintPointer(Uint16 *str, unsigned int maxlen, void *value)
char tmp[128]; char tmp[128];
int len, i; int len, i;
sprintf(tmp, "%p", value); snprintf(tmp, SDL_arraysize(tmp), "%p", value);
len = 0; len = 0;
if ( strlen(tmp) < maxlen ) { if ( strlen(tmp) < maxlen ) {
for ( i=0; tmp[i]; ++i ) { for ( i=0; tmp[i]; ++i ) {
......
...@@ -20,91 +20,27 @@ ...@@ -20,91 +20,27 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
#ifdef _WIN32_WCE
#define NO_SIGNAL_H
#endif
/* General fatal signal handling code for SDL */ /* General fatal signal handling code for SDL */
#ifdef NO_SIGNAL_H #include "SDL_config.h"
/* No signals on this platform, nothing to do.. */
void SDL_InstallParachute(void)
{
return;
}
void SDL_UninstallParachute(void)
{
return;
}
#else #ifdef HAVE_SIGNAL_H
#include <stdlib.h>
#include <stdio.h>
#include <signal.h> #include <signal.h>
#include <string.h>
#include "SDL.h" #include "SDL.h"
#include "SDL_fatal.h" #include "SDL_fatal.h"
#ifdef __CYGWIN__
#define DISABLE_STDIO
#endif
/* This installs some signal handlers for the more common fatal signals, /* This installs some signal handlers for the more common fatal signals,
so that if the programmer is lazy, the app doesn't die so horribly if so that if the programmer is lazy, the app doesn't die so horribly if
the program crashes. the program crashes.
*/ */
static void print_msg(const char *text)
{
#ifndef DISABLE_STDIO
fprintf(stderr, "%s", text);
#endif
}
static void SDL_Parachute(int sig) static void SDL_Parachute(int sig)
{ {
signal(sig, SIG_DFL); signal(sig, SIG_DFL);
print_msg("Fatal signal: ");
switch (sig) {
case SIGSEGV:
print_msg("Segmentation Fault");
break;
#ifdef SIGBUS
#if SIGBUS != SIGSEGV
case SIGBUS:
print_msg("Bus Error");
break;
#endif
#endif /* SIGBUS */
#ifdef SIGFPE
case SIGFPE:
print_msg("Floating Point Exception");
break;
#endif /* SIGFPE */
#ifdef SIGQUIT
case SIGQUIT:
print_msg("Keyboard Quit");
break;
#endif /* SIGQUIT */
#ifdef SIGPIPE
case SIGPIPE:
print_msg("Broken Pipe");
break;
#endif /* SIGPIPE */
default:
#ifndef DISABLE_STDIO
fprintf(stderr, "# %d", sig);
#endif
break;
}
print_msg(" (SDL Parachute Deployed)\n");
SDL_Quit(); SDL_Quit();
exit(-sig); raise(sig);
} }
static int SDL_fatal_signals[] = { static int SDL_fatal_signals[] = {
...@@ -182,4 +118,18 @@ void SDL_UninstallParachute(void) ...@@ -182,4 +118,18 @@ void SDL_UninstallParachute(void)
#endif /* HAVE_SIGACTION */ #endif /* HAVE_SIGACTION */
} }
#endif /* NO_SIGNAL_H */ #else
/* No signals on this platform, nothing to do.. */
void SDL_InstallParachute(void)
{
return;
}
void SDL_UninstallParachute(void)
{
return;
}
#endif /* HAVE_SIGNAL_H */
...@@ -21,14 +21,12 @@ ...@@ -21,14 +21,12 @@
*/ */
/* Allow access to a raw mixing buffer */ /* Allow access to a raw mixing buffer */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "SDL.h" #include "SDL.h"
#include "SDL_audio.h" #include "SDL_audio.h"
#include "SDL_timer.h" #include "SDL_timer.h"
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_string.h"
#include "SDL_audio_c.h" #include "SDL_audio_c.h"
#include "SDL_audiomem.h" #include "SDL_audiomem.h"
#include "SDL_sysaudio.h" #include "SDL_sysaudio.h"
...@@ -456,7 +454,12 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained) ...@@ -456,7 +454,12 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
D(bug("Locking semaphore...")); D(bug("Locking semaphore..."));
SDL_mutexP(audio->mixer_lock); SDL_mutexP(audio->mixer_lock);
#if (defined(_WIN32) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
#undef SDL_CreateThread
audio->thread = SDL_CreateThread(SDL_RunAudio, audio, NULL, NULL);
#else
audio->thread = SDL_CreateThread(SDL_RunAudio, audio); audio->thread = SDL_CreateThread(SDL_RunAudio, audio);
#endif
D(bug("Created thread...\n")); D(bug("Created thread...\n"));
if ( audio->thread == NULL ) { if ( audio->thread == NULL ) {
...@@ -516,7 +519,12 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained) ...@@ -516,7 +519,12 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
switch (audio->opened) { switch (audio->opened) {
case 1: case 1:
/* Start the audio thread */ /* Start the audio thread */
#if (defined(_WIN32) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
#undef SDL_CreateThread
audio->thread = SDL_CreateThread(SDL_RunAudio, audio, NULL, NULL);
#else
audio->thread = SDL_CreateThread(SDL_RunAudio, audio); audio->thread = SDL_CreateThread(SDL_RunAudio, audio);
#endif
if ( audio->thread == NULL ) { if ( audio->thread == NULL ) {
SDL_CloseAudio(); SDL_CloseAudio();
SDL_SetError("Couldn't create audio thread"); SDL_SetError("Couldn't create audio thread");
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
/* Functions for audio drivers to perform runtime conversion of audio format */ /* Functions for audio drivers to perform runtime conversion of audio format */
#include <stdio.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_audio.h" #include "SDL_audio.h"
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
(necessary because SDL audio emulates threads with fork() (necessary because SDL audio emulates threads with fork()
*/ */
#include <stdlib.h>
#ifdef FORK_HACK #ifdef FORK_HACK
#include <sys/types.h> #include <sys/types.h>
#include <sys/ipc.h> #include <sys/ipc.h>
...@@ -33,6 +32,7 @@ ...@@ -33,6 +32,7 @@
#endif #endif
#include "SDL_audiomem.h" #include "SDL_audiomem.h"
#include "SDL_stdlib.h"
/* Allocate memory that will be shared between threads (freed on exit) */ /* Allocate memory that will be shared between threads (freed on exit) */
void *SDL_AllocAudioMem(int size) void *SDL_AllocAudioMem(int size)
......
...@@ -22,10 +22,6 @@ ...@@ -22,10 +22,6 @@
/* This provides the default mixing callback for the SDL audio routines */ /* This provides the default mixing callback for the SDL audio routines */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL_audio.h" #include "SDL_audio.h"
#include "SDL_mutex.h" #include "SDL_mutex.h"
#include "SDL_timer.h" #include "SDL_timer.h"
......
#include "SDL_mixer_MMX_VC.h"
#if defined(USE_ASM_MIXER_VC) #if defined(USE_ASM_MIXER_VC)
// MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples // MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples
// Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr) // Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
...@@ -12,11 +15,6 @@ ...@@ -12,11 +15,6 @@
// Mixing for 16 bit signed buffers // Mixing for 16 bit signed buffers
//////////////////////////////////////////////// ////////////////////////////////////////////////
#ifndef __WATCOMC__
#include <windows.h>
#include <stdio.h>
#endif
void SDL_MixAudio_MMX_S16_VC(char* dst,char* src,unsigned int nSize,int volume) void SDL_MixAudio_MMX_S16_VC(char* dst,char* src,unsigned int nSize,int volume)
{ {
__asm __asm
......
#ifdef _MSC_VER
#define USE_ASM_MIXER_VC
#endif
#if defined(USE_ASM_MIXER_VC) #if defined(USE_ASM_MIXER_VC)
// headers for MMX assembler version of SDL_MixAudio // headers for MMX assembler version of SDL_MixAudio
// Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr) // Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
......
...@@ -24,17 +24,13 @@ ...@@ -24,17 +24,13 @@
/* Microsoft WAVE file loading routines */ /* Microsoft WAVE file loading routines */
#include <stdlib.h>
#include <string.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_audio.h" #include "SDL_audio.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_wave.h" #include "SDL_wave.h"
#include "SDL_endian.h" #include "SDL_endian.h"
#ifndef NELEMS
#define NELEMS(array) ((sizeof array)/(sizeof array[0]))
#endif
static int ReadChunk(SDL_RWops *src, Chunk *chunk); static int ReadChunk(SDL_RWops *src, Chunk *chunk);
...@@ -342,9 +338,9 @@ static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len) ...@@ -342,9 +338,9 @@ static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
/* Check to make sure we have enough variables in the state array */ /* Check to make sure we have enough variables in the state array */
channels = IMA_ADPCM_state.wavefmt.channels; channels = IMA_ADPCM_state.wavefmt.channels;
if ( channels > NELEMS(IMA_ADPCM_state.state) ) { if ( channels > SDL_arraysize(IMA_ADPCM_state.state) ) {
SDL_SetError("IMA ADPCM decoder can only handle %d channels", SDL_SetError("IMA ADPCM decoder can only handle %d channels",
NELEMS(IMA_ADPCM_state.state)); SDL_arraysize(IMA_ADPCM_state.state));
return(-1); return(-1);
} }
state = IMA_ADPCM_state.state; state = IMA_ADPCM_state.state;
...@@ -564,7 +560,7 @@ done: ...@@ -564,7 +560,7 @@ done:
} }
else { else {
// seek to the end of the file (given by the RIFF chunk) // seek to the end of the file (given by the RIFF chunk)
SDL_RWseek(src, wavelen - chunk.length - headerDiff, SEEK_CUR); SDL_RWseek(src, wavelen - chunk.length - headerDiff, RW_SEEK_CUR);
} }
if ( was_error ) { if ( was_error ) {
spec = NULL; spec = NULL;
......
...@@ -22,14 +22,14 @@ ...@@ -22,14 +22,14 @@
/* Allow access to a raw mixing buffer */ /* Allow access to a raw mixing buffer */
#include <stdio.h> #include "SDL_windows.h"
#include <stdlib.h>
#include <windows.h>
#include <mmsystem.h> #include <mmsystem.h>
#include "SDL_audio.h" #include "SDL_audio.h"
#include "SDL_mutex.h" #include "SDL_mutex.h"
#include "SDL_timer.h" #include "SDL_timer.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_audio_c.h" #include "SDL_audio_c.h"
#include "SDL_dibaudio.h" #include "SDL_dibaudio.h"
#if defined(_WIN32_WCE) && (_WIN32_WCE < 300) #if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
...@@ -125,7 +125,7 @@ static void SetMMerror(char *function, MMRESULT code) ...@@ -125,7 +125,7 @@ static void SetMMerror(char *function, MMRESULT code)
wchar_t werrbuf[MAXERRORLENGTH]; wchar_t werrbuf[MAXERRORLENGTH];
#endif #endif
sprintf(errbuf, "%s: ", function); snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function);
len = strlen(errbuf); len = strlen(errbuf);
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
......
...@@ -22,12 +22,12 @@ ...@@ -22,12 +22,12 @@
/* Allow access to a raw mixing buffer */ /* Allow access to a raw mixing buffer */
#include <stdio.h>
#include "SDL_types.h" #include "SDL_types.h"
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_timer.h" #include "SDL_timer.h"
#include "SDL_audio.h" #include "SDL_audio.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_audio_c.h" #include "SDL_audio_c.h"
#include "SDL_dx5audio.h" #include "SDL_dx5audio.h"
...@@ -223,12 +223,13 @@ static void SetDSerror(const char *function, int code) ...@@ -223,12 +223,13 @@ static void SetDSerror(const char *function, int code)
error = "Function not supported"; error = "Function not supported";
break; break;
default: default:
sprintf(errbuf, "%s: Unknown DirectSound error: 0x%x", snprintf(errbuf, SDL_arraysize(errbuf),
"%s: Unknown DirectSound error: 0x%x",
function, code); function, code);
break; break;
} }
if ( ! errbuf[0] ) { if ( ! errbuf[0] ) {
sprintf(errbuf, "%s: %s", function, error); snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error);
} }
SDL_SetError("%s", errbuf); SDL_SetError("%s", errbuf);
return; return;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
/* Include all of the DirectX 5.0 headers and adds any necessary tweaks */ /* Include all of the DirectX 5.0 headers and adds any necessary tweaks */
#include <windows.h> #include "SDL_windows.h"
#include <mmsystem.h> #include <mmsystem.h>
#ifndef WIN32 #ifndef WIN32
#define WIN32 #define WIN32
......
...@@ -22,12 +22,10 @@ ...@@ -22,12 +22,10 @@
/* This is the CD-audio control API for Simple DirectMedia Layer */ /* This is the CD-audio control API for Simple DirectMedia Layer */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_cdrom.h" #include "SDL_cdrom.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_syscdrom.h" #include "SDL_syscdrom.h"
#if !defined(macintosh) #if !defined(macintosh)
......
...@@ -22,13 +22,13 @@ ...@@ -22,13 +22,13 @@
/* Functions for system-level CD-ROM audio control */ /* Functions for system-level CD-ROM audio control */
#include <stdlib.h> #include "SDL_windows.h"
#include <stdio.h>
#include <windows.h>
#include <mmsystem.h> #include <mmsystem.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_cdrom.h" #include "SDL_cdrom.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_syscdrom.h" #include "SDL_syscdrom.h"
/* This really broken?? */ /* This really broken?? */
...@@ -99,7 +99,7 @@ int SDL_SYS_CDInit(void) ...@@ -99,7 +99,7 @@ int SDL_SYS_CDInit(void)
/* Scan the system for CD-ROM drives */ /* Scan the system for CD-ROM drives */
for ( i='A'; i<='Z'; ++i ) { for ( i='A'; i<='Z'; ++i ) {
sprintf(drive, "%c:\\", i); snprintf(drive, SDL_arraysize(drive), "%c:\\", i);
if ( GetDriveType(drive) == DRIVE_CDROM ) { if ( GetDriveType(drive) == DRIVE_CDROM ) {
AddDrive(drive); AddDrive(drive);
} }
......
...@@ -22,10 +22,8 @@ ...@@ -22,10 +22,8 @@
/* Application focus/iconification handling code for SDL */ /* Application focus/iconification handling code for SDL */
#include <stdio.h>
#include <string.h>
#include "SDL_events.h" #include "SDL_events.h"
#include "SDL_string.h"
#include "SDL_events_c.h" #include "SDL_events_c.h"
......
...@@ -22,13 +22,11 @@ ...@@ -22,13 +22,11 @@
/* General event handling code for SDL */ /* General event handling code for SDL */
#include <stdio.h>
#include <string.h>
#include "SDL.h" #include "SDL.h"
#include "SDL_thread.h" #include "SDL_thread.h"
#include "SDL_mutex.h" #include "SDL_mutex.h"
#include "SDL_events.h" #include "SDL_events.h"
#include "SDL_string.h"
#include "SDL_events_c.h" #include "SDL_events_c.h"
#include "SDL_timer_c.h" #include "SDL_timer_c.h"
#ifndef DISABLE_JOYSTICK #ifndef DISABLE_JOYSTICK
...@@ -177,7 +175,12 @@ static int SDL_StartEventThread(Uint32 flags) ...@@ -177,7 +175,12 @@ static int SDL_StartEventThread(Uint32 flags)
/* The event thread will handle timers too */ /* The event thread will handle timers too */
SDL_SetTimerThreaded(2); SDL_SetTimerThreaded(2);
#if (defined(_WIN32) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
#undef SDL_CreateThread
SDL_EventThread = SDL_CreateThread(SDL_GobbleEvents, NULL, NULL, NULL);
#else
SDL_EventThread = SDL_CreateThread(SDL_GobbleEvents, NULL); SDL_EventThread = SDL_CreateThread(SDL_GobbleEvents, NULL);
#endif
if ( SDL_EventThread == NULL ) { if ( SDL_EventThread == NULL ) {
return(-1); return(-1);
} }
......
...@@ -22,14 +22,10 @@ ...@@ -22,14 +22,10 @@
/* General keyboard handling code for SDL */ /* General keyboard handling code for SDL */
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_events.h" #include "SDL_events.h"
#include "SDL_timer.h" #include "SDL_timer.h"
#include "SDL_string.h"
#include "SDL_events_c.h" #include "SDL_events_c.h"
#include "SDL_sysevents.h" #include "SDL_sysevents.h"
...@@ -58,17 +54,14 @@ int SDL_KeyboardInit(void) ...@@ -58,17 +54,14 @@ int SDL_KeyboardInit(void)
{ {
SDL_VideoDevice *video = current_video; SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video; SDL_VideoDevice *this = current_video;
Uint16 i;
/* Set default mode of UNICODE translation */ /* Set default mode of UNICODE translation */
SDL_EnableUNICODE(DEFAULT_UNICODE_TRANSLATION); SDL_EnableUNICODE(DEFAULT_UNICODE_TRANSLATION);
/* Initialize the tables */ /* Initialize the tables */
SDL_ModState = KMOD_NONE; SDL_ModState = KMOD_NONE;
for ( i=0; i<SDL_TABLESIZE(keynames); ++i ) memset(keynames, 0, sizeof(keynames));
keynames[i] = NULL; memset(SDL_KeyState, 0, sizeof(SDL_KeyState));
for ( i=0; i<SDL_TABLESIZE(SDL_KeyState); ++i )
SDL_KeyState[i] = SDL_RELEASED;
video->InitOSKeymap(this); video->InitOSKeymap(this);
SDL_EnableKeyRepeat(0, 0); SDL_EnableKeyRepeat(0, 0);
......
...@@ -22,11 +22,8 @@ ...@@ -22,11 +22,8 @@
/* General mouse handling code for SDL */ /* General mouse handling code for SDL */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL_events.h" #include "SDL_events.h"
#include "SDL_string.h"
#include "SDL_events_c.h" #include "SDL_events_c.h"
#include "SDL_cursor_c.h" #include "SDL_cursor_c.h"
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
......
...@@ -22,12 +22,9 @@ ...@@ -22,12 +22,9 @@
/* General quit handling code for SDL */ /* General quit handling code for SDL */
#if defined (_WIN32_WCE) #include "SDL_config.h"
#define NO_SIGNAL_H
#endif
#include <stdio.h> #ifdef HAVE_SIGNAL_H
#ifndef NO_SIGNAL_H
#include <signal.h> #include <signal.h>
#endif #endif
...@@ -35,7 +32,7 @@ ...@@ -35,7 +32,7 @@
#include "SDL_events_c.h" #include "SDL_events_c.h"
#ifndef NO_SIGNAL_H #ifdef HAVE_SIGNAL_H
static void SDL_HandleSIG(int sig) static void SDL_HandleSIG(int sig)
{ {
/* Reset the signal handler */ /* Reset the signal handler */
...@@ -44,12 +41,12 @@ static void SDL_HandleSIG(int sig) ...@@ -44,12 +41,12 @@ static void SDL_HandleSIG(int sig)
/* Signal a quit interrupt */ /* Signal a quit interrupt */
SDL_PrivateQuit(); SDL_PrivateQuit();
} }
#endif /* NO_SIGNAL_H */ #endif /* HAVE_SIGNAL_H */
/* Public functions */ /* Public functions */
int SDL_QuitInit(void) int SDL_QuitInit(void)
{ {
#ifndef NO_SIGNAL_H #ifdef HAVE_SIGNAL_H
void (*ohandler)(int); void (*ohandler)(int);
/* Both SIGINT and SIGTERM are translated into quit interrupts */ /* Both SIGINT and SIGTERM are translated into quit interrupts */
...@@ -59,14 +56,14 @@ int SDL_QuitInit(void) ...@@ -59,14 +56,14 @@ int SDL_QuitInit(void)
ohandler = signal(SIGTERM, SDL_HandleSIG); ohandler = signal(SIGTERM, SDL_HandleSIG);
if ( ohandler != SIG_DFL ) if ( ohandler != SIG_DFL )
signal(SIGTERM, ohandler); signal(SIGTERM, ohandler);
#endif /* NO_SIGNAL_H */ #endif /* HAVE_SIGNAL_H */
/* That's it! */ /* That's it! */
return(0); return(0);
} }
void SDL_QuitQuit(void) void SDL_QuitQuit(void)
{ {
#ifndef NO_SIGNAL_H #ifdef HAVE_SIGNAL_H
void (*ohandler)(int); void (*ohandler)(int);
ohandler = signal(SIGINT, SIG_DFL); ohandler = signal(SIGINT, SIG_DFL);
...@@ -75,7 +72,7 @@ void SDL_QuitQuit(void) ...@@ -75,7 +72,7 @@ void SDL_QuitQuit(void)
ohandler = signal(SIGTERM, SIG_DFL); ohandler = signal(SIGTERM, SIG_DFL);
if ( ohandler != SDL_HandleSIG ) if ( ohandler != SDL_HandleSIG )
signal(SIGTERM, ohandler); signal(SIGTERM, ohandler);
#endif /* NO_SIGNAL_H */ #endif /* HAVE_SIGNAL_H */
} }
/* This function returns 1 if it's okay to close the application window */ /* This function returns 1 if it's okay to close the application window */
......
...@@ -24,12 +24,12 @@ ...@@ -24,12 +24,12 @@
data sources. It can easily be extended to files, memory, etc. data sources. It can easily be extended to files, memory, etc.
*/ */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_rwops.h" #include "SDL_rwops.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#ifdef HAVE_STDIO_H
/* Functions to read/write stdio file pointers */ /* Functions to read/write stdio file pointers */
...@@ -74,6 +74,8 @@ static int stdio_close(SDL_RWops *context) ...@@ -74,6 +74,8 @@ static int stdio_close(SDL_RWops *context)
return(0); return(0);
} }
#endif /* HAVE_STDIO_H */
/* Functions to read/write memory pointers */ /* Functions to read/write memory pointers */
static int mem_seek(SDL_RWops *context, int offset, int whence) static int mem_seek(SDL_RWops *context, int offset, int whence)
...@@ -81,13 +83,13 @@ static int mem_seek(SDL_RWops *context, int offset, int whence) ...@@ -81,13 +83,13 @@ static int mem_seek(SDL_RWops *context, int offset, int whence)
Uint8 *newpos; Uint8 *newpos;
switch (whence) { switch (whence) {
case SEEK_SET: case RW_SEEK_SET:
newpos = context->hidden.mem.base+offset; newpos = context->hidden.mem.base+offset;
break; break;
case SEEK_CUR: case RW_SEEK_CUR:
newpos = context->hidden.mem.here+offset; newpos = context->hidden.mem.here+offset;
break; break;
case SEEK_END: case RW_SEEK_END:
newpos = context->hidden.mem.stop+offset; newpos = context->hidden.mem.stop+offset;
break; break;
default: default:
...@@ -199,10 +201,9 @@ static char *unix_to_mac(const char *file) ...@@ -199,10 +201,9 @@ static char *unix_to_mac(const char *file)
SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
{ {
SDL_RWops *rwops = NULL;
#ifdef HAVE_STDIO_H
FILE *fp; FILE *fp;
SDL_RWops *rwops;
rwops = NULL;
#ifdef macintosh #ifdef macintosh
{ {
...@@ -224,12 +225,14 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) ...@@ -224,12 +225,14 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
rwops = SDL_RWFromFP(fp, 1); rwops = SDL_RWFromFP(fp, 1);
#endif #endif
} }
#endif /* HAVE_STDIO_H */
return(rwops); return(rwops);
} }
#ifdef HAVE_STDIO_H
SDL_RWops *SDL_RWFromFP(FILE *fp, int autoclose) SDL_RWops *SDL_RWFromFP(FILE *fp, int autoclose)
{ {
SDL_RWops *rwops; SDL_RWops *rwops = NULL;
#ifdef WIN32 #ifdef WIN32
if ( ! in_sdl ) { if ( ! in_sdl ) {
...@@ -249,6 +252,7 @@ SDL_RWops *SDL_RWFromFP(FILE *fp, int autoclose) ...@@ -249,6 +252,7 @@ SDL_RWops *SDL_RWFromFP(FILE *fp, int autoclose)
} }
return(rwops); return(rwops);
} }
#endif /* HAVE_STDIO_H */
SDL_RWops *SDL_RWFromMem(void *mem, int size) SDL_RWops *SDL_RWFromMem(void *mem, int size)
{ {
......
...@@ -22,12 +22,10 @@ ...@@ -22,12 +22,10 @@
/* This is the joystick API for Simple DirectMedia Layer */ /* This is the joystick API for Simple DirectMedia Layer */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_events.h" #include "SDL_events.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#ifndef DISABLE_EVENTS #ifndef DISABLE_EVENTS
#include "SDL_events_c.h" #include "SDL_events_c.h"
#endif #endif
......
...@@ -22,15 +22,15 @@ ...@@ -22,15 +22,15 @@
/* Win32 MultiMedia Joystick driver, contributed by Andrei de A. Formiga */ /* Win32 MultiMedia Joystick driver, contributed by Andrei de A. Formiga */
#include <stdlib.h>
#include <stdio.h> /* For the definition of NULL */
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_events.h"
#include "SDL_joystick.h" #include "SDL_joystick.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_sysjoystick.h" #include "SDL_sysjoystick.h"
#include "SDL_joystick_c.h" #include "SDL_joystick_c.h"
#include <windows.h> #include "SDL_windows.h"
#include <mmsystem.h> #include <mmsystem.h>
#include <regstr.h> #include <regstr.h>
...@@ -82,7 +82,7 @@ static char *GetJoystickName(int index, const char *szRegKey) ...@@ -82,7 +82,7 @@ static char *GetJoystickName(int index, const char *szRegKey)
unsigned char regvalue[256]; unsigned char regvalue[256];
unsigned char regname[256]; unsigned char regname[256];
sprintf((char *) regkey, "%s\\%s\\%s", snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s\\%s",
REGSTR_PATH_JOYCONFIG, REGSTR_PATH_JOYCONFIG,
szRegKey, szRegKey,
REGSTR_KEY_JOYCURR); REGSTR_KEY_JOYCURR);
...@@ -95,7 +95,7 @@ static char *GetJoystickName(int index, const char *szRegKey) ...@@ -95,7 +95,7 @@ static char *GetJoystickName(int index, const char *szRegKey)
joystick's properties joystick's properties
*/ */
regsize = sizeof(regname); regsize = sizeof(regname);
sprintf((char *) regvalue, snprintf((char *) regvalue, SDL_arraysize(regvalue),
"Joystick%d%s", index+1, "Joystick%d%s", index+1,
REGSTR_VAL_JOYOEMNAME); REGSTR_VAL_JOYOEMNAME);
regresult = RegQueryValueExA(hKey, regresult = RegQueryValueExA(hKey,
...@@ -105,7 +105,7 @@ static char *GetJoystickName(int index, const char *szRegKey) ...@@ -105,7 +105,7 @@ static char *GetJoystickName(int index, const char *szRegKey)
if (regresult == ERROR_SUCCESS) if (regresult == ERROR_SUCCESS)
{ {
/* open that registry key */ /* open that registry key */
sprintf((char *) regkey, "%s\\%s", snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s",
REGSTR_PATH_JOYOEM, regname); REGSTR_PATH_JOYOEM, regname);
regresult = RegOpenKeyExA(HKEY_LOCAL_MACHINE, regresult = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
(char *) regkey, 0, KEY_READ, &hKey); (char *) regkey, 0, KEY_READ, &hKey);
...@@ -379,7 +379,7 @@ void SDL_SYS_JoystickQuit(void) ...@@ -379,7 +379,7 @@ void SDL_SYS_JoystickQuit(void)
void SetMMerror(char *function, int code) void SetMMerror(char *function, int code)
{ {
static char *error; static char *error;
static char errbuf[BUFSIZ]; static char errbuf[1024];
errbuf[0] = 0; errbuf[0] = 0;
switch (code) switch (code)
...@@ -406,13 +406,14 @@ void SetMMerror(char *function, int code) ...@@ -406,13 +406,14 @@ void SetMMerror(char *function, int code)
break; break;
default: default:
sprintf(errbuf, "%s: Unknown Multimedia system error: 0x%x", snprintf(errbuf, SDL_arraysize(errbuf),
"%s: Unknown Multimedia system error: 0x%x",
function, code); function, code);
break; break;
} }
if ( ! errbuf[0] ) { if ( ! errbuf[0] ) {
sprintf(errbuf, "%s: %s", function, error); snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error);
} }
SDL_SetError("%s", errbuf); SDL_SetError("%s", errbuf);
} }
...@@ -31,8 +31,7 @@ ...@@ -31,8 +31,7 @@
#error Compiling for the wrong platform? #error Compiling for the wrong platform?
#endif #endif
#include <stdio.h> #include "SDL_windows.h"
#include <windows.h>
#include "SDL_types.h" #include "SDL_types.h"
#include "SDL_error.h" #include "SDL_error.h"
......
Makefile.in
Makefile
.libs
*.o
*.lo
*.la
## Makefile.am for the SDL file library
noinst_LTLIBRARIES = libstdlib.la
# Include the architecture-independent sources
COMMON_SRCS = \
SDL_getenv.c \
SDL_malloc.c \
SDL_qsort.c \
SDL_stdlib.c \
SDL_string.c
libstdlib_la_SOURCES = $(COMMON_SRCS)
...@@ -20,22 +20,14 @@ ...@@ -20,22 +20,14 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
/* Not all environments have a working getenv()/putenv() */ #include "SDL_stdlib.h"
#include "SDL_string.h"
#ifdef TEST_MAIN
#define NEED_SDL_GETENV
#endif
#include "SDL_getenv.h"
#ifdef NEED_SDL_GETENV
#if defined(WIN32) && !defined(_WIN32_WCE) #if defined(WIN32) && !defined(_WIN32_WCE)
#define WIN32_LEAN_AND_MEAN #include "SDL_windows.h"
#include <windows.h> #include "SDL_string.h"
#include <malloc.h>
#include <string.h>
/* Note this isn't thread-safe! */ /* Note this isn't thread-safe! */
...@@ -94,9 +86,6 @@ char *SDL_getenv(const char *name) ...@@ -94,9 +86,6 @@ char *SDL_getenv(const char *name)
#else /* roll our own */ #else /* roll our own */
#include <stdlib.h>
#include <string.h>
static char **SDL_env = (char **)0; static char **SDL_env = (char **)0;
/* Put a variable of the form "name=value" into the environment */ /* Put a variable of the form "name=value" into the environment */
...@@ -184,8 +173,6 @@ char *SDL_getenv(const char *name) ...@@ -184,8 +173,6 @@ char *SDL_getenv(const char *name)
#endif /* WIN32 */ #endif /* WIN32 */
#endif /* NEED_GETENV */
#ifdef TEST_MAIN #ifdef TEST_MAIN
#include <stdio.h> #include <stdio.h>
......
This diff is collapsed.
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/* This file contains portable stdlib functions for SDL */
#include "SDL_stdlib.h"
#ifndef HAVE_LIBC
/* These are some C runtime intrinsics that need to be defined */
#if defined(_MSC_VER)
/* Float to long (FIXME!) */
long _ftol2_sse()
{
return 0;
}
/* 64-bit math operators (FIXME!) */
void _allmul()
{
}
void _alldiv()
{
}
void _aulldiv()
{
}
void _allrem()
{
}
void _aullrem()
{
}
void _alldvrm()
{
}
void _aulldvrm()
{
}
void _allshl()
{
}
void _aullshr()
{
}
#endif /* MSC_VER */
#endif /* !HAVE_LIBC */
\ No newline at end of file
This diff is collapsed.
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
saves a system-dependent thread id in thread->id, and returns 0 saves a system-dependent thread id in thread->id, and returns 0
on success. on success.
*/ */
#ifdef __OS2__ #if defined(_WIN32) || defined(__OS2__)
extern int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread); extern int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread);
#else #else
extern int SDL_SYS_CreateThread(SDL_Thread *thread, void *args); extern int SDL_SYS_CreateThread(SDL_Thread *thread, void *args);
......
...@@ -22,13 +22,11 @@ ...@@ -22,13 +22,11 @@
/* System independent thread management routines for SDL */ /* System independent thread management routines for SDL */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_mutex.h" #include "SDL_mutex.h"
#include "SDL_thread.h" #include "SDL_thread.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_thread_c.h" #include "SDL_thread_c.h"
#include "SDL_systhread.h" #include "SDL_systhread.h"
...@@ -213,8 +211,9 @@ void SDL_RunThread(void *data) ...@@ -213,8 +211,9 @@ void SDL_RunThread(void *data)
*statusloc = userfunc(userdata); *statusloc = userfunc(userdata);
} }
#ifdef __OS2__ #if defined(_WIN32) || defined(__OS2__)
DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread_Core(int (*fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread) #undef SDL_CreateThread
DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
#else #else
DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data) DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data)
#endif #endif
...@@ -253,8 +252,8 @@ DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data) ...@@ -253,8 +252,8 @@ DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data)
SDL_AddThread(thread); SDL_AddThread(thread);
/* Create the thread and go! */ /* Create the thread and go! */
#ifdef __OS2__ #if defined(_WIN32) || defined(__OS2__)
ret = SDL_SYS_CreateThread(thread, args, pfnBeginThread, pfnEndThread); ret = SDL_SYS_CreateThread(thread, args, pfnBeginThread, pfnEndThread);
#else #else
ret = SDL_SYS_CreateThread(thread, args); ret = SDL_SYS_CreateThread(thread, args);
#endif #endif
......
...@@ -26,11 +26,9 @@ ...@@ -26,11 +26,9 @@
implementation, written by Christopher Tate and Owen Smith. Thanks! implementation, written by Christopher Tate and Owen Smith. Thanks!
*/ */
#include <stdio.h>
#include <stdlib.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_thread.h" #include "SDL_thread.h"
#include "SDL_stdlib.h"
struct SDL_cond struct SDL_cond
{ {
......
...@@ -22,11 +22,9 @@ ...@@ -22,11 +22,9 @@
/* An implementation of mutexes using semaphores */ /* An implementation of mutexes using semaphores */
#include <stdio.h>
#include <stdlib.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_thread.h" #include "SDL_thread.h"
#include "SDL_stdlib.h"
#include "SDL_systhread_c.h" #include "SDL_systhread_c.h"
......
...@@ -22,11 +22,10 @@ ...@@ -22,11 +22,10 @@
/* An implementation of semaphores using mutexes and condition variables */ /* An implementation of semaphores using mutexes and condition variables */
#include <stdlib.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_timer.h" #include "SDL_timer.h"
#include "SDL_thread.h" #include "SDL_thread.h"
#include "SDL_stdlib.h"
#include "SDL_systhread_c.h" #include "SDL_systhread_c.h"
......
...@@ -72,7 +72,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThre ...@@ -72,7 +72,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThre
// Also save the real parameters we have to pass to thread function // Also save the real parameters we have to pass to thread function
pThreadParms->args = args; pThreadParms->args = args;
// Start the thread using the runtime library of calling app! // Start the thread using the runtime library of calling app!
thread->threadid = thread->handle = (*pfnBeginThread)(threadfunc, 512*1024, pThreadParms); thread->threadid = thread->handle = (*pfnBeginThread)(threadfunc, NULL, 512*1024, pThreadParms);
if (thread->threadid<=0) if (thread->threadid<=0)
{ {
SDL_SetError("Not enough resources to create thread"); SDL_SetError("Not enough resources to create thread");
......
...@@ -22,12 +22,11 @@ ...@@ -22,12 +22,11 @@
/* Mutex functions using the Win32 API */ /* Mutex functions using the Win32 API */
#include <stdio.h> #include "SDL_windows.h"
#include <stdlib.h>
#include <windows.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_mutex.h" #include "SDL_mutex.h"
#include "SDL_stdlib.h"
struct SDL_mutex { struct SDL_mutex {
......
...@@ -22,12 +22,11 @@ ...@@ -22,12 +22,11 @@
/* Semaphore functions using the Win32 API */ /* Semaphore functions using the Win32 API */
#include <stdio.h> #include "SDL_windows.h"
#include <stdlib.h>
#include <windows.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_thread.h" #include "SDL_thread.h"
#include "SDL_stdlib.h"
#if defined(_WIN32_WCE) && (_WIN32_WCE < 300) #if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
#include "win_ce_semaphore.h" #include "win_ce_semaphore.h"
#endif #endif
......
...@@ -22,43 +22,59 @@ ...@@ -22,43 +22,59 @@
/* Win32 thread management routines for SDL */ /* Win32 thread management routines for SDL */
#include <stdio.h> #include "SDL_windows.h"
#include <stdlib.h>
#include <windows.h>
#ifndef _WIN32_WCE
#include <process.h>
#endif
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_thread.h" #include "SDL_thread.h"
#include "SDL_stdlib.h"
#include "SDL_systhread.h" #include "SDL_systhread.h"
typedef struct ThreadStartParms
{
void *args;
pfnSDL_CurrentEndThread pfnCurrentEndThread;
} tThreadStartParms, *pThreadStartParms;
static unsigned __stdcall RunThread(void *data) static unsigned __stdcall RunThread(void *data)
{ {
SDL_RunThread(data); pThreadStartParms pThreadParms = (pThreadStartParms)data;
return(0); pfnSDL_CurrentEndThread pfnCurrentEndThread = NULL;
// Call the thread function!
SDL_RunThread(pThreadParms->args);
// Get the current endthread we have to use!
if (pThreadParms)
{
pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread;
free(pThreadParms);
}
// Call endthread!
if (pfnCurrentEndThread)
(*pfnCurrentEndThread)(0);
return(0);
} }
int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
{ {
unsigned threadid; unsigned threadid;
pThreadStartParms pThreadParms = (pThreadStartParms)malloc(sizeof(tThreadStartParms));
/* if (!pThreadParms) {
* Avoid CreateThread: https://bugzilla.libsdl.org/show_bug.cgi?id=22 SDL_OutOfMemory();
* return(-1);
* have to use _beginthreadex if we want the returned handle }
* to be accessible after the thread exits
* threads created with _beginthread auto-close the handle // Save the function which we will have to call to clear the RTL of calling app!
* Windows CE still use CreateThread. pThreadParms->pfnCurrentEndThread = pfnEndThread;
*/ // Also save the real parameters we have to pass to thread function
#ifdef _WIN32_WCE pThreadParms->args = args;
thread->handle = CreateThread(NULL, 0, RunThread, args, 0, &threadid);
#else if (pfnBeginThread) {
thread->handle = (SYS_ThreadHandle) _beginthreadex(NULL, 0, RunThread, thread->handle = (SYS_ThreadHandle) pfnBeginThread(NULL, 0, RunThread,
args, 0, &threadid); pThreadParms, 0, &threadid);
#endif } else {
thread->handle = CreateThread(NULL, 0, RunThread, pThreadParms, 0, &threadid);
}
if (thread->handle == NULL) { if (thread->handle == NULL) {
SDL_SetError("Not enough resources to create thread"); SDL_SetError("Not enough resources to create thread");
return(-1); return(-1);
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
#include <windows.h> #include "SDL_windows.h"
typedef HANDLE SYS_ThreadHandle; typedef HANDLE SYS_ThreadHandle;
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
and it is not clear how to handle a mixture of WCE semaphores and normal and it is not clear how to handle a mixture of WCE semaphores and normal
events and mutexes. */ events and mutexes. */
#include <windows.h> #include "SDL_windows.h"
#include "win_ce_semaphore.h" #include "win_ce_semaphore.h"
static SYNCHHANDLE CleanUp (SYNCHHANDLE hSynch, DWORD Flags); static SYNCHHANDLE CleanUp (SYNCHHANDLE hSynch, DWORD Flags);
......
...@@ -20,11 +20,9 @@ ...@@ -20,11 +20,9 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
#include <stdlib.h>
#include <stdio.h> /* For the definition of NULL */
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_timer.h" #include "SDL_timer.h"
#include "SDL_stdlib.h"
#include "SDL_timer_c.h" #include "SDL_timer_c.h"
#include "SDL_mutex.h" #include "SDL_mutex.h"
#include "SDL_systimer.h" #include "SDL_systimer.h"
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
#include <windows.h> #include "SDL_windows.h"
#include <mmsystem.h> #include <mmsystem.h>
#include "SDL_timer.h" #include "SDL_timer.h"
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
#include <windows.h> #include "SDL_windows.h"
#include <mmsystem.h> #include <mmsystem.h>
#include "SDL_timer.h" #include "SDL_timer.h"
......
...@@ -30,7 +30,6 @@ COMMON_SRCS = \ ...@@ -30,7 +30,6 @@ COMMON_SRCS = \
SDL_gamma.c \ SDL_gamma.c \
SDL_glfuncs.h \ SDL_glfuncs.h \
SDL_leaks.h \ SDL_leaks.h \
SDL_memops.h \
SDL_pixels.c \ SDL_pixels.c \
SDL_pixels_c.h \ SDL_pixels_c.h \
SDL_surface.c \ SDL_surface.c \
...@@ -44,6 +43,10 @@ COMMON_SRCS = \ ...@@ -44,6 +43,10 @@ COMMON_SRCS = \
SDL_yuv_sw_c.h \ SDL_yuv_sw_c.h \
SDL_yuv_mmx.c \ SDL_yuv_mmx.c \
mmx.h \ mmx.h \
math_private.h \
e_log.h \
e_pow.h \
e_sqrt.h \
blank_cursor.h \ blank_cursor.h \
default_cursor.h default_cursor.h
......
...@@ -85,16 +85,13 @@ ...@@ -85,16 +85,13 @@
* beginning of an opaque line. * beginning of an opaque line.
*/ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL_types.h" #include "SDL_types.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
#include "SDL_blit.h" #include "SDL_blit.h"
#include "SDL_memops.h"
#include "SDL_RLEaccel_c.h" #include "SDL_RLEaccel_c.h"
#if (defined(i386) || defined(__x86_64__)) && defined(__GNUC__) && defined(USE_ASMBLIT) #if (defined(i386) || defined(__x86_64__)) && defined(__GNUC__) && defined(USE_ASMBLIT)
......
...@@ -20,17 +20,13 @@ ...@@ -20,17 +20,13 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_string.h"
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
#include "SDL_blit.h" #include "SDL_blit.h"
#include "SDL_RLEaccel_c.h" #include "SDL_RLEaccel_c.h"
#include "SDL_pixels_c.h" #include "SDL_pixels_c.h"
#include "SDL_memops.h"
#if (defined(i386) || defined(__x86_64__)) && defined(__GNUC__) && defined(USE_ASMBLIT) #if (defined(i386) || defined(__x86_64__)) && defined(__GNUC__) && defined(USE_ASMBLIT)
#define MMX_ASMBLIT #define MMX_ASMBLIT
......
...@@ -20,11 +20,9 @@ ...@@ -20,11 +20,9 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
#include <stdio.h>
#include <string.h>
#include "SDL_types.h" #include "SDL_types.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_string.h"
#include "SDL_blit.h" #include "SDL_blit.h"
/* Functions to blit from bitmaps to other surfaces */ /* Functions to blit from bitmaps to other surfaces */
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
#include <stdio.h>
#include "SDL_types.h" #include "SDL_types.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_blit.h" #include "SDL_blit.h"
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
#include <stdio.h>
#include "SDL_types.h" #include "SDL_types.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_blit.h" #include "SDL_blit.h"
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
#include <stdio.h>
#include "SDL_types.h" #include "SDL_types.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_blit.h" #include "SDL_blit.h"
......
...@@ -34,11 +34,10 @@ ...@@ -34,11 +34,10 @@
This code currently supports Win32 DIBs in uncompressed 8 and 24 bpp. This code currently supports Win32 DIBs in uncompressed 8 and 24 bpp.
*/ */
#include <string.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_endian.h" #include "SDL_endian.h"
#include "SDL_string.h"
/* Compression encodings for BMP files */ /* Compression encodings for BMP files */
#ifndef BI_RGB #ifndef BI_RGB
...@@ -238,7 +237,7 @@ SDL_Surface * SDL_LoadBMP_RW (SDL_RWops *src, int freesrc) ...@@ -238,7 +237,7 @@ SDL_Surface * SDL_LoadBMP_RW (SDL_RWops *src, int freesrc)
} }
/* Read the surface pixels. Note that the bmp image is upside down */ /* Read the surface pixels. Note that the bmp image is upside down */
if ( SDL_RWseek(src, fp_offset+bfOffBits, SEEK_SET) < 0 ) { if ( SDL_RWseek(src, fp_offset+bfOffBits, RW_SEEK_SET) < 0 ) {
SDL_Error(SDL_EFSEEK); SDL_Error(SDL_EFSEEK);
was_error = 1; was_error = 1;
goto done; goto done;
...@@ -319,7 +318,7 @@ SDL_Surface * SDL_LoadBMP_RW (SDL_RWops *src, int freesrc) ...@@ -319,7 +318,7 @@ SDL_Surface * SDL_LoadBMP_RW (SDL_RWops *src, int freesrc)
done: done:
if ( was_error ) { if ( was_error ) {
if ( src ) { if ( src ) {
SDL_RWseek(src, fp_offset, SEEK_SET); SDL_RWseek(src, fp_offset, RW_SEEK_SET);
} }
if ( surface ) { if ( surface ) {
SDL_FreeSurface(surface); SDL_FreeSurface(surface);
...@@ -475,11 +474,11 @@ int SDL_SaveBMP_RW (SDL_Surface *saveme, SDL_RWops *dst, int freedst) ...@@ -475,11 +474,11 @@ int SDL_SaveBMP_RW (SDL_Surface *saveme, SDL_RWops *dst, int freedst)
/* Write the bitmap offset */ /* Write the bitmap offset */
bfOffBits = SDL_RWtell(dst)-fp_offset; bfOffBits = SDL_RWtell(dst)-fp_offset;
if ( SDL_RWseek(dst, fp_offset+10, SEEK_SET) < 0 ) { if ( SDL_RWseek(dst, fp_offset+10, RW_SEEK_SET) < 0 ) {
SDL_Error(SDL_EFSEEK); SDL_Error(SDL_EFSEEK);
} }
SDL_WriteLE32(dst, bfOffBits); SDL_WriteLE32(dst, bfOffBits);
if ( SDL_RWseek(dst, fp_offset+bfOffBits, SEEK_SET) < 0 ) { if ( SDL_RWseek(dst, fp_offset+bfOffBits, RW_SEEK_SET) < 0 ) {
SDL_Error(SDL_EFSEEK); SDL_Error(SDL_EFSEEK);
} }
...@@ -502,11 +501,11 @@ int SDL_SaveBMP_RW (SDL_Surface *saveme, SDL_RWops *dst, int freedst) ...@@ -502,11 +501,11 @@ int SDL_SaveBMP_RW (SDL_Surface *saveme, SDL_RWops *dst, int freedst)
/* Write the BMP file size */ /* Write the BMP file size */
bfSize = SDL_RWtell(dst)-fp_offset; bfSize = SDL_RWtell(dst)-fp_offset;
if ( SDL_RWseek(dst, fp_offset+2, SEEK_SET) < 0 ) { if ( SDL_RWseek(dst, fp_offset+2, RW_SEEK_SET) < 0 ) {
SDL_Error(SDL_EFSEEK); SDL_Error(SDL_EFSEEK);
} }
SDL_WriteLE32(dst, bfSize); SDL_WriteLE32(dst, bfSize);
if ( SDL_RWseek(dst, fp_offset+bfSize, SEEK_SET) < 0 ) { if ( SDL_RWseek(dst, fp_offset+bfSize, RW_SEEK_SET) < 0 ) {
SDL_Error(SDL_EFSEEK); SDL_Error(SDL_EFSEEK);
} }
......
...@@ -22,14 +22,12 @@ ...@@ -22,14 +22,12 @@
/* General cursor handling code for SDL */ /* General cursor handling code for SDL */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL_mutex.h" #include "SDL_mutex.h"
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_mouse.h" #include "SDL_mouse.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_blit.h" #include "SDL_blit.h"
#include "SDL_events_c.h" #include "SDL_events_c.h"
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
......
...@@ -22,18 +22,26 @@ ...@@ -22,18 +22,26 @@
/* Gamma correction support */ /* Gamma correction support */
#define USE_MATH_H /* Used for calculating gamma ramps */ #include "SDL_config.h"
#ifdef USE_MATH_H #ifdef HAVE_MATH_H
#include <math.h> #include <math.h> /* Used for calculating gamma ramps */
#endif #endif
#include <stdlib.h>
#include <string.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
#ifdef USE_MATH_H #ifndef HAVE_MATH_H
#include "math_private.h"
#include "e_sqrt.h"
#include "e_pow.h"
#include "e_log.h"
#define pow(x, y) __ieee754_pow(x, y)
#define log(x) __ieee754_log(x)
#endif
static void CalculateGammaRamp(float gamma, Uint16 *ramp) static void CalculateGammaRamp(float gamma, Uint16 *ramp)
{ {
int i; int i;
...@@ -85,7 +93,6 @@ static void CalculateGammaFromRamp(float *gamma, Uint16 *ramp) ...@@ -85,7 +93,6 @@ static void CalculateGammaFromRamp(float *gamma, Uint16 *ramp)
*gamma = 1.0f / (sum / count); *gamma = 1.0f / (sum / count);
} }
} }
#endif /* USE_MATH_H */
int SDL_SetGamma(float red, float green, float blue) int SDL_SetGamma(float red, float green, float blue)
{ {
...@@ -94,7 +101,6 @@ int SDL_SetGamma(float red, float green, float blue) ...@@ -94,7 +101,6 @@ int SDL_SetGamma(float red, float green, float blue)
SDL_VideoDevice *this = current_video; SDL_VideoDevice *this = current_video;
succeeded = -1; succeeded = -1;
#ifdef USE_MATH_H
/* Prefer using SetGammaRamp(), as it's more flexible */ /* Prefer using SetGammaRamp(), as it's more flexible */
{ {
Uint16 ramp[3][256]; Uint16 ramp[3][256];
...@@ -104,9 +110,6 @@ int SDL_SetGamma(float red, float green, float blue) ...@@ -104,9 +110,6 @@ int SDL_SetGamma(float red, float green, float blue)
CalculateGammaRamp(blue, ramp[2]); CalculateGammaRamp(blue, ramp[2]);
succeeded = SDL_SetGammaRamp(ramp[0], ramp[1], ramp[2]); succeeded = SDL_SetGammaRamp(ramp[0], ramp[1], ramp[2]);
} }
#else
SDL_SetError("Gamma correction not supported");
#endif
if ( (succeeded < 0) && video->SetGamma ) { if ( (succeeded < 0) && video->SetGamma ) {
SDL_ClearError(); SDL_ClearError();
succeeded = video->SetGamma(this, red, green, blue); succeeded = video->SetGamma(this, red, green, blue);
...@@ -124,7 +127,6 @@ int SDL_GetGamma(float *red, float *green, float *blue) ...@@ -124,7 +127,6 @@ int SDL_GetGamma(float *red, float *green, float *blue)
SDL_VideoDevice *this = current_video; SDL_VideoDevice *this = current_video;
succeeded = -1; succeeded = -1;
#ifdef USE_MATH_H
/* Prefer using GetGammaRamp(), as it's more flexible */ /* Prefer using GetGammaRamp(), as it's more flexible */
{ {
Uint16 ramp[3][256]; Uint16 ramp[3][256];
...@@ -136,9 +138,6 @@ int SDL_GetGamma(float *red, float *green, float *blue) ...@@ -136,9 +138,6 @@ int SDL_GetGamma(float *red, float *green, float *blue)
CalculateGammaFromRamp(blue, ramp[2]); CalculateGammaFromRamp(blue, ramp[2]);
} }
} }
#else
SDL_SetError("Gamma correction not supported");
#endif
if ( (succeeded < 0) && video->GetGamma ) { if ( (succeeded < 0) && video->GetGamma ) {
SDL_ClearError(); SDL_ClearError();
succeeded = video->GetGamma(this, red, green, blue); succeeded = video->GetGamma(this, red, green, blue);
......
...@@ -22,13 +22,11 @@ ...@@ -22,13 +22,11 @@
/* General (mostly internal) pixel/color manipulation routines for SDL */ /* General (mostly internal) pixel/color manipulation routines for SDL */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_endian.h" #include "SDL_endian.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
#include "SDL_blit.h" #include "SDL_blit.h"
#include "SDL_pixels_c.h" #include "SDL_pixels_c.h"
......
...@@ -20,18 +20,15 @@ ...@@ -20,18 +20,15 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
#include "SDL_cursor_c.h" #include "SDL_cursor_c.h"
#include "SDL_blit.h" #include "SDL_blit.h"
#include "SDL_RLEaccel_c.h" #include "SDL_RLEaccel_c.h"
#include "SDL_pixels_c.h" #include "SDL_pixels_c.h"
#include "SDL_memops.h"
#include "SDL_leaks.h" #include "SDL_leaks.h"
......
...@@ -37,8 +37,7 @@ ...@@ -37,8 +37,7 @@
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
#define HAVE_OPENGL #define HAVE_OPENGL
#endif #endif
#define WIN32_LEAN_AND_MEAN #include "SDL_windows.h"
#include <windows.h>
#endif #endif
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
......
...@@ -22,15 +22,13 @@ ...@@ -22,15 +22,13 @@
/* The high-level video driver subsystem */ /* The high-level video driver subsystem */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL.h" #include "SDL.h"
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_events.h" #include "SDL_events.h"
#include "SDL_mutex.h" #include "SDL_mutex.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
#include "SDL_sysevents.h" #include "SDL_sysevents.h"
#include "SDL_blit.h" #include "SDL_blit.h"
......
...@@ -22,12 +22,9 @@ ...@@ -22,12 +22,9 @@
/* This is the implementation of the YUV video surface support */ /* This is the implementation of the YUV video surface support */
#include <stdlib.h>
#include <string.h>
#include "SDL_getenv.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_stdlib.h"
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
#include "SDL_yuvfuncs.h" #include "SDL_yuvfuncs.h"
#include "SDL_yuv_sw_c.h" #include "SDL_yuv_sw_c.h"
...@@ -57,7 +54,7 @@ SDL_Overlay *SDL_CreateYUVOverlay(int w, int h, Uint32 format, ...@@ -57,7 +54,7 @@ SDL_Overlay *SDL_CreateYUVOverlay(int w, int h, Uint32 format,
overlay = NULL; overlay = NULL;
yuv_hwaccel = getenv("SDL_VIDEO_YUV_HWACCEL"); yuv_hwaccel = getenv("SDL_VIDEO_YUV_HWACCEL");
if ( ((display == SDL_VideoSurface) && video->CreateYUVOverlay) && if ( ((display == SDL_VideoSurface) && video->CreateYUVOverlay) &&
(!yuv_hwaccel || (atoi(yuv_hwaccel) > 0)) ) { (!yuv_hwaccel || (*yuv_hwaccel != '0')) ) {
overlay = video->CreateYUVOverlay(this, w, h, format, display); overlay = video->CreateYUVOverlay(this, w, h, format, display);
} }
/* If hardware YUV overlay failed ... */ /* If hardware YUV overlay failed ... */
......
...@@ -82,12 +82,11 @@ ...@@ -82,12 +82,11 @@
* SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/ */
#include <stdlib.h>
#include <string.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_cpuinfo.h" #include "SDL_cpuinfo.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_stretch_c.h" #include "SDL_stretch_c.h"
#include "SDL_yuvfuncs.h" #include "SDL_yuvfuncs.h"
#include "SDL_yuv_sw_c.h" #include "SDL_yuv_sw_c.h"
......
/* @(#)e_log.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#if defined(LIBM_SCCS) && !defined(lint)
static char rcsid[] = "$NetBSD: e_log.c,v 1.8 1995/05/10 20:45:49 jtc Exp $";
#endif
/* __ieee754_log(x)
* Return the logrithm of x
*
* Method :
* 1. Argument Reduction: find k and f such that
* x = 2^k * (1+f),
* where sqrt(2)/2 < 1+f < sqrt(2) .
*
* 2. Approximation of log(1+f).
* Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
* = 2s + 2/3 s**3 + 2/5 s**5 + .....,
* = 2s + s*R
* We use a special Reme algorithm on [0,0.1716] to generate
* a polynomial of degree 14 to approximate R The maximum error
* of this polynomial approximation is bounded by 2**-58.45. In
* other words,
* 2 4 6 8 10 12 14
* R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s
* (the values of Lg1 to Lg7 are listed in the program)
* and
* | 2 14 | -58.45
* | Lg1*s +...+Lg7*s - R(z) | <= 2
* | |
* Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
* In order to guarantee error in log below 1ulp, we compute log
* by
* log(1+f) = f - s*(f - R) (if f is not too large)
* log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy)
*
* 3. Finally, log(x) = k*ln2 + log(1+f).
* = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
* Here ln2 is split into two floating point number:
* ln2_hi + ln2_lo,
* where n*ln2_hi is always exact for |n| < 2000.
*
* Special cases:
* log(x) is NaN with signal if x < 0 (including -INF) ;
* log(+INF) is +INF; log(0) is -INF with signal;
* log(NaN) is that NaN with no signal.
*
* Accuracy:
* according to an error analysis, the error is always less than
* 1 ulp (unit in the last place).
*
* Constants:
* The hexadecimal values are the intended ones for the following
* constants. The decimal values may be used, provided that the
* compiler will convert from decimal to binary accurately enough
* to produce the hexadecimal values shown.
*/
/*#include "math.h"*/
#include "math_private.h"
#ifdef __STDC__
static const double
#else
static double
#endif
ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */
ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */
Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */
Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */
Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */
Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */
Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
#ifdef __STDC__
double __ieee754_log(double x)
#else
double __ieee754_log(x)
double x;
#endif
{
double hfsq,f,s,z,R,w,t1,t2,dk;
int32_t k,hx,i,j;
u_int32_t lx;
EXTRACT_WORDS(hx,lx,x);
k=0;
if (hx < 0x00100000) { /* x < 2**-1022 */
if (((hx&0x7fffffff)|lx)==0)
return -two54/zero; /* log(+-0)=-inf */
if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
k -= 54; x *= two54; /* subnormal number, scale up x */
GET_HIGH_WORD(hx,x);
}
if (hx >= 0x7ff00000) return x+x;
k += (hx>>20)-1023;
hx &= 0x000fffff;
i = (hx+0x95f64)&0x100000;
SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */
k += (i>>20);
f = x-1.0;
if((0x000fffff&(2+hx))<3) { /* |f| < 2**-20 */
if(f==zero) {if(k==0) return zero; else {dk=(double)k;
return dk*ln2_hi+dk*ln2_lo;}
}
R = f*f*(0.5-0.33333333333333333*f);
if(k==0) return f-R; else {dk=(double)k;
return dk*ln2_hi-((R-dk*ln2_lo)-f);}
}
s = f/(2.0+f);
dk = (double)k;
z = s*s;
i = hx-0x6147a;
w = z*z;
j = 0x6b851-hx;
t1= w*(Lg2+w*(Lg4+w*Lg6));
t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
i |= j;
R = t2+t1;
if(i>0) {
hfsq=0.5*f*f;
if(k==0) return f-(hfsq-s*(hfsq+R)); else
return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f);
} else {
if(k==0) return f-s*(f-R); else
return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f);
}
}
/* @(#)e_pow.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#if defined(LIBM_SCCS) && !defined(lint)
static char rcsid[] = "$NetBSD: e_pow.c,v 1.9 1995/05/12 04:57:32 jtc Exp $";
#endif
/* __ieee754_pow(x,y) return x**y
*
* n
* Method: Let x = 2 * (1+f)
* 1. Compute and return log2(x) in two pieces:
* log2(x) = w1 + w2,
* where w1 has 53-24 = 29 bit trailing zeros.
* 2. Perform y*log2(x) = n+y' by simulating muti-precision
* arithmetic, where |y'|<=0.5.
* 3. Return x**y = 2**n*exp(y'*log2)
*
* Special cases:
* 1. (anything) ** 0 is 1
* 2. (anything) ** 1 is itself
* 3. (anything) ** NAN is NAN
* 4. NAN ** (anything except 0) is NAN
* 5. +-(|x| > 1) ** +INF is +INF
* 6. +-(|x| > 1) ** -INF is +0
* 7. +-(|x| < 1) ** +INF is +0
* 8. +-(|x| < 1) ** -INF is +INF
* 9. +-1 ** +-INF is NAN
* 10. +0 ** (+anything except 0, NAN) is +0
* 11. -0 ** (+anything except 0, NAN, odd integer) is +0
* 12. +0 ** (-anything except 0, NAN) is +INF
* 13. -0 ** (-anything except 0, NAN, odd integer) is +INF
* 14. -0 ** (odd integer) = -( +0 ** (odd integer) )
* 15. +INF ** (+anything except 0,NAN) is +INF
* 16. +INF ** (-anything except 0,NAN) is +0
* 17. -INF ** (anything) = -0 ** (-anything)
* 18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer)
* 19. (-anything except 0 and inf) ** (non-integer) is NAN
*
* Accuracy:
* pow(x,y) returns x**y nearly rounded. In particular
* pow(integer,integer)
* always returns the correct integer provided it is
* representable.
*
* Constants :
* The hexadecimal values are the intended ones for the following
* constants. The decimal values may be used, provided that the
* compiler will convert from decimal to binary accurately enough
* to produce the hexadecimal values shown.
*/
/*#include "math.h"*/
#include "math_private.h"
#ifdef __STDC__
static const double
#else
static double
#endif
bp[] = {1.0, 1.5,},
dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */
dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */
/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
L1 = 5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */
L2 = 4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */
L3 = 3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */
L4 = 2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */
L5 = 2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */
L6 = 2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */
P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
P5 = 4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */
lg2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */
lg2_h = 6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */
lg2_l = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */
ovt = 8.0085662595372944372e-0017, /* -(1024-log2(ovfl+.5ulp)) */
cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */
cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */
cp_l = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/
ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */
ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/
ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
#ifdef __STDC__
double __ieee754_pow(double x, double y)
#else
double __ieee754_pow(x,y)
double x, y;
#endif
{
double z,ax,z_h,z_l,p_h,p_l;
double y1,t1,t2,r,s,t,u,v,w;
int32_t i,j,k,yisint,n;
int32_t hx,hy,ix,iy;
u_int32_t lx,ly;
EXTRACT_WORDS(hx,lx,x);
EXTRACT_WORDS(hy,ly,y);
ix = hx&0x7fffffff; iy = hy&0x7fffffff;
/* y==zero: x**0 = 1 */
if((iy|ly)==0) return one;
/* +-NaN return x+y */
if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) ||
iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0)))
return x+y;
/* determine if y is an odd int when x < 0
* yisint = 0 ... y is not an integer
* yisint = 1 ... y is an odd int
* yisint = 2 ... y is an even int
*/
yisint = 0;
if(hx<0) {
if(iy>=0x43400000) yisint = 2; /* even integer y */
else if(iy>=0x3ff00000) {
k = (iy>>20)-0x3ff; /* exponent */
if(k>20) {
j = ly>>(52-k);
if((j<<(52-k))==ly) yisint = 2-(j&1);
} else if(ly==0) {
j = iy>>(20-k);
if((j<<(20-k))==iy) yisint = 2-(j&1);
}
}
}
/* special value of y */
if(ly==0) {
if (iy==0x7ff00000) { /* y is +-inf */
if(((ix-0x3ff00000)|lx)==0)
return y - y; /* inf**+-1 is NaN */
else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */
return (hy>=0)? y: zero;
else /* (|x|<1)**-,+inf = inf,0 */
return (hy<0)?-y: zero;
}
if(iy==0x3ff00000) { /* y is +-1 */
if(hy<0) return one/x; else return x;
}
if(hy==0x40000000) return x*x; /* y is 2 */
if(hy==0x3fe00000) { /* y is 0.5 */
if(hx>=0) /* x >= +0 */
return __ieee754_sqrt(x);
}
}
ax = x < 0 ? -x : x; /*fabs(x);*/
/* special value of x */
if(lx==0) {
if(ix==0x7ff00000||ix==0||ix==0x3ff00000){
z = ax; /*x is +-0,+-inf,+-1*/
if(hy<0) z = one/z; /* z = (1/|x|) */
if(hx<0) {
if(((ix-0x3ff00000)|yisint)==0) {
z = (z-z)/(z-z); /* (-1)**non-int is NaN */
} else if(yisint==1)
z = -z; /* (x<0)**odd = -(|x|**odd) */
}
return z;
}
}
/* (x<0)**(non-int) is NaN */
if(((((u_int32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x);
/* |y| is huge */
if(iy>0x41e00000) { /* if |y| > 2**31 */
if(iy>0x43f00000){ /* if |y| > 2**64, must o/uflow */
if(ix<=0x3fefffff) return (hy<0)? huge*huge:tiny*tiny;
if(ix>=0x3ff00000) return (hy>0)? huge*huge:tiny*tiny;
}
/* over/underflow if x is not close to one */
if(ix<0x3fefffff) return (hy<0)? huge*huge:tiny*tiny;
if(ix>0x3ff00000) return (hy>0)? huge*huge:tiny*tiny;
/* now |1-x| is tiny <= 2**-20, suffice to compute
log(x) by x-x^2/2+x^3/3-x^4/4 */
t = x-1; /* t has 20 trailing zeros */
w = (t*t)*(0.5-t*(0.3333333333333333333333-t*0.25));
u = ivln2_h*t; /* ivln2_h has 21 sig. bits */
v = t*ivln2_l-w*ivln2;
t1 = u+v;
SET_LOW_WORD(t1,0);
t2 = v-(t1-u);
} else {
double s2,s_h,s_l,t_h,t_l;
n = 0;
/* take care subnormal number */
if(ix<0x00100000)
{ax *= two53; n -= 53; GET_HIGH_WORD(ix,ax); }
n += ((ix)>>20)-0x3ff;
j = ix&0x000fffff;
/* determine interval */
ix = j|0x3ff00000; /* normalize ix */
if(j<=0x3988E) k=0; /* |x|<sqrt(3/2) */
else if(j<0xBB67A) k=1; /* |x|<sqrt(3) */
else {k=0;n+=1;ix -= 0x00100000;}
SET_HIGH_WORD(ax,ix);
/* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
u = ax-bp[k]; /* bp[0]=1.0, bp[1]=1.5 */
v = one/(ax+bp[k]);
s = u*v;
s_h = s;
SET_LOW_WORD(s_h,0);
/* t_h=ax+bp[k] High */
t_h = zero;
SET_HIGH_WORD(t_h,((ix>>1)|0x20000000)+0x00080000+(k<<18));
t_l = ax - (t_h-bp[k]);
s_l = v*((u-s_h*t_h)-s_h*t_l);
/* compute log(ax) */
s2 = s*s;
r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6)))));
r += s_l*(s_h+s);
s2 = s_h*s_h;
t_h = 3.0+s2+r;
SET_LOW_WORD(t_h,0);
t_l = r-((t_h-3.0)-s2);
/* u+v = s*(1+...) */
u = s_h*t_h;
v = s_l*t_h+t_l*s;
/* 2/(3log2)*(s+...) */
p_h = u+v;
SET_LOW_WORD(p_h,0);
p_l = v-(p_h-u);
z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */
z_l = cp_l*p_h+p_l*cp+dp_l[k];
/* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
t = (double)n;
t1 = (((z_h+z_l)+dp_h[k])+t);
SET_LOW_WORD(t1,0);
t2 = z_l-(((t1-t)-dp_h[k])-z_h);
}
s = one; /* s (sign of result -ve**odd) = -1 else = 1 */
if(((((u_int32_t)hx>>31)-1)|(yisint-1))==0)
s = -one;/* (-ve)**(odd int) */
/* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
y1 = y;
SET_LOW_WORD(y1,0);
p_l = (y-y1)*t1+y*t2;
p_h = y1*t1;
z = p_l+p_h;
EXTRACT_WORDS(j,i,z);
if (j>=0x40900000) { /* z >= 1024 */
if(((j-0x40900000)|i)!=0) /* if z > 1024 */
return s*huge*huge; /* overflow */
else {
if(p_l+ovt>z-p_h) return s*huge*huge; /* overflow */
}
} else if((j&0x7fffffff)>=0x4090cc00 ) { /* z <= -1075 */
if(((j-0xc090cc00)|i)!=0) /* z < -1075 */
return s*tiny*tiny; /* underflow */
else {
if(p_l<=z-p_h) return s*tiny*tiny; /* underflow */
}
}
/*
* compute 2**(p_h+p_l)
*/
i = j&0x7fffffff;
k = (i>>20)-0x3ff;
n = 0;
if(i>0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */
n = j+(0x00100000>>(k+1));
k = ((n&0x7fffffff)>>20)-0x3ff; /* new k for n */
t = zero;
SET_HIGH_WORD(t,n&~(0x000fffff>>k));
n = ((n&0x000fffff)|0x00100000)>>(20-k);
if(j<0) n = -n;
p_h -= t;
}
t = p_l+p_h;
SET_LOW_WORD(t,0);
u = t*lg2_h;
v = (p_l-(t-p_h))*lg2+t*lg2_l;
z = u+v;
w = v-(z-u);
t = z*z;
t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
r = (z*t1)/(t1-two)-(w+z*w);
z = one-(r-z);
GET_HIGH_WORD(j,z);
j += (n<<20);
if((j>>20)<=0) z = scalbn(z,n); /* subnormal output */
else SET_HIGH_WORD(z,j);
return s*z;
}
This diff is collapsed.
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
#ifndef SDL_fbelo_h #ifndef SDL_fbelo_h
#define SDL_fbelo_h #define SDL_fbelo_h
#include <stdlib.h>
#include "SDL_fbvideo.h" #include "SDL_fbvideo.h"
/* ELO */ /* ELO */
......
This diff is collapsed.
...@@ -237,8 +237,6 @@ mmx_ok(void) ...@@ -237,8 +237,6 @@ mmx_ok(void)
/* Include the stuff for printing a trace to stderr... /* Include the stuff for printing a trace to stderr...
*/ */
#include <stdio.h>
#define mmx_i2r(op, imm, reg) \ #define mmx_i2r(op, imm, reg) \
{ \ { \
mmx_t mmx_trace; \ mmx_t mmx_trace; \
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#ifndef _SDL_QWin_h #ifndef _SDL_QWin_h
#define _SDL_QWin_h #define _SDL_QWin_h
#include <stdio.h> #include <stdio.h>
#include <qimage.h> #include <qimage.h>
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#ifndef _SDL_lowvideo_h #ifndef _SDL_lowvideo_h
#define _SDL_lowvideo_h #define _SDL_lowvideo_h
#include <windows.h> #include "SDL_windows.h"
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
......
...@@ -20,15 +20,15 @@ ...@@ -20,15 +20,15 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
#include <stdlib.h> #include "SDL_windows.h"
#include <stdio.h>
#include <windows.h>
#include "SDL_getenv.h"
#include "SDL_events.h" #include "SDL_events.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_syswm.h" #include "SDL_syswm.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_getenv.h"
#include "SDL_sysevents.h" #include "SDL_sysevents.h"
#include "SDL_events_c.h" #include "SDL_events_c.h"
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
...@@ -798,7 +798,7 @@ static int GetCodePage() ...@@ -798,7 +798,7 @@ static int GetCodePage()
int cp = GetACP(); int cp = GetACP();
if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof(buff))) { if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof(buff))) {
cp = atoi(buff); cp = strtol(buff, NULL, 0);
} }
return cp; return cp;
} }
......
...@@ -20,11 +20,12 @@ ...@@ -20,11 +20,12 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
#include <stdlib.h> #include "SDL_windows.h"
#include <windows.h>
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_mouse.h" #include "SDL_mouse.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_sysmouse_c.h" #include "SDL_sysmouse_c.h"
#include "SDL_events_c.h" #include "SDL_events_c.h"
#include "SDL_cursor_c.h" #include "SDL_cursor_c.h"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#ifndef _SDL_dibvideo_h #ifndef _SDL_dibvideo_h
#define _SDL_dibvideo_h #define _SDL_dibvideo_h
#include <windows.h> #include "SDL_windows.h"
/* for PDA */ /* for PDA */
typedef enum typedef enum
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment