[ovs-dev] [PATCH] autoconf: check for linux/perf_event.h
Alex Wang
alexw at nicira.com
Thu Apr 16 22:21:49 UTC 2015
Thx a lot for the quick fix, let's get it in and have some good builds,
Acked-by: Alex Wang <alexw at nicira.com>
On Thu, Apr 16, 2015 at 1:02 PM, Andy Zhou <azhou at nicira.com> wrote:
> Older Linux prior to version 2.6.32 do not support user mode
> performance events, They also don't have 'linux/perf_event.h' header
> file. Add check for those older Linux to conditionally compile
> perf-counter.c
>
> Reported-by: Alex Wang <alexw at nicira.com>
> Signed-off-by: Andy Zhou <azhou at nicira.com>
> ---
> configure.ac | 1 +
> lib/perf-counter.c | 5 +++--
> lib/perf-counter.h | 4 ++--
> m4/openvswitch.m4 | 4 ++++
> 4 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 8d47eb9..d1b48ca 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -111,6 +111,7 @@ OVS_CHECK_PKIDIR
> OVS_CHECK_RUNDIR
> OVS_CHECK_DBDIR
> OVS_CHECK_BACKTRACE
> +OVS_CHECK_PERF_EVENT
> OVS_CHECK_VALGRIND
> OVS_CHECK_SOCKET_LIBS
> OVS_CHECK_XENSERVER_VERSION
> diff --git a/lib/perf-counter.c b/lib/perf-counter.c
> index 4188f6b..a6c4965 100644
> --- a/lib/perf-counter.c
> +++ b/lib/perf-counter.c
> @@ -15,7 +15,9 @@
> */
>
> /* This implementation only applies to the Linux platform. */
> -#ifdef __linux__
> +
> +#include <config.h>
> +#if defined(__linux__) && defined(HAVE_PERF_EVENT_H)
>
> #include <stddef.h>
> #include <sys/types.h>
> @@ -24,7 +26,6 @@
> #include <sys/ioctl.h>
> #include <linux/perf_event.h>
> #include <asm/unistd.h>
> -#include <config.h>
> #include "dynamic-string.h"
> #include "openvswitch/vlog.h"
> #include "perf-counter.h"
> diff --git a/lib/perf-counter.h b/lib/perf-counter.h
> index 851bd63..9b36919 100644
> --- a/lib/perf-counter.h
> +++ b/lib/perf-counter.h
> @@ -94,7 +94,7 @@
> * will work just fine.
> */
>
> -#ifdef __linux__
> +#if defined(__linux__) && defined(HAVE_PERF_EVENT_H)
> struct perf_counter {
> const char *name;
> bool once;
> @@ -138,7 +138,7 @@ static inline void perf_counters_clear(void) {}
> static inline char *
> perf_counters_to_string(void)
> {
> - return xstrdup("Not Supported on this platform. Only available on
> Linux.");
> + return xstrdup("Not Supported on this platform. Only available on
> Linux (version >= 2.6.32)");
> }
>
> #endif
> diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
> index ba3ed9b..8ace9ce 100644
> --- a/m4/openvswitch.m4
> +++ b/m4/openvswitch.m4
> @@ -243,6 +243,10 @@ AC_DEFUN([OVS_CHECK_BACKTRACE],
> [AC_DEFINE([HAVE_BACKTRACE], [1],
> [Define to 1 if you have backtrace(3).])])])
>
> +dnl Defines HAVE_PERF_EVENT if linux/perf_event.h is found.
> +AC_DEFUN([OVS_CHECK_PERF_EVENT],
> + [AC_CHECK_HEADERS([linux/perf_event.h])])
> +
> dnl Checks for valgrind/valgrind.h.
> AC_DEFUN([OVS_CHECK_VALGRIND],
> [AC_CHECK_HEADERS([valgrind/valgrind.h])])
> --
> 1.9.1
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
More information about the dev
mailing list