diff options
author | Colin Cross <ccross@android.com> | 2022-04-22 12:52:25 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2022-04-22 13:14:06 -0700 |
commit | 7d7be8894e1bc7b2bbe3aeecdd05326cf540cb37 (patch) | |
tree | 6138168a97f8b86b41e8232f3becfd1df4cae3f1 | |
parent | 2db6b950ee8789d935a02acd1d9cafca18a1284c (diff) | |
download | bpftool-7d7be8894e1bc7b2bbe3aeecdd05326cf540cb37.tar.gz |
Fix compiling bpftool against musl libc
Include fcntl.h instead of sys/fcntl.h, musl throws and error if
sys/fcntl.h is included directly.
musl libc doesn't implement these GNU extensions. They are used in perf.c
to optimize out walking unnecessary subtrees of /proc, #defining them
to 0 disables the optimization but leaves the functionality otherwise
unchanged.
Bug: 190084016
Test: m USE_HOST_MUSL=true
Change-Id: I8c9c18c022503ba22244444c748dbb950e619bed
-rw-r--r-- | src/perf.c | 13 | ||||
-rw-r--r-- | src/tracelog.c | 2 |
2 files changed, 14 insertions, 1 deletions
@@ -17,6 +17,19 @@ #include "main.h" +/* musl libc doesn't implement these GNU extensions. They are used below + * to optimize out walking unnecessary subtrees of /proc, #defining them + * to 0 here disables the optimization but leaves the functionality otherwise + * unchanged. + */ +#ifndef FTW_SKIP_SUBTREE +#define FTW_SKIP_SUBTREE 0 +#endif + +#ifndef FTW_ACTIONRETVAL +#define FTW_ACTIONRETVAL 0 +#endif + /* 0: undecided, 1: supported, 2: not supported */ static int perf_query_supported; static bool has_perf_query_support(void) diff --git a/src/tracelog.c b/src/tracelog.c index e80a5c7..d218a58 100644 --- a/src/tracelog.c +++ b/src/tracelog.c @@ -3,13 +3,13 @@ /* Copyright (c) 2018 Netronome Systems, Inc. */ #include <errno.h> +#include <fcntl.h> #include <limits.h> #include <signal.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <linux/magic.h> -#include <sys/fcntl.h> #include <sys/vfs.h> #include "main.h" |