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.

Merge branch 'Provide NULL and KERNEL_VERSION macros in bpf_helpers.h'

Andrii Nakryiko says:

====================

Provide NULL and KERNEL_VERSION macros in bpf_helpers.h. Patch #2 removes such
custom NULL definition from one of the selftests.

v2->v3:
- instead of vmlinux.h, do this in bpf_helpers.h;
- added KERNEL_VERSION, which comes up periodically as well;
- I dropped strict compilation patches for now, because we run into new
warnings (e.g., not checking read() result) in kernel-patches CI, which
I can't even reproduce locally. Also -Wdiscarded-qualifiers pragma for
jit_disasm.c is not supported by Clang, it needs to be
-Wincompatible-pointer-types-discards-qualifiers for Clang; we don't have
to deal with that in this patch set;
v1->v2:
- fix few typos and wrong copy/paste;
- fix #pragma push -> pop.
====================

Signed-off-by: Alexei Starovoitov <ast@kernel.org>

+15 -2
+15 -1
tools/lib/bpf/bpf_helpers.h
··· 40 40 #define __weak __attribute__((weak)) 41 41 #endif 42 42 43 + /* When utilizing vmlinux.h with BPF CO-RE, user BPF programs can't include 44 + * any system-level headers (such as stddef.h, linux/version.h, etc), and 45 + * commonly-used macros like NULL and KERNEL_VERSION aren't available through 46 + * vmlinux.h. This just adds unnecessary hurdles and forces users to re-define 47 + * them on their own. So as a convenience, provide such definitions here. 48 + */ 49 + #ifndef NULL 50 + #define NULL ((void *)0) 51 + #endif 52 + 53 + #ifndef KERNEL_VERSION 54 + #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + ((c) > 255 ? 255 : (c)) 55 + #endif 56 + 43 57 /* 44 - * Helper macro to manipulate data structures 58 + * Helper macros to manipulate data structures 45 59 */ 46 60 #ifndef offsetof 47 61 #define offsetof(TYPE, MEMBER) ((unsigned long)&((TYPE *)0)->MEMBER)
-1
tools/testing/selftests/bpf/progs/skb_pkt_end.c
··· 4 4 #include <bpf/bpf_core_read.h> 5 5 #include <bpf/bpf_helpers.h> 6 6 7 - #define NULL 0 8 7 #define INLINE __always_inline 9 8 10 9 #define skb_shorter(skb, len) ((void *)(long)(skb)->data + (len) > (void *)(long)skb->data_end)