libbpf: Avoid inline hint definition from 'linux/stddef.h'
authorPedro Tammela <pctammela@gmail.com>
Sun, 14 Mar 2021 17:38:38 +0000 (18:38 +0100)
committerAndrii Nakryiko <andrii@kernel.org>
Tue, 16 Mar 2021 05:11:17 +0000 (22:11 -0700)
Linux headers might pull 'linux/stddef.h' which defines
'__always_inline' as the following:

   #ifndef __always_inline
   #define __always_inline inline
   #endif

This becomes an issue if the program picks up the 'linux/stddef.h'
definition as the macro now just hints inline to clang.

This change now enforces the proper definition for BPF programs
regardless of the include order.

Signed-off-by: Pedro Tammela <pctammela@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210314173839.457768-1-pctammela@gmail.com
tools/lib/bpf/bpf_helpers.h

index ae6c975e0b87b6ea080be00c53bebba7ba81ba28..53ff81c49dbd91cd1069e07df139f8a1fa4ec702 100644 (file)
  */
 #define SEC(NAME) __attribute__((section(NAME), used))
 
-#ifndef __always_inline
+/* Avoid 'linux/stddef.h' definition of '__always_inline'. */
+#undef __always_inline
 #define __always_inline inline __attribute__((always_inline))
-#endif
+
 #ifndef __noinline
 #define __noinline __attribute__((noinline))
 #endif