Mercurial > hg > waaad
changeset 325:4e96f59da35f
Simplified endianness tests, removed strange cases (PDP, ...)
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Wed, 18 Mar 2009 18:29:45 +0900 |
parents | a18fd5d9a1ec |
children | fd2b783a8561 |
files | waaad/CMakeLists.txt waaad/utils.h waaad/waaad-host.h.in |
diffstat | 3 files changed, 14 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/waaad/CMakeLists.txt Wed Mar 18 17:52:19 2009 +0900 +++ b/waaad/CMakeLists.txt Wed Mar 18 18:29:45 2009 +0900 @@ -20,6 +20,7 @@ INCLUDE (CheckFunctionExists) INCLUDE (CheckIncludeFiles) INCLUDE (CheckSymbolExists) +INCLUDE (TestBigEndian) # We use dlopen and dlclose SET(WAAAD_LIBS ${WAAAD_LIBS} ${CMAKE_DL_LIBS}) @@ -58,11 +59,9 @@ ENDIF(NOT HAVE_NATIVE_SCTP) ENDIF(NOT DISABLE_SCTP) -# We need the __BYTE_ORDER definition ( sys/param.h ) -CHECK_SYMBOL_EXISTS(__BYTE_ORDER "sys/param.h" HAVE___BYTE_ORDER) -IF (NOT HAVE___BYTE_ORDER) - MESSAGE(SEND_ERROR "The __BYTE_ORDER is not found, please hack the code to fix this") -ENDIF (NOT HAVE___BYTE_ORDER) + +# Check byte ordering +TEST_BIG_ENDIAN(HOST_BIG_ENDIAN) # We need the getopt_long function
--- a/waaad/utils.h Wed Mar 18 17:52:19 2009 +0900 +++ b/waaad/utils.h Wed Mar 18 18:29:45 2009 +0900 @@ -41,6 +41,8 @@ #ifndef _UTILS_H #define _UTILS_H +#include "waaad-host.h" + #include <stdio.h> #include <string.h> @@ -288,31 +290,16 @@ /* We provide macros to convert 64 bit values to and from network byte-order, on systems where it is not already provided. */ #ifndef HAVE_NTOHLL /* Defined in config.h, if the ntohll symbol is defined on the system */ -# ifdef __BYTE_ORDER -# if __BYTE_ORDER == __LITTLE_ENDIAN +# if HOST_BIG_ENDIAN + /* In big-endian systems, we don't have to change the values, since the order is the same as network */ +# define ntohll(x) (x) +# define htonll(x) (x) +# else /* HOST_BIG_ENDIAN */ /* For these systems, we must reverse the bytes. Use ntohl and htonl on sub-32 blocs, and inverse these blocs. */ # define ntohll(x) (typeof (x))( (((uint64_t)ntohl( (uint32_t)(x))) << 32 ) | ((uint64_t) ntohl( ((uint64_t)(x)) >> 32 ))) # define htonll(x) (typeof (x))( (((uint64_t)htonl( (uint32_t)(x))) << 32 ) | ((uint64_t) htonl( ((uint64_t)(x)) >> 32 ))) -# else /* ! __LITTLE_ENDIAN */ -# if __BYTE_ORDER == __BIG_ENDIAN - /* In big-endian systems, we don't have to change the values, since the order is the same as network */ -# define ntohll(x) (x) -# define htonll(x) (x) -# else /* ! __BIG_ENDIAN */ -# if __BYTE_ORDER == __PDP_ENDIAN - /* We don't support these systems currently */ -# error "Unsupported byte order: PDP. Please provide implementation for ntohll and htonll" -# else /* ! __PDP_ENDIAN */ - /* What is the byte order then??? */ -# error "Unknown byte order" -# endif /* __PDP_ENDIAN */ -# endif /* __BIG_ENDIAN */ -# endif /* __LITTLE_ENDIAN */ -# else /* __BYTE_ORDER */ -# error "__BYTE_ORDER is not defined, and configure did not detect that. -- or you forgot to include <config.h> ?" -# endif /* __BYTE_ORDER */ +# endif /* HOST_BIG_ENDIAN */ #endif /* HAVE_NTOHLL */ - /*
--- a/waaad/waaad-host.h.in Wed Mar 18 17:52:19 2009 +0900 +++ b/waaad/waaad-host.h.in Wed Mar 18 18:29:45 2009 +0900 @@ -40,6 +40,8 @@ #cmakedefine HAVE_NTOHLL #cmakedefine HAVE_MALLOC_H +#cmakedefine HOST_BIG_ENDIAN @HOST_BIG_ENDIAN@ + #cmakedefine DISABLE_SCTP #cmakedefine PROJECT_NAME "@PROJECT_NAME@"