diff options
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/f_finale.c | 2 | ||||
-rw-r--r-- | src/hu_lib.c | 2 | ||||
-rw-r--r-- | src/hu_stuff.c | 2 | ||||
-rw-r--r-- | src/i_sound.c | 2 | ||||
-rw-r--r-- | src/i_swap.h (renamed from src/m_swap.h) | 30 | ||||
-rw-r--r-- | src/i_video.c | 2 | ||||
-rw-r--r-- | src/m_menu.c | 2 | ||||
-rw-r--r-- | src/m_misc.c | 2 | ||||
-rw-r--r-- | src/m_swap.c | 54 | ||||
-rw-r--r-- | src/md5.c | 31 | ||||
-rw-r--r-- | src/mus2mid.c | 2 | ||||
-rw-r--r-- | src/p_setup.c | 2 | ||||
-rw-r--r-- | src/r_data.c | 2 | ||||
-rw-r--r-- | src/r_things.c | 2 | ||||
-rw-r--r-- | src/st_lib.c | 3 | ||||
-rw-r--r-- | src/v_video.c | 2 | ||||
-rw-r--r-- | src/w_wad.c | 2 | ||||
-rw-r--r-- | src/wi_stuff.c | 2 |
20 files changed, 50 insertions, 100 deletions
diff --git a/configure.in b/configure.in index bf0cdce6..ca9dffe6 100644 --- a/configure.in +++ b/configure.in @@ -60,8 +60,6 @@ AC_SUBST(SDLNET_LIBS) AC_SUBST(ac_aux_dir) -AC_C_BIGENDIAN - dnl Shut up the datarootdir warnings. AC_DEFUN([AC_DATAROOTDIR_CHECKED]) diff --git a/src/Makefile.am b/src/Makefile.am index 4d694293..335cf869 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -64,6 +64,7 @@ info.c info.h \ i_scale.c i_scale.h \ i_pcsound.c i_pcsound.h \ i_sound.c i_sound.h \ + i_swap.h \ i_system.c i_system.h \ i_timer.c i_timer.h \ i_video.c i_video.h \ @@ -77,7 +78,6 @@ md5.c md5.h \ memio.c memio.h \ mus2mid.c mus2mid.h \ m_random.c m_random.h \ -m_swap.c m_swap.h \ net_client.c net_client.h \ net_common.c net_common.h \ net_dedicated.c net_dedicated.h \ diff --git a/src/f_finale.c b/src/f_finale.c index beee6e55..c81649dd 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -31,7 +31,7 @@ // Functions. #include "deh_main.h" #include "i_system.h" -#include "m_swap.h" +#include "i_swap.h" #include "z_zone.h" #include "v_video.h" #include "w_wad.h" diff --git a/src/hu_lib.c b/src/hu_lib.c index 06850f5f..a6b00f3f 100644 --- a/src/hu_lib.c +++ b/src/hu_lib.c @@ -29,7 +29,7 @@ #include "doomdef.h" #include "v_video.h" -#include "m_swap.h" +#include "i_swap.h" #include "hu_lib.h" #include "r_local.h" diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 99b67210..08422706 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -31,7 +31,7 @@ #include "z_zone.h" #include "deh_main.h" -#include "m_swap.h" +#include "i_swap.h" #include "hu_stuff.h" #include "hu_lib.h" diff --git a/src/i_sound.c b/src/i_sound.c index 16118622..67a92130 100644 --- a/src/i_sound.c +++ b/src/i_sound.c @@ -41,10 +41,10 @@ #include "i_system.h" #include "i_pcsound.h" #include "i_sound.h" +#include "i_swap.h" #include "deh_main.h" #include "m_argv.h" #include "m_misc.h" -#include "m_swap.h" #include "w_wad.h" #include "doomdef.h" diff --git a/src/m_swap.h b/src/i_swap.h index 04adfa55..d24f500e 100644 --- a/src/m_swap.h +++ b/src/i_swap.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // // Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard +// Copyright(C) 2005,2006,2007 Simon Howard // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -25,26 +25,26 @@ //----------------------------------------------------------------------------- -#ifndef __M_SWAP__ -#define __M_SWAP__ - - -#include "config.h" +#ifndef __I_SWAP__ +#define __I_SWAP__ +#include "SDL_endian.h" // Endianess handling. // WAD files are stored little endian. -#ifdef WORDS_BIGENDIAN -extern unsigned short SwapSHORT(unsigned short); -extern unsigned int SwapLONG(unsigned int); -#define SHORT(x) ((short)SwapSHORT((unsigned short) (x))) -#define LONG(x) ((int)SwapLONG((unsigned int) (x))) -#else -#define SHORT(x) (x) -#define LONG(x) (x) -#endif +// Just use SDL's endianness swapping functions. +#define SHORT(x) SDL_SwapLE16(x) +#define LONG(x) SDL_SwapLE32(x) +// Defines for checking the endianness of the system. +#if SDL_BYTEORDER == SYS_LIL_ENDIAN +#define SYS_LITTLE_ENDIAN +#elif SDL_BYTEORDER == SYS_BIG_ENDIAN +#define SYS_BIG_ENDIAN #endif + +#endif + diff --git a/src/i_video.c b/src/i_video.c index bbf35326..3718f612 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -39,9 +39,9 @@ #include "d_main.h" #include "i_scale.h" #include "i_system.h" +#include "i_swap.h" #include "i_timer.h" #include "m_argv.h" -#include "m_swap.h" #include "s_sound.h" #include "sounds.h" #include "v_video.h" diff --git a/src/m_menu.c b/src/m_menu.c index 0df17fa1..b83fca0c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -36,6 +36,7 @@ #include "d_main.h" #include "deh_main.h" +#include "i_swap.h" #include "i_system.h" #include "i_timer.h" #include "i_video.h" @@ -51,7 +52,6 @@ #include "g_game.h" #include "m_argv.h" -#include "m_swap.h" #include "p_saveg.h" #include "s_sound.h" diff --git a/src/m_misc.c b/src/m_misc.c index 6c4d6953..35889492 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -49,12 +49,12 @@ #include "z_zone.h" #include "m_menu.h" -#include "m_swap.h" #include "m_argv.h" #include "net_client.h" #include "w_wad.h" +#include "i_swap.h" #include "i_system.h" #include "i_video.h" #include "v_video.h" diff --git a/src/m_swap.c b/src/m_swap.c deleted file mode 100644 index b5592072..00000000 --- a/src/m_swap.c +++ /dev/null @@ -1,54 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program 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 General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// Endianess handling, swapping 16bit and 32bit. -// -//----------------------------------------------------------------------------- - - - -#include "m_swap.h" - - -#ifdef WORDS_BIGENDIAN - -// Swap 16bit, that is, MSB and LSB byte. -unsigned short SwapSHORT(unsigned short x) -{ - // No masking with 0xFF should be necessary. - return (x>>8) | (x<<8); -} - -// Swapping 32bit. -unsigned int SwapLONG( unsigned int x) -{ - return - (x>>24) - | ((x>>8) & 0xff00) - | ((x<<8) & 0xff0000) - | (x<<24); -} - - -#endif - - @@ -19,16 +19,23 @@ * - Ian Jackson <ian@chiark.greenend.org.uk>. * Still in the public domain. */ -#include "config.h" + +#include "i_swap.h" #include <string.h> /* for memcpy() */ #include <sys/types.h> /* for stupid systems */ #include "md5.h" -#ifdef WORDS_BIGENDIAN -void -byteSwap(UWORD32 *buf, unsigned words) +#ifdef SYS_LITTLE_ENDIAN + +// Little endian system - no byte swapping required + +#define ByteSwapBlock(x) + +#else + +void ByteSwapBlock(UWORD32 *buf, unsigned words) { md5byte *p = (md5byte *)buf; @@ -38,9 +45,8 @@ byteSwap(UWORD32 *buf, unsigned words) p += 4; } while (--words); } -#else -#define byteSwap(buf,words) -#endif + +#endif /* #ifndef SYS_LITTLE_ENDIAN */ /* * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious @@ -80,7 +86,7 @@ MD5_Update(md5_context_t *ctx, md5byte const *buf, unsigned len) } /* First chunk is an odd size */ memcpy((md5byte *)ctx->in + 64 - t, buf, t); - byteSwap(ctx->in, 16); + ByteSwapBlock(ctx->in, 16); MD5_Transform(ctx->buf, ctx->in); buf += t; len -= t; @@ -88,7 +94,7 @@ MD5_Update(md5_context_t *ctx, md5byte const *buf, unsigned len) /* Process data in 64-byte chunks */ while (len >= 64) { memcpy(ctx->in, buf, 64); - byteSwap(ctx->in, 16); + ByteSwapBlock(ctx->in, 16); MD5_Transform(ctx->buf, ctx->in); buf += 64; len -= 64; @@ -133,20 +139,20 @@ MD5_Final(md5byte digest[16], md5_context_t *ctx) if (count < 0) { /* Padding forces an extra block */ memset(p, 0, count + 8); - byteSwap(ctx->in, 16); + ByteSwapBlock(ctx->in, 16); MD5_Transform(ctx->buf, ctx->in); p = (md5byte *)ctx->in; count = 56; } memset(p, 0, count); - byteSwap(ctx->in, 14); + ByteSwapBlock(ctx->in, 14); /* Append length in bits and transform */ ctx->in[14] = ctx->bytes[0] << 3; ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29; MD5_Transform(ctx->buf, ctx->in); - byteSwap(ctx->buf, 4); + ByteSwapBlock(ctx->buf, 4); memcpy(digest, ctx->buf, 16); memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ } @@ -255,3 +261,4 @@ MD5_Transform(UWORD32 buf[4], UWORD32 const in[16]) } #endif + diff --git a/src/mus2mid.c b/src/mus2mid.c index ba93d4a8..603bd020 100644 --- a/src/mus2mid.c +++ b/src/mus2mid.c @@ -26,7 +26,7 @@ #include <stdio.h> #include "doomtype.h" -#include "m_swap.h" +#include "i_swap.h" #include "memio.h" #include "mus2mid.h" diff --git a/src/p_setup.c b/src/p_setup.c index ae89e4c8..f692658a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -32,7 +32,7 @@ #include "z_zone.h" #include "deh_main.h" -#include "m_swap.h" +#include "i_swap.h" #include "m_bbox.h" #include "g_game.h" diff --git a/src/r_data.c b/src/r_data.c index c59baab3..1fdc0a85 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -28,10 +28,10 @@ #include "deh_main.h" +#include "i_swap.h" #include "i_system.h" #include "z_zone.h" -#include "m_swap.h" #include "w_wad.h" diff --git a/src/r_things.c b/src/r_things.c index 8eb28e71..bdcdefd6 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -33,8 +33,8 @@ #include "deh_main.h" #include "doomdef.h" -#include "m_swap.h" +#include "i_swap.h" #include "i_system.h" #include "z_zone.h" #include "w_wad.h" diff --git a/src/st_lib.c b/src/st_lib.c index d22a29ef..11299a91 100644 --- a/src/st_lib.c +++ b/src/st_lib.c @@ -34,8 +34,7 @@ #include "z_zone.h" #include "v_video.h" -#include "m_swap.h" - +#include "i_swap.h" #include "i_system.h" #include "w_wad.h" diff --git a/src/v_video.c b/src/v_video.c index 169311d1..84882186 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -36,7 +36,7 @@ #include "doomdata.h" #include "m_bbox.h" -#include "m_swap.h" +#include "i_swap.h" #include "v_video.h" diff --git a/src/w_wad.c b/src/w_wad.c index 0e438140..892086d7 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -33,7 +33,7 @@ #include <string.h> #include "doomtype.h" -#include "m_swap.h" +#include "i_swap.h" #include "i_system.h" #include "i_video.h" #include "z_zone.h" diff --git a/src/wi_stuff.c b/src/wi_stuff.c index 659ac45c..21809f45 100644 --- a/src/wi_stuff.c +++ b/src/wi_stuff.c @@ -30,9 +30,9 @@ #include "z_zone.h" #include "m_random.h" -#include "m_swap.h" #include "deh_main.h" +#include "i_swap.h" #include "i_system.h" #include "w_wad.h" |