If both, BYTE_ORDER and BIG_ENDIAN, are undefined, the statement
#if BYTE_ORDER == BIG_ENDIAN
will be evaluated to `true', which may cause `ntohll' and `htonll' to behave
weird.
AC_HEADER_SYS_WAIT
AC_HEADER_DIRENT
-AC_CHECK_HEADERS(stdint.h stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h)
+AC_CHECK_HEADERS(stdint.h stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h)
# For ping library
AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
# endif /* !defined(isnan) */
#endif /* NAN_ZERO_ZERO */
+#if HAVE_ENDIAN_H
+# include <endian.h>
+#endif
+
+#ifndef BYTE_ORDER
+# ifdef __BYTE_ORDER
+# define BYTE_ORDER __BYTE_ORDER
+# endif
+#endif
+#ifndef BIG_ENDIAN
+# ifdef __BIG_ENDIAN
+# define BIG_ENDIAN __BIG_ENDIAN
+# endif
+#endif
+#if !defined(BYTE_ORDER) || !defined(BIG_ENDIAN)
+# error "Cannot determine byte order"
+#endif
+
#if HAVE_DIRENT_H
# include <dirent.h>
# define NAMLEN(dirent) strlen((dirent)->d_name)
# include "config.h"
#endif
+#include "collectd.h"
#include "common.h"
#include "plugin.h"
unsigned long long ntohll (unsigned long long n)
{
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if BYTE_ORDER == BIG_ENDIAN
return (n);
#else
return (((unsigned long long) ntohl (n)) << 32) + ntohl (n >> 32);
unsigned long long htonll (unsigned long long n)
{
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if BYTE_ORDER == BIG_ENDIAN
return (n);
#else
return (((unsigned long long) htonl (n)) << 32) + htonl (n >> 32);