From dc1e8b1f045c6912929be40cfdab846beca9881e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 9 Feb 2006 09:38:05 +0000 Subject: [PATCH] Fixed build problem with SDL_string.c Officially deprecated SDL_byteorder.h, SDL_getenv.h and SDL_types.h Moved endian-related SDL_rwops code into SDL_rwops.c --- configure.in | 19 +++---- include/Makefile.am | 3 +- include/SDL_byteorder.h | 28 +--------- include/SDL_config.h | 115 ++++++++++++++++++++++++++++++++++++---- include/SDL_config.h.in | 4 +- include/SDL_endian.h | 51 +++++++----------- include/SDL_getenv.h | 1 + include/SDL_rwops.h | 27 +++++++--- include/SDL_types.h | 1 + src/Makefile.am | 2 +- src/endian/Makefile.am | 11 ---- src/endian/Makefile.wat | 24 --------- src/endian/SDL_endian.c | 99 ---------------------------------- src/file/SDL_rwops.c | 80 +++++++++++++++++++++++++++- src/stdlib/SDL_getenv.c | 3 +- src/stdlib/SDL_malloc.c | 3 +- src/stdlib/SDL_qsort.c | 3 +- src/stdlib/SDL_stdlib.c | 2 +- src/stdlib/SDL_string.c | 43 +++++++-------- 19 files changed, 262 insertions(+), 257 deletions(-) delete mode 100644 src/endian/Makefile.am delete mode 100644 src/endian/Makefile.wat delete mode 100644 src/endian/SDL_endian.c diff --git a/configure.in b/configure.in index a9779d331..6cf890f9b 100644 --- a/configure.in +++ b/configure.in @@ -41,6 +41,12 @@ AC_SUBST(LT_AGE) dnl Detect the canonical host and target build environment AC_CANONICAL_SYSTEM +AC_C_BIGENDIAN +if test x$ac_cv_c_bigendian = xyes; then + AC_DEFINE(SDL_BYTEORDER, 4321) +else + AC_DEFINE(SDL_BYTEORDER, 1234) +fi dnl Setup for automake AM_INIT_AUTOMAKE(SDL, $SDL_VERSION) @@ -118,7 +124,7 @@ fi dnl See whether we are allowed to use the system C library AC_ARG_ENABLE(libc, [ --enable-libc Use the system C library [default=yes]], - , AC_DEFINE([HAVE_LIBC])) + , AC_DEFINE(HAVE_LIBC)) dnl Check for compiler characteristics AC_C_CONST @@ -286,15 +292,6 @@ if test x$enable_timers = xyes; then else CFLAGS="$CFLAGS -DDISABLE_TIMERS" fi -AC_ARG_ENABLE(endian, -[ --enable-endian Enable the endian subsystem [default=yes]], - , enable_endian=yes) -if test x$enable_endian = xyes; then - SDL_EXTRADIRS="$SDL_EXTRADIRS endian" - SDL_EXTRALIBS="$SDL_EXTRALIBS endian/libendian.la" -else - CFLAGS="$CFLAGS -DDISABLE_ENDIAN" -fi AC_ARG_ENABLE(file, [ --enable-file Enable the file subsystem [default=yes]], , enable_file=yes) @@ -3051,7 +3048,6 @@ CFLAGS="$CFLAGS -I\$(top_srcdir)/src/joystick" CFLAGS="$CFLAGS -I\$(top_srcdir)/src/cdrom" CFLAGS="$CFLAGS -I\$(top_srcdir)/src/thread" CFLAGS="$CFLAGS -I\$(top_srcdir)/src/timer" -CFLAGS="$CFLAGS -I\$(top_srcdir)/src/endian" CFLAGS="$CFLAGS -I\$(top_srcdir)/src/file" CFLAGS="$CFLAGS -I\$(top_builddir)/src/thread" CXXFLAGS="$CFLAGS" @@ -3180,7 +3176,6 @@ src/cdrom/qnx/Makefile src/cdrom/win32/Makefile src/thread/Makefile src/timer/Makefile -src/endian/Makefile src/file/Makefile src/cpuinfo/Makefile src/hermes/Makefile diff --git a/include/Makefile.am b/include/Makefile.am index 6cefd4c30..e0f1fbe2f 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -13,7 +13,6 @@ libSDLinclude_HEADERS = \ SDL_config.h \ SDL_copying.h \ SDL_cpuinfo.h \ - SDL_ctype.h \ SDL_endian.h \ SDL_error.h \ SDL_events.h \ @@ -29,7 +28,7 @@ libSDLinclude_HEADERS = \ SDL_opengl.h \ SDL_quit.h \ SDL_rwops.h \ - SDL_stdarg.h \ + SDL_stdinc.h \ SDL_stdlib.h \ SDL_string.h \ SDL_syswm.h \ diff --git a/include/SDL_byteorder.h b/include/SDL_byteorder.h index 483f0ed03..3871cfed5 100644 --- a/include/SDL_byteorder.h +++ b/include/SDL_byteorder.h @@ -20,29 +20,5 @@ slouken@libsdl.org */ -/* Macros for determining the byte-order of this platform */ - -#ifndef _SDL_byteorder_h -#define _SDL_byteorder_h - -#include "SDL_config.h" - -/* The two types of endianness */ -#define SDL_LIL_ENDIAN 1234 -#define SDL_BIG_ENDIAN 4321 - -#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ -#if (defined(__i386__) || defined(__i386)) || \ - defined(__ia64__) || defined(__x86_64__) || \ - (defined(__alpha__) || defined(__alpha)) || \ - (defined(__arm__) || defined(__thumb__)) || \ - (defined(__sh__) || defined(__sh64__)) || \ - (defined(__mips__) && defined(__MIPSEL__)) || \ - defined(__SYMBIAN32__) || defined(__OS2__) -#define SDL_BYTEORDER SDL_LIL_ENDIAN -#else -#define SDL_BYTEORDER SDL_BIG_ENDIAN -#endif -#endif /* !SDL_BYTEORDER */ - -#endif /* _SDL_byteorder_h */ +/* DEPRECATED */ +#include "SDL_endian.h" diff --git a/include/SDL_config.h b/include/SDL_config.h index 67aaa63cc..ff1975d2e 100644 --- a/include/SDL_config.h +++ b/include/SDL_config.h @@ -1,3 +1,4 @@ +/* include/SDL_config.h. Generated by configure. */ /* SDL - Simple DirectMedia Layer Copyright (C) 1997-2006 Sam Lantinga @@ -23,17 +24,111 @@ #ifndef _SDL_config_h #define _SDL_config_h -/* This is the minimal configuration that can be used to build SDL */ +/* This is a set of defines to configure the SDL features */ -#include +/* C language features */ +/* #undef const */ +/* #undef inline */ +/* #undef volatile */ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef unsigned int size_t; -typedef unsigned long uintptr_t; +/* C datatypes */ +/* #undef size_t */ +/* #undef int8_t */ +/* #undef uint8_t */ +/* #undef int16_t */ +/* #undef uint16_t */ +/* #undef int32_t */ +/* #undef uint32_t */ +#define SDL_HAS_64BIT_TYPE 1 +/* #undef int64_t */ +/* #undef uint64_t */ +/* #undef uintptr_t */ + +/* Endianness */ +#define SDL_BYTEORDER 1234 + +/* Comment this if you want to build without any C library requirements */ +#define HAVE_LIBC 1 +#ifdef HAVE_LIBC + +/* Useful headers */ +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#ifndef _WIN32 /* Don't use C runtime versions of these on Windows */ +#define HAVE_GETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#endif +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRCPY 1 +#define HAVE_STRNCPY 1 +#define HAVE_STRCAT 1 +#define HAVE_STRNCAT 1 +#define HAVE_STRDUP 1 +/* #undef HAVE__STRREV */ +/* #undef HAVE__STRUPR */ +/* #undef HAVE__STRLWR */ +/* #undef HAVE_INDEX */ +/* #undef HAVE_RINDEX */ +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +/* #undef HAVE_ITOA */ +/* #undef HAVE__LTOA */ +/* #undef HAVE__UITOA */ +/* #undef HAVE__ULTOA */ +#define HAVE_STRTOL 1 +/* #undef HAVE__I64TOA */ +/* #undef HAVE__UI64TOA */ +#define HAVE_STRTOLL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +/* #undef HAVE_STRICMP */ +#define HAVE_STRCASECMP 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +/* #undef HAVE_VSNPRINTF */ + +#endif /* HAVE_LIBC */ + + +/* Allow disabling of core subsystems */ +/* #undef DISABLE_AUDIO */ +/* #undef DISABLE_VIDEO */ +/* #undef DISABLE_EVENTS */ +/* #undef DISABLE_JOYSTICK */ +/* #undef DISABLE_CDROM */ +/* #undef DISABLE_THREADS */ +/* #undef DISABLE_TIMERS */ +/* #undef DISABLE_FILE */ +/* #undef DISABLE_CPUINFO */ #endif /* _SDL_config_h */ diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 6b5bc0fa1..a5ff395be 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -43,6 +43,9 @@ #undef uint64_t #undef uintptr_t +/* Endianness */ +#undef SDL_BYTEORDER + /* Comment this if you want to build without any C library requirements */ #undef HAVE_LIBC #ifdef HAVE_LIBC @@ -124,7 +127,6 @@ #undef DISABLE_CDROM #undef DISABLE_THREADS #undef DISABLE_TIMERS -#undef DISABLE_ENDIAN #undef DISABLE_FILE #undef DISABLE_CPUINFO diff --git a/include/SDL_endian.h b/include/SDL_endian.h index dc325dc43..1d24f5a44 100644 --- a/include/SDL_endian.h +++ b/include/SDL_endian.h @@ -25,22 +25,26 @@ #ifndef _SDL_endian_h #define _SDL_endian_h -/* These functions read and write data of the specified endianness, - dynamically translating to the host machine endianness. - - e.g.: If you want to read a 16 bit value on big-endian machine from - an open file containing little endian values, you would use: - value = SDL_ReadLE16(rp); - Note that the read/write functions use SDL_RWops pointers - instead of FILE pointers. This allows you to read and write - endian values from large chunks of memory as well as files - and other data sources. -*/ +#include "SDL_stdinc.h" + +/* The two types of endianness */ +#define SDL_LIL_ENDIAN 1234 +#define SDL_BIG_ENDIAN 4321 + +#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ +#if (defined(__i386__) || defined(__i386)) || \ + defined(__ia64__) || defined(__x86_64__) || \ + (defined(__alpha__) || defined(__alpha)) || \ + (defined(__arm__) || defined(__thumb__)) || \ + (defined(__sh__) || defined(__sh64__)) || \ + (defined(__mips__) && defined(__MIPSEL__)) || \ + defined(__SYMBIAN32__) || defined(__OS2__) +#define SDL_BYTEORDER SDL_LIL_ENDIAN +#else +#define SDL_BYTEORDER SDL_BIG_ENDIAN +#endif +#endif /* !SDL_BYTEORDER */ -#include "SDL_types.h" -//#warning FIXME: move rwops into rwops and swapping into byteorder.h -#include "SDL_rwops.h" -#include "SDL_byteorder.h" #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ @@ -180,23 +184,6 @@ static __inline__ Uint64 SDL_Swap64(Uint64 x) #define SDL_SwapBE64(X) (X) #endif -/* Read an item of the specified endianness and return in native format */ -extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src); -extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src); -extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src); -extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src); -extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src); -extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src); - -/* Write an item of native format to the specified endianness */ -extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value); -extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value); -extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value); -extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value); -extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value); -extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value); - - /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/include/SDL_getenv.h b/include/SDL_getenv.h index d913d8cbc..853b9ce45 100644 --- a/include/SDL_getenv.h +++ b/include/SDL_getenv.h @@ -20,4 +20,5 @@ slouken@libsdl.org */ +/* DEPRECATED */ #include "SDL_stdinc.h" diff --git a/include/SDL_rwops.h b/include/SDL_rwops.h index 29127989d..725031c6d 100644 --- a/include/SDL_rwops.h +++ b/include/SDL_rwops.h @@ -27,14 +27,9 @@ #ifndef _SDL_RWops_h #define _SDL_RWops_h -#include "SDL_config.h" - -#ifdef HAVE_STDIO_H -#include -#endif - -#include "SDL_types.h" +#include "SDL_stdinc.h" +#ifndef DISABLE_FILE #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus @@ -112,10 +107,28 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area); #define SDL_RWclose(ctx) (ctx)->close(ctx) +/* Read an item of the specified endianness and return in native format */ +extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src); +extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src); + +/* Write an item of native format to the specified endianness */ +extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value); +extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value); +extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value); +extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value); +extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value); +extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value); + + /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include "close_code.h" +#endif /* !DISABLE_FILE */ #endif /* _SDL_RWops_h */ diff --git a/include/SDL_types.h b/include/SDL_types.h index d913d8cbc..853b9ce45 100644 --- a/include/SDL_types.h +++ b/include/SDL_types.h @@ -20,4 +20,5 @@ slouken@libsdl.org */ +/* DEPRECATED */ #include "SDL_stdinc.h" diff --git a/src/Makefile.am b/src/Makefile.am index 4b0ee324f..fe873297c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,7 +7,7 @@ CORE_SUBDIRS = \ # These are the subdirectories which may be built EXTRA_SUBDIRS = \ - audio video events joystick cdrom thread timer endian file cpuinfo hermes + audio video events joystick cdrom thread timer file cpuinfo hermes # These are the subdirectories which will be built now SUBDIRS = $(CORE_SUBDIRS) @SDL_EXTRADIRS@ diff --git a/src/endian/Makefile.am b/src/endian/Makefile.am deleted file mode 100644 index c84f70f6b..000000000 --- a/src/endian/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ - -## Makefile.am for the SDL endian library - -noinst_LTLIBRARIES = libendian.la - -# Include the architecture-independent sources -COMMON_SRCS = \ - SDL_endian.c - -libendian_la_SOURCES = $(COMMON_SRCS) - diff --git a/src/endian/Makefile.wat b/src/endian/Makefile.wat deleted file mode 100644 index 365249d1d..000000000 --- a/src/endian/Makefile.wat +++ /dev/null @@ -1,24 +0,0 @@ -#============================================================================= -# This is a Watcom makefile to build SDL.DLL for OS/2 -# -# Makefile for endianness -#============================================================================= - -object_files=SDL_endian.obj -ExtraCFlags= - -# -#============================================================================== -# -!include ..\..\Watcom.mif - -.before - set include=$(%os2tk)\h;$(%include);../../include - -all : $(object_files) - -clean : .SYMBOLIC - @if exist *.obj del *.obj - @if exist *.map del *.map - @if exist *.res del *.res - @if exist *.lst del *.lst diff --git a/src/endian/SDL_endian.c b/src/endian/SDL_endian.c deleted file mode 100644 index f5efa969b..000000000 --- a/src/endian/SDL_endian.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - 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 -*/ - -/* Functions for dynamically reading and writing endian-specific values */ - -#include "SDL_endian.h" - -Uint16 SDL_ReadLE16 (SDL_RWops *src) -{ - Uint16 value; - - SDL_RWread(src, &value, (sizeof value), 1); - return(SDL_SwapLE16(value)); -} -Uint16 SDL_ReadBE16 (SDL_RWops *src) -{ - Uint16 value; - - SDL_RWread(src, &value, (sizeof value), 1); - return(SDL_SwapBE16(value)); -} -Uint32 SDL_ReadLE32 (SDL_RWops *src) -{ - Uint32 value; - - SDL_RWread(src, &value, (sizeof value), 1); - return(SDL_SwapLE32(value)); -} -Uint32 SDL_ReadBE32 (SDL_RWops *src) -{ - Uint32 value; - - SDL_RWread(src, &value, (sizeof value), 1); - return(SDL_SwapBE32(value)); -} -Uint64 SDL_ReadLE64 (SDL_RWops *src) -{ - Uint64 value; - - SDL_RWread(src, &value, (sizeof value), 1); - return(SDL_SwapLE64(value)); -} -Uint64 SDL_ReadBE64 (SDL_RWops *src) -{ - Uint64 value; - - SDL_RWread(src, &value, (sizeof value), 1); - return(SDL_SwapBE64(value)); -} - -int SDL_WriteLE16 (SDL_RWops *dst, Uint16 value) -{ - value = SDL_SwapLE16(value); - return(SDL_RWwrite(dst, &value, (sizeof value), 1)); -} -int SDL_WriteBE16 (SDL_RWops *dst, Uint16 value) -{ - value = SDL_SwapBE16(value); - return(SDL_RWwrite(dst, &value, (sizeof value), 1)); -} -int SDL_WriteLE32 (SDL_RWops *dst, Uint32 value) -{ - value = SDL_SwapLE32(value); - return(SDL_RWwrite(dst, &value, (sizeof value), 1)); -} -int SDL_WriteBE32 (SDL_RWops *dst, Uint32 value) -{ - value = SDL_SwapBE32(value); - return(SDL_RWwrite(dst, &value, (sizeof value), 1)); -} -int SDL_WriteLE64 (SDL_RWops *dst, Uint64 value) -{ - value = SDL_SwapLE64(value); - return(SDL_RWwrite(dst, &value, (sizeof value), 1)); -} -int SDL_WriteBE64 (SDL_RWops *dst, Uint64 value) -{ - value = SDL_SwapBE64(value); - return(SDL_RWwrite(dst, &value, (sizeof value), 1)); -} diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index f591eae6b..65dc851c8 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -24,11 +24,11 @@ data sources. It can easily be extended to files, memory, etc. */ -#include "SDL_stdlib.h" -#include "SDL_string.h" #include "SDL_error.h" +#include "SDL_endian.h" #include "SDL_rwops.h" + #ifdef HAVE_STDIO_H /* Functions to read/write stdio file pointers */ @@ -303,3 +303,79 @@ void SDL_FreeRW(SDL_RWops *area) { SDL_free(area); } + +/* Functions for dynamically reading and writing endian-specific values */ + +Uint16 SDL_ReadLE16 (SDL_RWops *src) +{ + Uint16 value; + + SDL_RWread(src, &value, (sizeof value), 1); + return(SDL_SwapLE16(value)); +} +Uint16 SDL_ReadBE16 (SDL_RWops *src) +{ + Uint16 value; + + SDL_RWread(src, &value, (sizeof value), 1); + return(SDL_SwapBE16(value)); +} +Uint32 SDL_ReadLE32 (SDL_RWops *src) +{ + Uint32 value; + + SDL_RWread(src, &value, (sizeof value), 1); + return(SDL_SwapLE32(value)); +} +Uint32 SDL_ReadBE32 (SDL_RWops *src) +{ + Uint32 value; + + SDL_RWread(src, &value, (sizeof value), 1); + return(SDL_SwapBE32(value)); +} +Uint64 SDL_ReadLE64 (SDL_RWops *src) +{ + Uint64 value; + + SDL_RWread(src, &value, (sizeof value), 1); + return(SDL_SwapLE64(value)); +} +Uint64 SDL_ReadBE64 (SDL_RWops *src) +{ + Uint64 value; + + SDL_RWread(src, &value, (sizeof value), 1); + return(SDL_SwapBE64(value)); +} + +int SDL_WriteLE16 (SDL_RWops *dst, Uint16 value) +{ + value = SDL_SwapLE16(value); + return(SDL_RWwrite(dst, &value, (sizeof value), 1)); +} +int SDL_WriteBE16 (SDL_RWops *dst, Uint16 value) +{ + value = SDL_SwapBE16(value); + return(SDL_RWwrite(dst, &value, (sizeof value), 1)); +} +int SDL_WriteLE32 (SDL_RWops *dst, Uint32 value) +{ + value = SDL_SwapLE32(value); + return(SDL_RWwrite(dst, &value, (sizeof value), 1)); +} +int SDL_WriteBE32 (SDL_RWops *dst, Uint32 value) +{ + value = SDL_SwapBE32(value); + return(SDL_RWwrite(dst, &value, (sizeof value), 1)); +} +int SDL_WriteLE64 (SDL_RWops *dst, Uint64 value) +{ + value = SDL_SwapLE64(value); + return(SDL_RWwrite(dst, &value, (sizeof value), 1)); +} +int SDL_WriteBE64 (SDL_RWops *dst, Uint64 value) +{ + value = SDL_SwapBE64(value); + return(SDL_RWwrite(dst, &value, (sizeof value), 1)); +} diff --git a/src/stdlib/SDL_getenv.c b/src/stdlib/SDL_getenv.c index 9da9427b4..efc86c1e5 100644 --- a/src/stdlib/SDL_getenv.c +++ b/src/stdlib/SDL_getenv.c @@ -20,8 +20,7 @@ slouken@libsdl.org */ -#include "SDL_stdlib.h" -#include "SDL_string.h" +#include "SDL_stdinc.h" #ifndef HAVE_GETENV diff --git a/src/stdlib/SDL_malloc.c b/src/stdlib/SDL_malloc.c index 3aec83c61..b7b72c286 100644 --- a/src/stdlib/SDL_malloc.c +++ b/src/stdlib/SDL_malloc.c @@ -23,8 +23,7 @@ /* This file contains portable memory management functions for SDL */ -#include "SDL_stdlib.h" -#include "SDL_string.h" +#include "SDL_stdinc.h" #ifndef HAVE_MALLOC diff --git a/src/stdlib/SDL_qsort.c b/src/stdlib/SDL_qsort.c index 37adbe8e5..327667448 100644 --- a/src/stdlib/SDL_qsort.c +++ b/src/stdlib/SDL_qsort.c @@ -47,8 +47,7 @@ #include #include */ -#include "SDL_stdlib.h" -#include "SDL_string.h" +#include "SDL_stdinc.h" #define assert(X) #define malloc SDL_malloc diff --git a/src/stdlib/SDL_stdlib.c b/src/stdlib/SDL_stdlib.c index 1bac89c89..120fcfe40 100644 --- a/src/stdlib/SDL_stdlib.c +++ b/src/stdlib/SDL_stdlib.c @@ -23,7 +23,7 @@ /* This file contains portable stdlib functions for SDL */ -#include "SDL_stdlib.h" +#include "SDL_stdinc.h" #ifndef HAVE_LIBC /* These are some C runtime intrinsics that need to be defined */ diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index 5c1f351d6..7a27c0988 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -23,14 +23,11 @@ /* This file contains portable string manipulation functions for SDL */ -#include "SDL_types.h" -#include "SDL_ctype.h" -#include "SDL_stdlib.h" -#include "SDL_string.h" +#include "SDL_stdinc.h" -#define isupperhex(X) (((X) >= 'A') && ((X) <= 'F')) -#define islowerhex(X) (((X) >= 'a') && ((X) <= 'f')) +#define SDL_isupperhex(X) (((X) >= 'A') && ((X) <= 'F')) +#define SDL_islowerhex(X) (((X) >= 'a') && ((X) <= 'f')) #if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOL) static size_t SDL_ScanLong(const char *text, int radix, long *valuep) @@ -48,11 +45,11 @@ static size_t SDL_ScanLong(const char *text, int radix, long *valuep) } for ( ; ; ) { int v; - if ( isdigit(*text) ) { + if ( SDL_isdigit(*text) ) { v = *text - '0'; - } else if ( radix == 16 && isupperhex(*text) ) { + } else if ( radix == 16 && SDL_isupperhex(*text) ) { v = 10 + (*text - 'A'); - } else if ( radix == 16 && islowerhex(*text) ) { + } else if ( radix == 16 && SDL_islowerhex(*text) ) { v = 10 + (*text - 'a'); } else { break; @@ -83,11 +80,11 @@ static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *v } for ( ; ; ) { int v; - if ( isdigit(*text) ) { + if ( SDL_isdigit(*text) ) { v = *text - '0'; - } else if ( radix == 16 && isupperhex(*text) ) { + } else if ( radix == 16 && SDL_isupperhex(*text) ) { v = 10 + (*text - 'A'); - } else if ( radix == 16 && islowerhex(*text) ) { + } else if ( radix == 16 && SDL_islowerhex(*text) ) { v = 10 + (*text - 'a'); } else { break; @@ -120,11 +117,11 @@ static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 *valuep) } for ( ; ; ) { int v; - if ( isdigit(*text) ) { + if ( SDL_isdigit(*text) ) { v = *text - '0'; - } else if ( radix == 16 && isupperhex(*text) ) { + } else if ( radix == 16 && SDL_isupperhex(*text) ) { v = 10 + (*text - 'A'); - } else if ( radix == 16 && islowerhex(*text) ) { + } else if ( radix == 16 && SDL_islowerhex(*text) ) { v = 10 + (*text - 'a'); } else { break; @@ -155,11 +152,11 @@ static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valu } for ( ; ; ) { int v; - if ( isdigit(*text) ) { + if ( SDL_isdigit(*text) ) { v = *text - '0'; - } else if ( radix == 16 && isupperhex(*text) ) { + } else if ( radix == 16 && SDL_isupperhex(*text) ) { v = 10 + (*text - 'A'); - } else if ( radix == 16 && islowerhex(*text) ) { + } else if ( radix == 16 && SDL_islowerhex(*text) ) { v = 10 + (*text - 'a'); } else { break; @@ -193,7 +190,7 @@ static size_t SDL_ScanFloat(const char *text, double *valuep) if ( *text == '.' ) { int mult = 10; ++text; - while ( isdigit(*text) ) { + while ( SDL_isdigit(*text) ) { lvalue = *text - '0'; value += (double)lvalue / mult; mult *= 10; @@ -632,7 +629,7 @@ int SDL_sscanf(const char *text, const char *fmt, ...) va_start(ap, fmt); while ( *fmt ) { if ( *fmt == ' ' ) { - while ( isspace(*text) ) { + while ( SDL_isspace(*text) ) { ++text; } ++fmt; @@ -683,7 +680,7 @@ int SDL_sscanf(const char *text, const char *fmt, ...) continue; } - while ( isspace(*text) ) { + while ( SDL_isspace(*text) ) { ++text; } @@ -845,7 +842,7 @@ int SDL_sscanf(const char *text, const char *fmt, ...) break; case 's': if ( suppress ) { - while ( !isspace(*text) ) { + while ( !SDL_isspace(*text) ) { ++text; if ( count ) { if ( --count == 0 ) { @@ -855,7 +852,7 @@ int SDL_sscanf(const char *text, const char *fmt, ...) } } else { char *valuep = va_arg(ap, char*); - while ( !isspace(*text) ) { + while ( !SDL_isspace(*text) ) { *valuep++ = *text++; if ( count ) { if ( --count == 0 ) {