xdp-project / xdp-tools

Utilities and example programs for use with XDP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Undefined XDP_ALWAYS_INLINE while building with sparse or non-GNU compiler

igsilya opened this issue · comments

sparse checker doesn't have __GNUC_GNU_INLINE__ or __GNUC_STDC_INLINE__ defined, the same will be true for any non-GNU compiler. This is causing build failures due to XDP_ALWAYS_INLINE being undefined.

The following change fixes the problem and I can submit it as a PR, but I'm not sure if that is a best way fixing it:

diff --git a/headers/xdp/xsk.h b/headers/xdp/xsk.h
index 59add0d..92fb4ab 100644
--- a/headers/xdp/xsk.h
+++ b/headers/xdp/xsk.h
@@ -25,6 +25,8 @@ extern "C" {
 #define XDP_ALWAYS_INLINE inline __attribute__((__always_inline__))
 #elif __GNUC_GNU_INLINE__
 #define XDP_ALWAYS_INLINE static inline __attribute__((__always_inline__))
+#else
+#define XDP_ALWAYS_INLINE static inline
 #endif
 
 /* Do not access these members directly. Use the functions below. */

I don't know why we even need to have a static inline and just inline versions here. Some compilers may not recognize the __always_inline__ attribute though.

Do not know if this is the most general way to fix this, but let us start with this patch that we know works for sparse and go from there.

OK. I'll send a PR.