summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 20d7c98)
raw | patch | inline | side by side (parent: 20d7c98)
author | Florian Forster <octo@huhu.verplant.org> | |
Mon, 31 Mar 2008 13:51:13 +0000 (15:51 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Mon, 31 Mar 2008 13:51:13 +0000 (15:51 +0200) |
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.
#if BYTE_ORDER == BIG_ENDIAN
will be evaluated to `true', which may cause `ntohll' and `htonll' to behave
weird.
configure.in | patch | blob | history | |
src/collectd.h | patch | blob | history | |
src/common.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index 17462a12d24380f5190c9a1fb38e12a0bab9f50a..e68d97e2569b4d447f82aa08ecb472d1247ee96e 100644 (file)
--- a/configure.in
+++ b/configure.in
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, [], [],
diff --git a/src/collectd.h b/src/collectd.h
index 9951d8a91013d929bc831a4e40ad49b9bce08893..59dc5d20a10e5e1d02b288c200f81925b44fe204 100644 (file)
--- a/src/collectd.h
+++ b/src/collectd.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)
diff --git a/src/common.c b/src/common.c
index f93cf769432e92f93dffa9661407db9237275690..9314d814ad4d1e02bd5e5a57e361c59d0d801eca 100644 (file)
--- a/src/common.c
+++ b/src/common.c
# 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);