From 4e3ded36efcfb13c0942a57ffa8b0b32e747a4d8 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 29 Jul 2015 16:27:16 +0000 Subject: [PATCH] tests/bpf: fix build with incompatibly old linux/bpf.h and/or gcc * configure.ac: Check how union bpf_attr.log_buf initialization works. * tests/bpf.c: Check for HAVE_UNION_BPF_ATTR_LOG_BUF. --- configure.ac | 15 ++++++++++++++- tests/bpf.c | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 20fae61c..bdaca466 100644 --- a/configure.ac +++ b/configure.ac @@ -253,7 +253,6 @@ AC_CHECK_HEADERS(m4_normalize([ elf.h inttypes.h ioctls.h - linux/bpf.h linux/bsg.h linux/falloc.h linux/filter.h @@ -319,6 +318,20 @@ AC_CHECK_HEADERS([linux/input.h], [ AC_CHECK_MEMBERS([struct input_absinfo.resolution],,, [#include ]) ]) +AC_CHECK_HEADERS([linux/bpf.h], [ + AC_CACHE_CHECK([whether union bpf_attr.log_buf initialization works], + [st_cv_have_union_bpf_attr_log_buf], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[union bpf_attr a = { .log_buf = 0 };]])], + [st_cv_have_union_bpf_attr_log_buf=yes], + [st_cv_have_union_bpf_attr_log_buf=no])]) + if test $st_cv_have_union_bpf_attr_log_buf = yes; then + AC_DEFINE(HAVE_UNION_BPF_ATTR_LOG_BUF, [1], + [Define to 1 if union bpf_attr.log_buf initialization works]) + fi +]) + AC_CHECK_DECLS([sys_errlist]) AC_CHECK_DECLS(m4_normalize([ PTRACE_PEEKUSER, diff --git a/tests/bpf.c b/tests/bpf.c index b2e019da..636fae88 100644 --- a/tests/bpf.c +++ b/tests/bpf.c @@ -7,7 +7,7 @@ #include #include -#if defined HAVE_LINUX_BPF_H && defined __NR_bpf +#if defined HAVE_UNION_BPF_ATTR_LOG_BUF && defined __NR_bpf # include static const struct bpf_insn insns[] = { -- 2.40.0