Skip to contentSkip to conversation

ethtool: Work around old <linux/types.h> without big-endian types

PATCH New Ben Hutchings 1 participant 1 message Nov 23, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ethtool: Work around old <linux/types.h> without big-endian types

Add an autoconf test for whether __be16 and __be32 are defined. If not, define them in ethtool-util.h.

---
__be16 and __be32 were not included in the userland version of <linux/types.h> before Linux 2.6.10.

Ben.

 configure.ac   |    7 +++++++
 ethtool-util.h |    6 ++++++
 2 files changed, 13 insertions(+), 0 deletions(-)
configure.ac +7 -0
index f2401a4..2e31e3a 100644
@@ -17,6 +17,13 @@ dnl Checks for header files.
 AC_CHECK_HEADERS(sys/ioctl.h)
 
 dnl Checks for typedefs, structures, and compiler characteristics.
+AC_MSG_CHECKING([whether <linux/types.h> defines big-endian types])
+AC_TRY_COMPILE([#include <linux/types.h>],
+	       [__be16 foo;__be32 bar;],
+	       [AC_MSG_RESULT(yes)
+		AC_DEFINE([HAVE_BE_TYPES], [1],
+			  [Define to 1 if <linux/types.h> defines big-endian types])],
+	       [AC_MSG_RESULT(no)])
 
 dnl Checks for library functions.
 AC_HEADER_STDC
ethtool-util.h +6 -0
index 4ef3a9f..f053028 100644
@@ -6,6 +6,12 @@
 #include <sys/types.h>
 #include <endian.h>
 
+/* ethtool.h expects these to be defined by <linux/types.h> */
+#ifndef HAVE_BE_TYPES
+typedef __uint16_t __be16;
+typedef __uint32_t __be32;
+#endif
+
 #include "ethtool-copy.h"
 
 typedef unsigned long long u64;
Signature · 7 lines
1.5.4


-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.