]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Add back-up implementation of be32toh()
authorRandy MacLeod <Randy.MacLeod@windriver.com>
Mon, 29 Sep 2014 19:18:04 +0000 (21:18 +0200)
committerLucas De Marchi <lucas.demarchi@intel.com>
Mon, 29 Sep 2014 20:13:26 +0000 (17:13 -0300)
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

configure.ac
libkmod/libkmod-signature.c
libkmod/missing.h

index 7781ce1756a343f2bf3b4e0c4611f765bbc15785..cd676bc1ca713678c24a3a623ac6d313afe17ab3 100644 (file)
@@ -53,6 +53,9 @@ AC_CHECK_MEMBERS([struct stat.st_mtim], [], [], [#include <sys/stat.h>])
 # 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])
 
index a3ac15e6230d2f7791cf699680be04dc1dc6cc2d..28f993e021bedb3ec860232033fdd6cde3d633e8 100644 (file)
@@ -25,6 +25,7 @@
 #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
index 8d47af865ceab8b8c27a80e31d7d62c66963e8ca..4c0d136e4ca5cdf73f5b1541dcf40b71ada896c2 100644 (file)
@@ -43,3 +43,13 @@ static inline int finit_module(int fd, const char *uargs, int flags)
                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