From fd93d236b14197cdf6e670703dec5a7bd15f12d2 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Thu, 19 May 2016 11:42:22 +0900 Subject: [PATCH] opal/util/ethtool: fix compilation on older Linux when struct ethtool_cmd has no speed_hi field Refs: open-mpi/ompi#1628 --- configure.ac | 36 ++++++++++++++++++++++++++++++++++++ opal/util/ethtool.c | 8 +++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 158fae0abf..b90674118c 100644 --- a/configure.ac +++ b/configure.ac @@ -653,6 +653,42 @@ AC_CHECK_DECLS([ethtool_cmd_speed, SIOCETHTOOL], #include #endif]) +AC_CHECK_MEMBERS([struct ethtool_cmd.speed_hi], + [], [], [AC_INCLUDES_DEFAULT +#ifdef HAVE_LINUX_ETHTOOL_H +#include +#endif +#ifdef HAVE_LINUX_SOCKIOS_H +#include +#endif]) + +AC_CHECK_MEMBERS([struct ethtool_cmd.speed_hi], + [], [], [AC_INCLUDES_DEFAULT +#ifdef HAVE_LINUX_ETHTOOL_H +#include +#endif +#ifdef HAVE_LINUX_SOCKIOS_H +#include +#endif]) + +AC_CHECK_MEMBERS([struct ethtool_cmd.speed_hi], + [], [], [AC_INCLUDES_DEFAULT +#ifdef HAVE_LINUX_ETHTOOL_H +#include +#endif +#ifdef HAVE_LINUX_SOCKIOS_H +#include +#endif]) + +AC_CHECK_MEMBERS([struct ethtool_cmd.speed_hi], + [], [], [AC_INCLUDES_DEFAULT +#ifdef HAVE_LINUX_ETHTOOL_H +#include +#endif +#ifdef HAVE_LINUX_SOCKIOS_H +#include +#endif]) + AC_CHECK_DECLS([AF_UNSPEC, PF_UNSPEC, AF_INET6, PF_INET6], [], [], [AC_INCLUDES_DEFAULT #if HAVE_SYS_SOCKET_H diff --git a/opal/util/ethtool.c b/opal/util/ethtool.c index 91a4a7ed64..ad3358227d 100644 --- a/opal/util/ethtool.c +++ b/opal/util/ethtool.c @@ -1,5 +1,7 @@ /* * Copyright (c) 2016 Karol Mroz. All rights reserved. + * Copyright (c) 2016 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -31,11 +33,15 @@ #include "opal/util/ethtool.h" #include "opal/util/if.h" -#if !defined(HAVE_DECL_ETHTOOL_CMD_SPEED) +#if ! HAVE_DECL_ETHTOOL_CMD_SPEED static inline unsigned int ethtool_cmd_speed(const struct ethtool_cmd *ep) { +#ifdef HAVE_STRUCT_ETHTOOL_CMD_SPEED_HI return (ep->speed_hi << 16) | ep->speed; +#else + return ep->speed; +#endif } #endif