Commit f9116eab authored by hybrid's avatar hybrid

Use irrlicht defines for endianess, and less memory consuming ops.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2980 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 05e1cf18
...@@ -146,19 +146,6 @@ ...@@ -146,19 +146,6 @@
#if clauses. #if clauses.
*/ */
/* PLATFORM SPECIFIC INCLUDES */
#if defined( __FreeBSD__ ) || defined( __OpenBSD__ )
# include <sys/endian.h>
#elif defined( BSD ) && ( BSD >= 199103 )
# include <machine/endian.h>
#elif defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
# include <endian.h>
# include <byteswap.h>
#elif defined( linux )
# include <endian.h>
#endif
/* BYTE ORDER IN 32-BIT WORDS /* BYTE ORDER IN 32-BIT WORDS
To obtain the highest speed on processors with 32-bit words, this code To obtain the highest speed on processors with 32-bit words, this code
...@@ -173,75 +160,10 @@ ...@@ -173,75 +160,10 @@
#define BRG_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */ #define BRG_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */
#define BRG_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */ #define BRG_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */
#if defined( __alpha__ ) || defined( __alpha ) || defined( i386 ) || \ #ifdef __BIG_ENDIAN__
defined( __i386__ ) || defined( _M_I86 ) || defined( _M_IX86 ) || \
defined( __OS2__ ) || defined( sun386 ) || defined( __TURBOC__ ) || \
defined( vax ) || defined( vms ) || defined( VMS ) || \
defined( __VMS )
#define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
#endif
#if defined( AMIGA ) || defined( applec ) || defined( __AS400__ ) || \
defined( _CRAY ) || defined( __hppa ) || defined( __hp9000 ) || \
defined( ibm370 ) || defined( mc68000 ) || defined( m68k ) || \
defined( __MRC__ ) || defined( __MVS__ ) || defined( __MWERKS__ ) || \
defined( sparc ) || defined( __sparc) || defined( SYMANTEC_C ) || \
defined( __TANDEM ) || defined( THINK_C ) || defined( __VMCMS__ )
#define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
#endif
/* if the platform is still not known, try to find its byte order */
/* from commonly used definitions in the headers included earlier */
#if !defined(PLATFORM_BYTE_ORDER)
#if defined(LITTLE_ENDIAN) || defined(BIG_ENDIAN)
# if defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif !defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# elif defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# endif
#elif defined(_LITTLE_ENDIAN) || defined(_BIG_ENDIAN)
# if defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif !defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# elif defined(_BYTE_ORDER) && (_BYTE_ORDER == _LITTLE_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif defined(_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# endif
#elif defined(__LITTLE_ENDIAN__) || defined(__BIG_ENDIAN__)
# if defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif !defined(__LITTLE_ENDIAN__) && defined(__BIG_ENDIAN__)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __LITTLE_ENDIAN__)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# endif
#elif 0 /* **** EDIT HERE IF NECESSARY **** */
#define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
#elif 0 /* **** EDIT HERE IF NECESSARY **** */
#define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN #define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
#else #else
#error Please edit aesopt.h (line 235 or 238) to set the platform byte order #define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
#endif
#endif #endif
/* SOME LOCAL DEFINITIONS */ /* SOME LOCAL DEFINITIONS */
...@@ -253,14 +175,7 @@ ...@@ -253,14 +175,7 @@
#define PARTIAL 1 #define PARTIAL 1
#define FULL 2 #define FULL 2
#if defined(bswap32) #define aes_sw32 Byteswap::byteswap
#define aes_sw32 bswap32
#elif defined(bswap_32)
#define aes_sw32 bswap_32
#else
#define brot(x,n) (((aes_32t)(x) << n) | ((aes_32t)(x) >> (32 - n)))
#define aes_sw32(x) ((brot((x),8) & 0x00ff00ff) | (brot((x),24) & 0xff00ff00))
#endif
/* 1. FUNCTIONS REQUIRED /* 1. FUNCTIONS REQUIRED
...@@ -381,7 +296,7 @@ ...@@ -381,7 +296,7 @@
If this section is included, tables are used to provide faster finite If this section is included, tables are used to provide faster finite
field arithmetic (this has no effect if FIXED_TABLES is defined). field arithmetic (this has no effect if FIXED_TABLES is defined).
*/ */
#if 1 #if 0
#define FF_TABLES #define FF_TABLES
#endif #endif
...@@ -419,13 +334,13 @@ ...@@ -419,13 +334,13 @@
statically into the binary file. Otherwise the subroutine gen_tabs() statically into the binary file. Otherwise the subroutine gen_tabs()
must be called to compute them before the code is first used. must be called to compute them before the code is first used.
*/ */
#if 1 #if 0
#define FIXED_TABLES #define FIXED_TABLES
#endif #endif
/* 9. TABLE ALIGNMENT /* 9. TABLE ALIGNMENT
On some sytsems speed will be improved by aligning the AES large lookup On some systems speed will be improved by aligning the AES large lookup
tables on particular boundaries. This define should be set to a power of tables on particular boundaries. This define should be set to a power of
two giving the desired alignment. It can be left undefined if alignment two giving the desired alignment. It can be left undefined if alignment
is not needed. This option is specific to the Microsft VC++ compiler - is not needed. This option is specific to the Microsft VC++ compiler -
...@@ -1030,3 +945,4 @@ extern aes_32t t_dec(r,c)[RC_LENGTH]; ...@@ -1030,3 +945,4 @@ extern aes_32t t_dec(r,c)[RC_LENGTH];
#endif #endif
#endif #endif
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <stdlib.h> /* for _lrotl with VC++ */ #include <stdlib.h> /* for _lrotl with VC++ */
#include "sha1.h" #include "sha1.h"
#include "../os.h"
/* /*
To obtain the highest speed on processors with 32-bit words, this code To obtain the highest speed on processors with 32-bit words, this code
...@@ -47,18 +48,6 @@ ...@@ -47,18 +48,6 @@
It may well fail, in which case the definitions will need to be set by It may well fail, in which case the definitions will need to be set by
editing at the points marked **** EDIT HERE IF NECESSARY **** below. editing at the points marked **** EDIT HERE IF NECESSARY **** below.
*/ */
/* PLATFORM SPECIFIC INCLUDES */
#if defined( __FreeBSD__ ) || defined( __OpenBSD__ )
# include <sys/endian.h>
#elif defined( BSD ) && ( BSD >= 199103 )
# include <machine/endian.h>
#elif defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
# include <endian.h>
# include <byteswap.h>
#elif defined( linux )
# include <endian.h>
#endif
/* BYTE ORDER IN 32-BIT WORDS /* BYTE ORDER IN 32-BIT WORDS
...@@ -74,85 +63,18 @@ ...@@ -74,85 +63,18 @@
#define BRG_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */ #define BRG_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */
#define BRG_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */ #define BRG_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */
#if defined( __alpha__ ) || defined( __alpha ) || defined( i386 ) || \ #ifdef __BIG_ENDIAN__
defined( __i386__ ) || defined( _M_I86 ) || defined( _M_IX86 ) || \
defined( __OS2__ ) || defined( sun386 ) || defined( __TURBOC__ ) || \
defined( vax ) || defined( vms ) || defined( VMS ) || \
defined( __VMS )
#define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
#endif
#if defined( AMIGA ) || defined( applec ) || defined( __AS400__ ) || \
defined( _CRAY ) || defined( __hppa ) || defined( __hp9000 ) || \
defined( ibm370 ) || defined( mc68000 ) || defined( m68k ) || \
defined( __MRC__ ) || defined( __MVS__ ) || defined( __MWERKS__ ) || \
defined( sparc ) || defined( __sparc) || defined( SYMANTEC_C ) || \
defined( __TANDEM ) || defined( THINK_C ) || defined( __VMCMS__ )
#define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN #define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
#endif
/* if the platform is still not known, try to find its byte order */
/* from commonly used definitions in the headers included earlier */
#if !defined(PLATFORM_BYTE_ORDER)
#if defined(LITTLE_ENDIAN) || defined(BIG_ENDIAN)
# if defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif !defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# elif defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# endif
#elif defined(_LITTLE_ENDIAN) || defined(_BIG_ENDIAN)
# if defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif !defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# elif defined(_BYTE_ORDER) && (_BYTE_ORDER == _LITTLE_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif defined(_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# endif
#elif defined(__LITTLE_ENDIAN__) || defined(__BIG_ENDIAN__)
# if defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif !defined(__LITTLE_ENDIAN__) && defined(__BIG_ENDIAN__)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __LITTLE_ENDIAN__)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# endif
#elif 0 /* **** EDIT HERE IF NECESSARY **** */
#define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
#elif 0 /* **** EDIT HERE IF NECESSARY **** */
#define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
#else #else
#error Please edit sha1.c (line 141 or 144) to set the platform byte order #define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
#endif
#endif #endif
#define rotl32(x,n) (((x) << n) | ((x) >> (32 - n))) #define rotl32(x,n) (((x) << n) | ((x) >> (32 - n)))
#if (PLATFORM_BYTE_ORDER == BRG_BIG_ENDIAN) #if (PLATFORM_BYTE_ORDER == BRG_BIG_ENDIAN)
#define swap_b32(x) (x) #define swap_b32(x) (x)
#elif defined(bswap_32)
#define swap_b32(x) bswap_32(x)
#else #else
#define swap_b32(x) ((rotl32((x), 8) & 0x00ff00ff) | (rotl32((x), 24) & 0xff00ff00)) #define swap_b32(x) irr::os::Byteswap::byteswap(x)
#endif #endif
#define SHA1_MASK (SHA1_BLOCK_SIZE - 1) #define SHA1_MASK (SHA1_BLOCK_SIZE - 1)
......
...@@ -85,19 +85,7 @@ ...@@ -85,19 +85,7 @@
#include <stdlib.h> /* for _lrotr with VC++ */ #include <stdlib.h> /* for _lrotr with VC++ */
#include "sha2.h" #include "sha2.h"
#include "../os.h"
/* PLATFORM SPECIFIC INCLUDES */
#if defined( __FreeBSD__ ) || defined( __OpenBSD__ )
# include <sys/endian.h>
#elif defined( BSD ) && ( BSD >= 199103 )
# include <machine/endian.h>
#elif defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
# include <endian.h>
# include <byteswap.h>
#elif defined( linux )
# include <endian.h>
#endif
/* BYTE ORDER IN 32-BIT WORDS /* BYTE ORDER IN 32-BIT WORDS
...@@ -113,75 +101,10 @@ ...@@ -113,75 +101,10 @@
#define BRG_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */ #define BRG_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */
#define BRG_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */ #define BRG_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */
#if defined( __alpha__ ) || defined( __alpha ) || defined( i386 ) || \ #ifdef __BIG_ENDIAN__
defined( __i386__ ) || defined( _M_I86 ) || defined( _M_IX86 ) || \
defined( __OS2__ ) || defined( sun386 ) || defined( __TURBOC__ ) || \
defined( vax ) || defined( vms ) || defined( VMS ) || \
defined( __VMS )
#define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
#endif
#if defined( AMIGA ) || defined( applec ) || defined( __AS400__ ) || \
defined( _CRAY ) || defined( __hppa ) || defined( __hp9000 ) || \
defined( ibm370 ) || defined( mc68000 ) || defined( m68k ) || \
defined( __MRC__ ) || defined( __MVS__ ) || defined( __MWERKS__ ) || \
defined( sparc ) || defined( __sparc) || defined( SYMANTEC_C ) || \
defined( __TANDEM ) || defined( THINK_C ) || defined( __VMCMS__ )
#define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
#endif
/* if the platform is still not known, try to find its byte order */
/* from commonly used definitions in the headers included earlier */
#if !defined(PLATFORM_BYTE_ORDER)
#if defined(LITTLE_ENDIAN) || defined(BIG_ENDIAN)
# if defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif !defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# elif defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# endif
#elif defined(_LITTLE_ENDIAN) || defined(_BIG_ENDIAN)
# if defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif !defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# elif defined(_BYTE_ORDER) && (_BYTE_ORDER == _LITTLE_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif defined(_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# endif
#elif defined(__LITTLE_ENDIAN__) || defined(__BIG_ENDIAN__)
# if defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif !defined(__LITTLE_ENDIAN__) && defined(__BIG_ENDIAN__)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __LITTLE_ENDIAN__)
# define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
# elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__)
# define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
# endif
#elif 0 /* **** EDIT HERE IF NECESSARY **** */
#define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
#elif 0 /* **** EDIT HERE IF NECESSARY **** */
#define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN #define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
#else #else
#error Please edit sha2.c (line 180 or 183) to set the platform byte order #define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
#endif
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
......
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