Snap for 10453563 from f847fd7131b17b32364e9e4d7c26fafa03eb2dfd to mainline-media-swcodec-release

Change-Id: I46b7ae9c3455a2277c24203222b0c2356b604420
diff --git a/Android.bp b/Android.bp
index 4a09836..b83d6ba 100644
--- a/Android.bp
+++ b/Android.bp
@@ -31,6 +31,19 @@
         "include/uapi",
         "src/kernel/bpf"
     ],
+    target: {
+        musl: {
+            // There is an unfortunate interaction between the bionic uapi headers
+            // used by musl and the kernel headers distributed with bpftool.  The
+            // bionic uapi headers include <linux/compiler_types.h>, which they
+            // expect to be resolved to their own copy of compiler_types.h that
+            // includes compiler.h.  It instead resolves to the bpftool copy,
+            // which includes compiler-gcc.h directly, triggering an error if
+            // the _LINUX_COMPILER_H_ header guard is not already defined.  Hack
+            // around it by always including linux/compiler.h from the command line.
+            cflags: ["-include linux/compiler.h"],
+        },
+    },
     static_libs: [
         "libbpf",
         "libcap",
diff --git a/src/perf.c b/src/perf.c
index 50de087..5e05ea5 100644
--- a/src/perf.c
+++ b/src/perf.c
@@ -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"