mirror of
https://github.com/yawut/SDL.git
synced 2026-08-26 02:35:06 -05:00
It's now possible to build SDL without any C runtime at all on Windows,
using Visual C++ 2005
This commit is contained in:
@@ -10,8 +10,10 @@ libSDLinclude_HEADERS = \
|
||||
SDL_audio.h \
|
||||
SDL_byteorder.h \
|
||||
SDL_cdrom.h \
|
||||
SDL_config.h \
|
||||
SDL_copying.h \
|
||||
SDL_cpuinfo.h \
|
||||
SDL_ctype.h \
|
||||
SDL_endian.h \
|
||||
SDL_error.h \
|
||||
SDL_events.h \
|
||||
@@ -27,11 +29,15 @@ libSDLinclude_HEADERS = \
|
||||
SDL_opengl.h \
|
||||
SDL_quit.h \
|
||||
SDL_rwops.h \
|
||||
SDL_stdarg.h \
|
||||
SDL_stdlib.h \
|
||||
SDL_string.h \
|
||||
SDL_syswm.h \
|
||||
SDL_thread.h \
|
||||
SDL_timer.h \
|
||||
SDL_types.h \
|
||||
SDL_version.h \
|
||||
SDL_video.h \
|
||||
SDL_windows.h \
|
||||
begin_code.h \
|
||||
close_code.h
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#ifndef _SDL_audio_h
|
||||
#define _SDL_audio_h
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "SDL_main.h"
|
||||
#include "SDL_types.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
87
include/SDL_config.h
Normal file
87
include/SDL_config.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
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 */
|
||||
39
include/SDL_ctype.h
Normal file
39
include/SDL_ctype.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
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 @@
|
||||
and other data sources.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "SDL_types.h"
|
||||
#include "SDL_rwops.h"
|
||||
#include "SDL_byteorder.h"
|
||||
|
||||
@@ -38,6 +38,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* General keyboard/mouse state definitions */
|
||||
#define SDL_RELEASED 0
|
||||
#define SDL_PRESSED 1
|
||||
|
||||
/* Event enumerations */
|
||||
typedef enum {
|
||||
SDL_NOEVENT = 0, /* Unused (do not remove) */
|
||||
|
||||
@@ -23,29 +23,31 @@
|
||||
#ifndef _SDL_getenv_h
|
||||
#define _SDL_getenv_h
|
||||
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Not all environments have a working getenv()/putenv() */
|
||||
|
||||
#if defined(macintosh) || defined(WIN32) || defined(_WIN32_WCE)
|
||||
#define NEED_SDL_GETENV
|
||||
#ifdef HAVE_GETENV
|
||||
#define SDL_getenv getenv
|
||||
#else
|
||||
#define getenv SDL_getenv
|
||||
extern DECLSPEC char * SDLCALL SDL_getenv(const char *name);
|
||||
#endif
|
||||
|
||||
#ifdef NEED_SDL_GETENV
|
||||
|
||||
/* Put a variable of the form "name=value" into the environment */
|
||||
#ifdef HAVE_PUTENV
|
||||
#define SDL_putenv putenv
|
||||
#else
|
||||
#define putenv SDL_putenv
|
||||
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
|
||||
#define putenv(X) SDL_putenv(X)
|
||||
|
||||
/* 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 */
|
||||
#endif
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -115,7 +115,7 @@ extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
|
||||
Button 4: Mouse wheel up (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_MIDDLE 2
|
||||
#define SDL_BUTTON_RIGHT 3
|
||||
|
||||
@@ -27,7 +27,11 @@
|
||||
#ifndef _SDL_RWops_h
|
||||
#define _SDL_RWops_h
|
||||
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "SDL_types.h"
|
||||
|
||||
@@ -63,10 +67,12 @@ typedef struct SDL_RWops {
|
||||
|
||||
Uint32 type;
|
||||
union {
|
||||
#ifdef HAVE_STDIO_H
|
||||
struct {
|
||||
int autoclose;
|
||||
FILE *fp;
|
||||
} stdio;
|
||||
#endif
|
||||
struct {
|
||||
Uint8 *base;
|
||||
Uint8 *here;
|
||||
@@ -84,7 +90,9 @@ typedef struct SDL_RWops {
|
||||
|
||||
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);
|
||||
#endif
|
||||
|
||||
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromMem(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
|
||||
extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void);
|
||||
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 */
|
||||
#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_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n)
|
||||
#define SDL_RWclose(ctx) (ctx)->close(ctx)
|
||||
|
||||
34
include/SDL_stdarg.h
Normal file
34
include/SDL_stdarg.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
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 */
|
||||
105
include/SDL_stdlib.h
Normal file
105
include/SDL_stdlib.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
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 */
|
||||
359
include/SDL_string.h
Normal file
359
include/SDL_string.h
Normal file
@@ -0,0 +1,359 @@
|
||||
/*
|
||||
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 string manipulation functions for SDL */
|
||||
|
||||
#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>
|
||||
#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)
|
||||
#define SDL_memcpy(dst, src, len) \
|
||||
do { \
|
||||
int u0, u1, u2; \
|
||||
__asm__ __volatile__ ( \
|
||||
"cld\n\t" \
|
||||
"rep ; movsl\n\t" \
|
||||
"testb $2,%b4\n\t" \
|
||||
"je 1f\n\t" \
|
||||
"movsw\n" \
|
||||
"1:\ttestb $1,%b4\n\t" \
|
||||
"je 2f\n\t" \
|
||||
"movsb\n" \
|
||||
"2:" \
|
||||
: "=&c" (u0), "=&D" (u1), "=&S" (u2) \
|
||||
: "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \
|
||||
: "memory" ); \
|
||||
} 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) \
|
||||
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 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) \
|
||||
do { \
|
||||
int u0, u1, u2; \
|
||||
char *dstp = (char *)(dst); \
|
||||
char *srcp = (char *)(src); \
|
||||
int n = (len); \
|
||||
if ( n >= 4 ) { \
|
||||
__asm__ __volatile__ ( \
|
||||
"std\n\t" \
|
||||
"rep ; movsl\n\t" \
|
||||
: "=&c" (u0), "=&D" (u1), "=&S" (u2) \
|
||||
: "0" (n >> 2), \
|
||||
"1" (dstp+(n-4)), "2" (srcp+(n-4)) \
|
||||
: "memory" ); \
|
||||
} \
|
||||
switch (n & 3) { \
|
||||
case 3: dstp[2] = srcp[2]; \
|
||||
case 2: dstp[1] = srcp[1]; \
|
||||
case 1: dstp[0] = srcp[0]; \
|
||||
break; \
|
||||
default: \
|
||||
break; \
|
||||
} \
|
||||
} 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) \
|
||||
do { \
|
||||
if ( dst < src ) { \
|
||||
SDL_memcpy(dst, src, len); \
|
||||
} else { \
|
||||
SDL_revcpy(dst, src, len); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#ifndef HAVE_MEMCMP
|
||||
#define memcmp SDL_memcmp
|
||||
#endif
|
||||
#ifndef SDL_memcmp
|
||||
extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRLEN
|
||||
#define SDL_strlen strlen
|
||||
#else
|
||||
#define strlen SDL_strlen
|
||||
extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRCPY
|
||||
#define SDL_strcpy strcpy
|
||||
#else
|
||||
#define strcpy SDL_strcpy
|
||||
extern DECLSPEC char * SDLCALL SDL_strcpy(char *dst, const char *src);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRNCPY
|
||||
#define SDL_strncpy strncpy
|
||||
#else
|
||||
#define strncpy SDL_strncpy
|
||||
extern DECLSPEC char * SDLCALL SDL_strncpy(char *dst, const char *src, size_t maxlen);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__STRREV
|
||||
#define SDL_strrev _strrev
|
||||
#else
|
||||
#define _strrev SDL_strrev
|
||||
extern DECLSPEC char * SDLCALL SDL_strrev(char *string);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__STRUPR
|
||||
#define SDL_strupr _strupr
|
||||
#else
|
||||
#define _strupr SDL_strupr
|
||||
extern DECLSPEC char * SDLCALL SDL_strupr(char *string);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__STRLWR
|
||||
#define SDL_strlwr _strlwr
|
||||
#else
|
||||
#define _strlwr SDL_strlwr
|
||||
extern DECLSPEC char * SDLCALL SDL_strlwr(char *string);
|
||||
#endif
|
||||
|
||||
#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
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_string_h */
|
||||
@@ -119,8 +119,7 @@ typedef struct SDL_SysWMinfo {
|
||||
} SDL_SysWMinfo;
|
||||
|
||||
#elif defined(WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "SDL_windows.h"
|
||||
|
||||
/* The windows custom event structure */
|
||||
struct SDL_SysWMmsg {
|
||||
|
||||
@@ -45,7 +45,7 @@ struct SDL_Thread;
|
||||
typedef struct SDL_Thread SDL_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
|
||||
creates a new thread for the calling process with the SDL_CreateThread()
|
||||
@@ -53,39 +53,39 @@ typedef struct SDL_Thread SDL_Thread;
|
||||
be initialized for those threads, and not the RTL of the calling application!
|
||||
To solve this, we make a little hack here.
|
||||
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
|
||||
the application, then the RTL of the application will be used.
|
||||
So, in short:
|
||||
Always use the _beginthread() and _endthread() of the calling runtime library!
|
||||
*/
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
#include <process.h> // This has _beginthread() and _endthread() defined!
|
||||
#endif
|
||||
#ifdef __EMX__
|
||||
#include <stdlib.h> // This has _beginthread() and _endthread() defined, if -Zmt flag is used!
|
||||
#endif
|
||||
|
||||
typedef Uint32 SDLCALL (*pfnSDL_CurrentBeginThread)(void (*pfnThreadFn)(void *), Uint32 uiStackSize, void *pParam);
|
||||
typedef void SDLCALL (*pfnSDL_CurrentEndThread)(void);
|
||||
#ifdef __OS2__
|
||||
typedef int (__cdecl *pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void *arg);
|
||||
typedef void (__cdecl *pfnSDL_CurrentEndThread)(void);
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
|
||||
unsigned (__stdcall *func)(void *), void *arg,
|
||||
unsigned, unsigned *threadID);
|
||||
typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
|
||||
#endif
|
||||
|
||||
extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread_Core(int (*fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread);
|
||||
|
||||
// Disable warnings about unreferenced symbol!
|
||||
#pragma disable_message (202)
|
||||
static Uint32 SDLCALL SDL_CurrentBeginThread(void (*pfnThreadFn)(void *), Uint32 uiStackSize, void *pParam)
|
||||
{
|
||||
return _beginthread(pfnThreadFn, NULL, uiStackSize, pParam);
|
||||
}
|
||||
|
||||
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
|
||||
extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data);
|
||||
#endif
|
||||
|
||||
@@ -25,11 +25,17 @@
|
||||
#ifndef _SDL_types_h
|
||||
#define _SDL_types_h
|
||||
|
||||
/* The number of elements in a table */
|
||||
#define SDL_TABLESIZE(table) (sizeof(table)/sizeof(table[0]))
|
||||
#include <sys/types.h>
|
||||
#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 */
|
||||
typedef enum {
|
||||
typedef enum SDL_bool {
|
||||
SDL_FALSE = 0,
|
||||
SDL_TRUE = 1
|
||||
} SDL_bool;
|
||||
@@ -107,9 +113,4 @@ typedef enum {
|
||||
|
||||
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
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#ifndef _SDL_video_h
|
||||
#define _SDL_video_h
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "SDL_types.h"
|
||||
#include "SDL_mutex.h"
|
||||
#include "SDL_rwops.h"
|
||||
|
||||
46
include/SDL_windows.h
Normal file
46
include/SDL_windows.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
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 */
|
||||
Reference in New Issue
Block a user