summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Gusarov <dottedmag@dottedmag.net>2008-09-25 09:25:50 +0700
committerMikhail Gusarov <dottedmag@dottedmag.net>2008-09-25 09:25:50 +0700
commit6aff694ae314690882e794e4e80c57c829bbc92d (patch)
tree3535b3c414f241ab8beaee51d724b6c36055683c
parent2494b5b85995fd95fd6249d1a7c88462f355d9fb (diff)
downloadlibsha1-6aff694ae314690882e794e4e80c57c829bbc92d.tar.gz
Endianness detection replaced with autoconf test
-rw-r--r--brg_endian.h99
-rw-r--r--config.h.in4
-rw-r--r--configure.ac2
3 files changed, 12 insertions, 93 deletions
diff --git a/brg_endian.h b/brg_endian.h
index a62e433..e3c1402 100644
--- a/brg_endian.h
+++ b/brg_endian.h
@@ -33,104 +33,17 @@
#ifndef BRG_ENDIAN_H
#define BRG_ENDIAN_H
-#define IS_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */
-#define IS_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */
-
-/* Include files where endian defines and byteswap functions may reside */
-#if defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined( __NetBSD__ )
-# include <sys/endian.h>
-#elif defined( BSD ) && ( BSD >= 199103 ) || defined( __APPLE__ ) || \
- defined( __CYGWIN32__ ) || defined( __DJGPP__ ) || defined( __osf__ )
-# include <machine/endian.h>
-#elif defined( __linux__ ) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
-# if !defined( __MINGW32__ )
-# include <endian.h>
-# if !defined( __BEOS__ )
-# include <byteswap.h>
-# endif
-# endif
-#endif
-
-/* Now attempt to set the define for platform byte order using any */
-/* of the four forms SYMBOL, _SYMBOL, __SYMBOL & __SYMBOL__, which */
-/* seem to encompass most endian symbol definitions */
-
-#if defined( BIG_ENDIAN ) && defined( LITTLE_ENDIAN )
-# if defined( BYTE_ORDER ) && BYTE_ORDER == BIG_ENDIAN
-# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
-# elif defined( BYTE_ORDER ) && BYTE_ORDER == LITTLE_ENDIAN
-# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-# endif
-#elif defined( BIG_ENDIAN )
-# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
-#elif defined( LITTLE_ENDIAN )
-# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-#endif
-
-#if defined( _BIG_ENDIAN ) && defined( _LITTLE_ENDIAN )
-# if defined( _BYTE_ORDER ) && _BYTE_ORDER == _BIG_ENDIAN
-# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
-# elif defined( _BYTE_ORDER ) && _BYTE_ORDER == _LITTLE_ENDIAN
-# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-# endif
-#elif defined( _BIG_ENDIAN )
-# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
-#elif defined( _LITTLE_ENDIAN )
-# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-#endif
-
-#if defined( __BIG_ENDIAN ) && defined( __LITTLE_ENDIAN )
-# if defined( __BYTE_ORDER ) && __BYTE_ORDER == __BIG_ENDIAN
-# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
-# elif defined( __BYTE_ORDER ) && __BYTE_ORDER == __LITTLE_ENDIAN
-# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-# endif
-#elif defined( __BIG_ENDIAN )
-# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
-#elif defined( __LITTLE_ENDIAN )
-# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-#endif
-
-#if defined( __BIG_ENDIAN__ ) && defined( __LITTLE_ENDIAN__ )
-# if defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __BIG_ENDIAN__
-# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
-# elif defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __LITTLE_ENDIAN__
-# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-# endif
-#elif defined( __BIG_ENDIAN__ )
-# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
-#elif defined( __LITTLE_ENDIAN__ )
-# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
+#if defined(HAVE_CONFIG_H)
+# include "config.h"
#endif
-/* if the platform byte order could not be determined, then try to */
-/* set this define using common machine defines */
-#if !defined(PLATFORM_BYTE_ORDER)
-
-#if defined( __alpha__ ) || defined( __alpha ) || defined( i386 ) || \
- defined( __i386__ ) || defined( _M_I86 ) || defined( _M_IX86 ) || \
- defined( __OS2__ ) || defined( sun386 ) || defined( __TURBOC__ ) || \
- defined( vax ) || defined( vms ) || defined( VMS ) || \
- defined( __VMS ) || defined( _M_X64 )
-# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-
-#elif 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( __VOS__ ) || defined( __TIGCC__ ) || defined( __TANDEM ) || \
- defined( THINK_C ) || defined( __VMCMS__ )
-# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
+#define IS_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */
+#define IS_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */
-#elif 0 /* **** EDIT HERE IF NECESSARY **** */
-# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
-#elif 0 /* **** EDIT HERE IF NECESSARY **** */
+#if defined(WORDS_BIGENDIAN)
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
#else
-# error Please edit lines 126 or 128 in brg_endian.h to set the platform byte order
-#endif
-
+# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
#endif
#endif
diff --git a/config.h.in b/config.h.in
index b92d902..aa9477e 100644
--- a/config.h.in
+++ b/config.h.in
@@ -57,5 +57,9 @@
/* Version number of package */
#undef VERSION
+/* Define to 1 if your processor stores words with the most significant byte
+ first (like Motorola and SPARC, unlike Intel and VAX). */
+#undef WORDS_BIGENDIAN
+
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
diff --git a/configure.ac b/configure.ac
index 8213b27..608c88c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,6 +11,8 @@ AC_PROG_LIBTOOL
AC_HEADER_STDC
AC_CHECK_HEADERS([limits.h stdlib.h string.h])
+AC_C_BIGENDIAN
+
AC_C_CONST
AC_CONFIG_FILES([Makefile])