* [PATCH] Add back-up implementation of be32toh()
@ 2014-09-29 19:18 Thomas De Schampheleire
2014-09-29 20:21 ` Lucas De Marchi
0 siblings, 1 reply; 2+ messages in thread
From: Thomas De Schampheleire @ 2014-09-29 19:18 UTC (permalink / raw)
To: linux-modules; +Cc: Randy MacLeod
From: Randy MacLeod <Randy.MacLeod@windriver.com>
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 | 3 +++
libkmod/libkmod-signature.c | 1 +
libkmod/missing.h | 10 ++++++++++
3 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
index 7781ce1..cd676bc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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])
diff --git a/libkmod/libkmod-signature.c b/libkmod/libkmod-signature.c
index a3ac15e..28f993e 100644
--- a/libkmod/libkmod-signature.c
+++ b/libkmod/libkmod-signature.c
@@ -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
diff --git a/libkmod/missing.h b/libkmod/missing.h
index 8d47af8..4c0d136 100644
--- a/libkmod/missing.h
+++ b/libkmod/missing.h
@@ -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
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Add back-up implementation of be32toh()
2014-09-29 19:18 [PATCH] Add back-up implementation of be32toh() Thomas De Schampheleire
@ 2014-09-29 20:21 ` Lucas De Marchi
0 siblings, 0 replies; 2+ messages in thread
From: Lucas De Marchi @ 2014-09-29 20:21 UTC (permalink / raw)
To: Thomas De Schampheleire; +Cc: linux-modules, Randy MacLeod
Hi Thomas
On Mon, Sep 29, 2014 at 4:18 PM, Thomas De Schampheleire
<patrickdepinguin@gmail.com> wrote:
> From: Randy MacLeod <Randy.MacLeod@windriver.com>
>
> 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
> ---
Applied, thanks
--
Lucas De Marchi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-29 20:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-29 19:18 [PATCH] Add back-up implementation of be32toh() Thomas De Schampheleire
2014-09-29 20:21 ` Lucas De Marchi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.