Skip to content

Commit b3d84af

Browse files
qmonnetAlexei Starovoitov
authored andcommitted
bpftool: Define _GNU_SOURCE only once
_GNU_SOURCE is defined in several source files for bpftool, but only one of them takes the precaution of checking whether the value is already defined. Add #ifndef for other occurrences too. This is in preparation for the support of disassembling JIT-ed programs with LLVM, with $(llvm-config --cflags) passing -D_GNU_SOURCE as a compilation argument. Signed-off-by: Quentin Monnet <[email protected]> Tested-by: Niklas Söderlund <[email protected]> Acked-by: Song Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 8f4bc15 commit b3d84af

File tree

7 files changed

+14
-0
lines changed

7 files changed

+14
-0
lines changed

tools/bpf/bpftool/common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
22
/* Copyright (C) 2017-2018 Netronome Systems, Inc. */
33

4+
#ifndef _GNU_SOURCE
45
#define _GNU_SOURCE
6+
#endif
57
#include <ctype.h>
68
#include <errno.h>
79
#include <fcntl.h>

tools/bpf/bpftool/iter.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
22
// Copyright (C) 2020 Facebook
33

4+
#ifndef _GNU_SOURCE
45
#define _GNU_SOURCE
6+
#endif
57
#include <unistd.h>
68
#include <linux/err.h>
79
#include <bpf/libbpf.h>

tools/bpf/bpftool/jit_disasm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
* Licensed under the GNU General Public License, version 2.0 (GPLv2)
1212
*/
1313

14+
#ifndef _GNU_SOURCE
1415
#define _GNU_SOURCE
16+
#endif
1517
#include <stdio.h>
1618
#include <stdarg.h>
1719
#include <stdint.h>

tools/bpf/bpftool/net.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
22
// Copyright (C) 2018 Facebook
33

4+
#ifndef _GNU_SOURCE
45
#define _GNU_SOURCE
6+
#endif
57
#include <errno.h>
68
#include <fcntl.h>
79
#include <stdlib.h>

tools/bpf/bpftool/perf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
// Copyright (C) 2018 Facebook
33
// Author: Yonghong Song <[email protected]>
44

5+
#ifndef _GNU_SOURCE
56
#define _GNU_SOURCE
7+
#endif
68
#include <ctype.h>
79
#include <errno.h>
810
#include <fcntl.h>

tools/bpf/bpftool/prog.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
22
/* Copyright (C) 2017-2018 Netronome Systems, Inc. */
33

4+
#ifndef _GNU_SOURCE
45
#define _GNU_SOURCE
6+
#endif
57
#include <errno.h>
68
#include <fcntl.h>
79
#include <signal.h>

tools/bpf/bpftool/xlated_dumper.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
22
/* Copyright (C) 2018 Netronome Systems, Inc. */
33

4+
#ifndef _GNU_SOURCE
45
#define _GNU_SOURCE
6+
#endif
57
#include <stdarg.h>
68
#include <stdio.h>
79
#include <stdlib.h>

0 commit comments

Comments
 (0)