Merge pull request #53 from wookietreiber/endian-conversion-checks

autoconf checks for htole64 and le64toh
pull/61/head
Christian Krause 9 years ago
commit b263b1c6e1

@ -54,6 +54,12 @@ AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STRTOD
AC_CHECK_FUNCS([memchr memmove memset strerror strtol])
AC_CHECK_DECLS([htole64, le64toh],
[],
[
AC_CHECK_DECLS([htole64, le64toh], [], [], [#include <endian.h>])
],
[#include <sys/endian.h>])
AC_CONFIG_FILES([Makefile
src/Makefile

@ -19,6 +19,22 @@ void xle64enc(uint8_t *d, uint64_t n) {
#include <sys/endian.h>
#endif
#if !HAVE_DECL_HTOLE64
# if __BYTE_ORDER == __LITTLE_ENDIAN
# define htole64(x) (x)
# else
# define htole64(x) __bswap_64 (x)
# endif
#endif
#if !HAVE_DECL_LE64TOH
# if __BYTE_ORDER == __LITTLE_ENDIAN
# define le64toh(x) (x)
# else
# define le64toh(x) __bswap_64 (x)
# endif
#endif
uint64_t xle64dec(const uint8_t *d) {
return le64toh(*(uint64_t*)d);
}

Loading…
Cancel
Save