Message ID | 20211030045941.3514948-2-andrii@kernel.org (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | libbpf: add unified bpf_prog_load() low-level API | expand |
Hi, On 2021/10/30 12:59 PM, Andrii Nakryiko wrote: > cgroup.c in bpftool source code is defining _XOPEN_SOURCE 500, which, > apparently, makes syscall() unavailable. Which is a problem now that > libbpf exposes syscal()-usign bpf() API in bpf.h. > typo: syscal -> syscall usign -> using ? > Fix by defining _GNU_SOURCE instead, which enables syscall() wrapper. > > Signed-off-by: Andrii Nakryiko <andrii@kernel.org> > --- > tools/bpf/bpftool/cgroup.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/bpf/bpftool/cgroup.c b/tools/bpf/bpftool/cgroup.c > index 3571a281c43f..4876364e753d 100644 > --- a/tools/bpf/bpftool/cgroup.c > +++ b/tools/bpf/bpftool/cgroup.c > @@ -2,7 +2,7 @@ > // Copyright (C) 2017 Facebook > // Author: Roman Gushchin <guro@fb.com> > > -#define _XOPEN_SOURCE 500 > +#define _GNU_SOURCE > #include <errno.h> > #include <fcntl.h> > #include <ftw.h> > According to the man page ([0]), defining _GNU_SOURCE also implicitly defines _XOPEN_SOURCE with the value 700 (600 in glibc versions before 2.10; 500 in glibc versions before 2.2), so this change should not break anything. [0]: https://man7.org/linux/man-pages/man7/feature_test_macros.7.html --Hengqi
On Mon, Nov 1, 2021 at 7:12 AM Hengqi Chen <hengqi.chen@gmail.com> wrote: > > Hi, > > On 2021/10/30 12:59 PM, Andrii Nakryiko wrote: > > cgroup.c in bpftool source code is defining _XOPEN_SOURCE 500, which, > > apparently, makes syscall() unavailable. Which is a problem now that > > libbpf exposes syscal()-usign bpf() API in bpf.h. > > > > typo: > syscal -> syscall > usign -> using ? > Thanks, will fix. > > Fix by defining _GNU_SOURCE instead, which enables syscall() wrapper. > > > > Signed-off-by: Andrii Nakryiko <andrii@kernel.org> > > --- > > tools/bpf/bpftool/cgroup.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/tools/bpf/bpftool/cgroup.c b/tools/bpf/bpftool/cgroup.c > > index 3571a281c43f..4876364e753d 100644 > > --- a/tools/bpf/bpftool/cgroup.c > > +++ b/tools/bpf/bpftool/cgroup.c > > @@ -2,7 +2,7 @@ > > // Copyright (C) 2017 Facebook > > // Author: Roman Gushchin <guro@fb.com> > > > > -#define _XOPEN_SOURCE 500 > > +#define _GNU_SOURCE > > > > #include <errno.h> > > #include <fcntl.h> > > #include <ftw.h> > > > > According to the man page ([0]), defining _GNU_SOURCE also implicitly defines > _XOPEN_SOURCE with the value 700 (600 in glibc versions before 2.10; 500 in glibc > versions before 2.2), so this change should not break anything. Cool, thanks for checking. > > [0]: https://man7.org/linux/man-pages/man7/feature_test_macros.7.html > > --Hengqi
diff --git a/tools/bpf/bpftool/cgroup.c b/tools/bpf/bpftool/cgroup.c index 3571a281c43f..4876364e753d 100644 --- a/tools/bpf/bpftool/cgroup.c +++ b/tools/bpf/bpftool/cgroup.c @@ -2,7 +2,7 @@ // Copyright (C) 2017 Facebook // Author: Roman Gushchin <guro@fb.com> -#define _XOPEN_SOURCE 500 +#define _GNU_SOURCE #include <errno.h> #include <fcntl.h> #include <ftw.h>
cgroup.c in bpftool source code is defining _XOPEN_SOURCE 500, which, apparently, makes syscall() unavailable. Which is a problem now that libbpf exposes syscal()-usign bpf() API in bpf.h. Fix by defining _GNU_SOURCE instead, which enables syscall() wrapper. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> --- tools/bpf/bpftool/cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)