Older systems may not have the be32toh function defined. Check for this
and fall back to checking the endianness and calling bswap_32 directly
if needed. This works on both old and new systems.
[Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>:
address comments raised by Lucas De Marchi [1], update commit message]
[1] http://www.spinics.net/lists/linux-modules/msg01129.html
# musl 1.0 and bionic 4.4 don't have strndupa
AC_CHECK_DECLS_ONCE([strndupa])
+# RHEL 5 and older do not have be32toh
+AC_CHECK_DECLS_ONCE([be32toh])
+
# Check kernel headers
AC_CHECK_HEADERS_ONCE([linux/module.h])
#include <stdio.h>
#include "libkmod-internal.h"
+#include "missing.h"
/* These types and tables were copied from the 3.7 kernel sources.
* As this is just description of the signature format, it should not be
memcpy(__new, __old, __len); \
})
#endif
+
+#if !HAVE_DECL_BE32TOH
+#include <endian.h>
+#include <byteswap.h>
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define be32toh(x) bswap_32 (x)
+#else
+#define be32toh(x) (x)
+#endif
+#endif