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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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@xxxxxx>
>  
> -#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



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux