Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

libbpf: Avoid inline hint definition from 'linux/stddef.h'

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

authored by

Pedro Tammela and committed by
Andrii Nakryiko
0205e9de 6503b9f2

+3 -2
+3 -2
tools/lib/bpf/bpf_helpers.h
··· 29 29 */ 30 30 #define SEC(NAME) __attribute__((section(NAME), used)) 31 31 32 - #ifndef __always_inline 32 + /* Avoid 'linux/stddef.h' definition of '__always_inline'. */ 33 + #undef __always_inline 33 34 #define __always_inline inline __attribute__((always_inline)) 34 - #endif 35 + 35 36 #ifndef __noinline 36 37 #define __noinline __attribute__((noinline)) 37 38 #endif