kmod-0002-add-backup-implementation-of-be32toh.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. From bda1ed2aefee23b0eedbcd9f82e73c2547908438 Mon Sep 17 00:00:00 2001
  2. From: Randy MacLeod <Randy.MacLeod@windriver.com>
  3. Date: Mon, 29 Sep 2014 12:32:20 +0200
  4. Subject: [PATCH] Add back-up implementation of be32toh()
  5. Older systems may not have the be32toh function defined. Check for this
  6. and fall back to checking the endianness and calling bswap_32 directly
  7. if needed. This works on both old and new systems.
  8. [Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>:
  9. address comments raised by Lucas De Marchi [1], update commit message]
  10. Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
  11. Upstream-status: accepted [2]
  12. [1] http://www.spinics.net/lists/linux-modules/msg01129.html
  13. [2] https://git.kernel.org/cgit/utils/kernel/kmod/kmod.git/commit/?id=9b34db1ae63427269f918b2868b4cfcb50e6259b
  14. ---
  15. configure.ac | 3 +++
  16. libkmod/libkmod-signature.c | 1 +
  17. libkmod/missing.h | 10 ++++++++++
  18. 3 files changed, 14 insertions(+), 0 deletions(-)
  19. diff --git a/configure.ac b/configure.ac
  20. index 7781ce1..cd676bc 100644
  21. --- a/configure.ac
  22. +++ b/configure.ac
  23. @@ -53,6 +53,9 @@ AC_CHECK_MEMBERS([struct stat.st_mtim], [], [], [#include <sys/stat.h>])
  24. # musl 1.0 and bionic 4.4 don't have strndupa
  25. AC_CHECK_DECLS_ONCE([strndupa])
  26. +# RHEL 5 and older do not have be32toh
  27. +AC_CHECK_DECLS_ONCE([be32toh])
  28. +
  29. # Check kernel headers
  30. AC_CHECK_HEADERS_ONCE([linux/module.h])
  31. diff --git a/libkmod/libkmod-signature.c b/libkmod/libkmod-signature.c
  32. index a3ac15e..28f993e 100644
  33. --- a/libkmod/libkmod-signature.c
  34. +++ b/libkmod/libkmod-signature.c
  35. @@ -25,6 +25,7 @@
  36. #include <stdio.h>
  37. #include "libkmod-internal.h"
  38. +#include "missing.h"
  39. /* These types and tables were copied from the 3.7 kernel sources.
  40. * As this is just description of the signature format, it should not be
  41. diff --git a/libkmod/missing.h b/libkmod/missing.h
  42. index 8d47af8..4c0d136 100644
  43. --- a/libkmod/missing.h
  44. +++ b/libkmod/missing.h
  45. @@ -43,3 +43,13 @@ static inline int finit_module(int fd, const char *uargs, int flags)
  46. memcpy(__new, __old, __len); \
  47. })
  48. #endif
  49. +
  50. +#if !HAVE_DECL_BE32TOH
  51. +#include <endian.h>
  52. +#include <byteswap.h>
  53. +#if __BYTE_ORDER == __LITTLE_ENDIAN
  54. +#define be32toh(x) bswap_32 (x)
  55. +#else
  56. +#define be32toh(x) (x)
  57. +#endif
  58. +#endif
  59. --
  60. 1.7.1