Browse Source

update bigendian

pull/4/merge
Max Lv 12 years ago
parent
commit
4b74df3c16
4 changed files with 26 additions and 23 deletions
  1. 24
      config.h.in
  2. 21
      configure.ac
  3. 4
      encrypt.c
  4. 0
      encrypt.h

24
config.h.in

@ -1,11 +1,14 @@
/* config.h.in. Generated from configure.ac by autoheader. */ /* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if system is big endian */
#undef BIGENDIAN
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
/* Define to 1 if you have the <arpa/inet.h> header file. */ /* Define to 1 if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H #undef HAVE_ARPA_INET_H
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <fcntl.h> header file. */ /* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H #undef HAVE_FCNTL_H
@ -61,8 +64,9 @@
/* Define to 1 if you have the <unistd.h> header file. */ /* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H #undef HAVE_UNISTD_H
/* Define to 1 if system is little endian */
#undef LITTLEENDIAN
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Name of package */ /* Name of package */
#undef PACKAGE #undef PACKAGE
@ -91,6 +95,18 @@
/* Version number of package */ /* Version number of package */
#undef VERSION #undef VERSION
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
# undef WORDS_BIGENDIAN
# endif
#endif
/* Define to `__inline__' or `__inline' if that's what the C compiler /* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */ calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus #ifndef __cplusplus

21
configure.ac

@ -10,30 +10,17 @@ AM_INIT_AUTOMAKE([foreign -Wall -Werror])
# Checks for programs. # Checks for programs.
AC_PROG_CC AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LIBTOOL
# Checks for libraries. # Checks for libraries.
AC_SEARCH_LIBS([MD5], [crypto], [ ], AC_MSG_ERROR([libcrypto not found.])) AC_SEARCH_LIBS([MD5], [crypto], [ ], AC_MSG_ERROR([libcrypto not found.]))
AC_SEARCH_LIBS([ev_io_start], [ev], [ ], AC_MSG_ERROR([libev not found.]))
dnl AC_SEARCH_LIBS([ev_io_start], [ev], [ ], AC_MSG_ERROR([libev not found.]))
# Checks for header files. # Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h fcntl.h langinfo.h locale.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/socket.h unistd.h]) AC_CHECK_HEADERS([arpa/inet.h fcntl.h langinfo.h locale.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/socket.h unistd.h])
[echo -n "checking for little or big endian... " ]
AC_TRY_RUN([
#include <sys/types.h>
int main()
{
uint16_t s = 1;
uint16_t* ptr = &s;
uint8_t n = *((uint8_t*)ptr);
return n;
}
]
, AC_DEFINE([BIGENDIAN], [1], [Define to 1 if system is big endian])
[echo "big"]
, AC_DEFINE([LITTLEENDIAN], [1], [Define to 1 if system is little endian])
[echo "little"]
)
AC_C_BIGENDIAN
# Checks for typedefs, structures, and compiler characteristics. # Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE AC_C_INLINE

4
encrypt.c

@ -6,9 +6,9 @@
#include "encrypt.h" #include "encrypt.h"
#ifdef BIGENDIAN
#ifdef WORDS_BIGENDIAN
#include <endian.h> #include <endian.h>
#elif LITTLEENDIAN
#else
#define htole64(x) (x) #define htole64(x) (x)
#endif #endif

0
encrypt.h

Loading…
Cancel
Save