2
0
mirror of https://github.com/vasi/pixz synced 2024-11-16 21:26:04 +00:00

autoconf checks for htole64 and le64toh

- addresses #52
This commit is contained in:
Christian Krause 2015-09-20 21:49:33 +02:00
parent 8d318b90fc
commit 5d831e6d1b
2 changed files with 22 additions and 0 deletions

View File

@ -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

View File

@ -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);
}