diff mbox series

[bpf-next,01/14] bpftool: fix unistd.h include

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

Checks

Context Check Description
bpf/vmtest-bpf-next fail VM_Test
bpf/vmtest-bpf-next-PR fail PR summary
netdev/cover_letter success Series has a cover letter
netdev/fixes_present success Fixes tag not required for -next series
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 7 maintainers not CCed: john.fastabend@gmail.com yhs@fb.com netdev@vger.kernel.org songliubraving@fb.com kafai@fb.com kpsingh@kernel.org quentin@isovalent.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success No Fixes tag
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success No static functions without inline keyword in header files

Commit Message

Andrii Nakryiko Oct. 30, 2021, 4:59 a.m. UTC
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(-)

Comments

Hengqi Chen Nov. 1, 2021, 2:12 p.m. UTC | #1
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
Andrii Nakryiko Nov. 1, 2021, 9:44 p.m. UTC | #2
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 mbox series

Patch

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>