netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] ethtool.h: define DIV_ROUND_UP for userland
@ 2016-03-01 15:20 Nicolas Dichtel
  2016-03-01 15:29 ` Ben Hutchings
  2016-03-01 16:42 ` [PATCH net-next] ethtool.h: define DIV_ROUND_UP for userland David Miller
  0 siblings, 2 replies; 19+ messages in thread
From: Nicolas Dichtel @ 2016-03-01 15:20 UTC (permalink / raw)
  To: davem; +Cc: netdev, Nicolas Dichtel, Nikolay Aleksandrov, Kan Liang

DIV_ROUND_UP and is defined in linux/kernel.h only for the kernel. INT_MAX
needs limits.h in userland.

When ethtool.h is included by a userland app, we got the following errors:

include/linux/ethtool.h:1218:8: error: variably modified 'queue_mask' at file scope
  __u32 queue_mask[DIV_ROUND_UP(MAX_NUM_QUEUE, 32)];
        ^

.../usr/include/linux/ethtool.h: In function 'ethtool_validate_speed':
.../usr/include/linux/ethtool.h:1471:18: error: 'INT_MAX' undeclared (first use in this function)
  return speed <= INT_MAX || speed == SPEED_UNKNOWN
                  ^

Fixes: ac2c7ad0e5d6 ("net/ethtool: introduce a new ioctl for per queue setting")
Fixes: e02564ee334a ("ethtool: make validate_speed accept all speeds between 0 and INT_MAX")
CC: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
CC: Kan Liang <kan.liang@intel.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 include/uapi/linux/ethtool.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 37fd6dc33de4..d4e1351fe9b5 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -16,6 +16,11 @@
 #include <linux/types.h>
 #include <linux/if_ether.h>
 
+#ifndef __KERNEL__
+#include <limits.h> /* for INT_MAX */
+#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
+#endif
+
 /* All structures exposed to userland should be defined such that they
  * have the same layout for 32-bit and 64-bit userland.
  */
-- 
2.4.2

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2016-03-04 21:36 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-01 15:20 [PATCH net-next] ethtool.h: define DIV_ROUND_UP for userland Nicolas Dichtel
2016-03-01 15:29 ` Ben Hutchings
2016-03-01 16:41   ` [PATCH net-next v2 1/2] uapi: " Nicolas Dichtel
2016-03-01 16:41     ` [PATCH net-next v2 2/2] ethtool.h: define INT_MAX " Nicolas Dichtel
2016-03-03 21:43       ` David Miller
2016-03-03 21:43     ` [PATCH net-next v2 1/2] uapi: define DIV_ROUND_UP " David Miller
2016-03-03 22:08       ` David Miller
2016-03-04 10:52         ` [PATCH net-next v3 0/4] uapi: consolidate DIV_ROUND_UP definition Nicolas Dichtel
2016-03-04 10:52           ` [PATCH net-next v3 1/4] uapi: define DIV_ROUND_UP for userland Nicolas Dichtel
2016-03-04 10:52           ` [PATCH net-next v3 2/4] cxgb4i: don't redefine DIV_ROUND_UP Nicolas Dichtel
2016-03-04 10:52           ` [PATCH net-next v3 3/4] drm/vmwgfx: remove userland definition of DIV_ROUND_UP Nicolas Dichtel
2016-03-04 21:36             ` Emil Velikov
2016-03-04 10:52           ` [PATCH net-next v3 4/4] ethtool.h: define INT_MAX for userland Nicolas Dichtel
2016-03-04 13:10             ` Nikolay Aleksandrov
2016-03-04 21:10           ` [PATCH net-next v3 0/4] uapi: consolidate DIV_ROUND_UP definition David Miller
2016-03-01 16:42 ` [PATCH net-next] ethtool.h: define DIV_ROUND_UP for userland David Miller
2016-03-01 17:14   ` Ben Hutchings
2016-03-01 19:48     ` David Miller
2016-03-01 20:06       ` Ben Hutchings

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).