* Implement htons/htonl in common.h just in case.tags/v0.99.beta14
| @@ -30,3 +30,37 @@ typedef long int intptr_t; | |||||
| typedef unsigned long int uintptr_t; | typedef unsigned long int uintptr_t; | ||||
| #endif | #endif | ||||
| #if !defined(HAVE_HTONS) && !defined(HAVE_NETINET_IN_H) | |||||
| # if defined(HAVE_ENDIAN_H) | |||||
| # include <endian.h> | |||||
| # endif | |||||
| static extern inline uint16_t htons(uint16_t x) | |||||
| { | |||||
| #if defined(HAVE_ENDIAN_H) | |||||
| if(__BYTE_ORDER == __BIG_ENDIAN) | |||||
| #else | |||||
| /* This is compile-time optimised with at least -O1 or -Os */ | |||||
| uint32_t const dummy = 0x12345678; | |||||
| if(*(uint8_t const *)&dummy == 0x12) | |||||
| #endif | |||||
| return x; | |||||
| else | |||||
| return (x >> 8) | (x << 8); | |||||
| } | |||||
| static extern inline uint32_t htonl(uint32_t x) | |||||
| { | |||||
| #if defined(HAVE_ENDIAN_H) | |||||
| if(__BYTE_ORDER == __BIG_ENDIAN) | |||||
| #else | |||||
| /* This is compile-time optimised with at least -O1 or -Os */ | |||||
| uint32_t const dummy = 0x12345678; | |||||
| if(*(uint8_t const *)&dummy == 0x12) | |||||
| #endif | |||||
| return x; | |||||
| else | |||||
| return (x >> 24) | ((x >> 8) & 0x0000ff00) | |||||
| | ((x << 8) & 0x00ff0000) | (x << 24); | |||||
| } | |||||
| #endif | |||||
| @@ -61,7 +61,7 @@ dnl conditional builds | |||||
| AC_ARG_ENABLE(doc, | AC_ARG_ENABLE(doc, | ||||
| [ --enable-doc build documentation (needs doxygen and LaTeX)]) | [ --enable-doc build documentation (needs doxygen and LaTeX)]) | ||||
| AC_CHECK_HEADERS(stdio.h stdarg.h signal.h sys/ioctl.h sys/time.h inttypes.h endian.h unistd.h arpa/inet.h) | |||||
| AC_CHECK_HEADERS(stdio.h stdarg.h signal.h sys/ioctl.h sys/time.h inttypes.h endian.h unistd.h arpa/inet.h netinet/in.h) | |||||
| AC_CHECK_FUNCS(signal ioctl vsnprintf getenv putenv strcasecmp htons) | AC_CHECK_FUNCS(signal ioctl vsnprintf getenv putenv strcasecmp htons) | ||||
| AC_CHECK_FUNCS(usleep gettimeofday) | AC_CHECK_FUNCS(usleep gettimeofday) | ||||
| @@ -25,6 +25,8 @@ | |||||
| # endif | # endif | ||||
| # if defined(HAVE_ARPA_INET_H) | # if defined(HAVE_ARPA_INET_H) | ||||
| # include <arpa/inet.h> | # include <arpa/inet.h> | ||||
| # elif defined(HAVE_NETINET_IN_H) | |||||
| # include <netinet/in.h> | |||||
| # endif | # endif | ||||
| # include <stdio.h> | # include <stdio.h> | ||||
| # include <stdlib.h> | # include <stdlib.h> | ||||
| @@ -23,6 +23,8 @@ | |||||
| #if defined(HAVE_ARPA_INET_H) | #if defined(HAVE_ARPA_INET_H) | ||||
| # include <arpa/inet.h> | # include <arpa/inet.h> | ||||
| #elif defined(HAVE_NETINET_IN_H) | |||||
| # include <netinet/in.h> | |||||
| #endif | #endif | ||||
| #include <pango/pango.h> | #include <pango/pango.h> | ||||