diff options
author | Tim Angus <tim@ngus.net> | 2007-07-15 14:15:41 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2007-07-15 14:15:41 +0000 |
commit | ffbf946dd63dccf0d6b6553c8bc1c9da4d3c89b3 (patch) | |
tree | 62b48381afabceca4c2aad7c39e0eeb51e328126 /src/SDL12/include/SDL_endian.h | |
parent | 655d4c12eea45edf2041300eccace352a503b690 (diff) |
* Merge of ioq3-r1112
Diffstat (limited to 'src/SDL12/include/SDL_endian.h')
-rw-r--r-- | src/SDL12/include/SDL_endian.h | 68 |
1 files changed, 24 insertions, 44 deletions
diff --git a/src/SDL12/include/SDL_endian.h b/src/SDL12/include/SDL_endian.h index 4fc2cf12..6257a649 100644 --- a/src/SDL12/include/SDL_endian.h +++ b/src/SDL12/include/SDL_endian.h @@ -1,52 +1,48 @@ /* SDL - Simple DirectMedia Layer - Copyright (C) 1997-2004 Sam Lantinga + 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 Library General Public + modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + 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 - Library General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + 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 */ -#ifdef SAVE_RCSID -static char rcsid = - "@(#) $Id: SDL_endian.h,v 1.15 2005/03/30 12:38:03 pmandin Exp $"; -#endif - /* Functions for reading and writing endian-specific values */ #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. +#include "SDL_stdinc.h" - 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. -*/ +/* The two types of endianness */ +#define SDL_LIL_ENDIAN 1234 +#define SDL_BIG_ENDIAN 4321 -#include <stdio.h> +#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ +#if defined(__hppa__) || \ + defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ + (defined(__MIPS__) && defined(__MISPEB__)) || \ + defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ + defined(__sparc__) +#define SDL_BYTEORDER SDL_BIG_ENDIAN +#else +#define SDL_BYTEORDER SDL_LIL_ENDIAN +#endif +#endif /* !SDL_BYTEORDER */ -#include "SDL_types.h" -#include "SDL_rwops.h" -#include "SDL_byteorder.h" #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ @@ -59,7 +55,8 @@ extern "C" { static for compilers that do not support inline functions, this header should only be included in files that actually use them. */ -#if defined(__GNUC__) && defined(__i386__) +#if defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */) static __inline__ Uint16 SDL_Swap16(Uint16 x) { __asm__("xchgb %b0,%h0" : "=q" (x) : "0" (x)); @@ -186,23 +183,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 } |