diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2022-11-10 10:35:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-10 10:35:58 +0100 |
commit | 1f1074f8fbed46077ddc05dae92af95fecc78a33 (patch) | |
tree | cd973b0341e13e489b98e8c1c3a39ff594be3d44 /psutil/_psutil_linux.c | |
parent | 6941261ad010d4d1e936af22fec224e9900509c0 (diff) | |
download | psutil-1f1074f8fbed46077ddc05dae92af95fecc78a33.tar.gz |
#2164: fix compilation failures on linux < 2.6.27 / CentOS 5 (#2171)
Diffstat (limited to 'psutil/_psutil_linux.c')
-rw-r--r-- | psutil/_psutil_linux.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/psutil/_psutil_linux.c b/psutil/_psutil_linux.c index 0bacb204..f04fe776 100644 --- a/psutil/_psutil_linux.c +++ b/psutil/_psutil_linux.c @@ -78,10 +78,16 @@ ioprio_set(int which, int who, int ioprio) { return syscall(__NR_ioprio_set, which, who, ioprio); } -// defined in linux/ethtool.h but not always available (e.g. Android) +// * defined in linux/ethtool.h but not always available (e.g. Android) +// * #ifdef check needed for old kernels, see: +// https://github.com/giampaolo/psutil/issues/2164 static inline uint32_t psutil_ethtool_cmd_speed(const struct ethtool_cmd *ecmd) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) + return ecmd->speed; +#else return (ecmd->speed_hi << 16) | ecmd->speed; +#endif } #define IOPRIO_CLASS_SHIFT 13 |