[LTP] [PATCH] tracing/pt_test.c: Fix compiler errors on old distros

Xiao Yang yangx.jy@cn.fujitsu.com
Thu Nov 1 07:56:53 CET 2018


Compilation fails on old distros which don't have linux/perf_event.h
and LTP_CHECK_PERF_EVENT can check the existence of linux/perf_event.h
as well, so we just include perf_event.h header file when
HAVE_STRUCT_PERF_EVENT_MMAP_PAGE_AUX_HEAD is defined.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
 testcases/kernel/tracing/pt_test/pt_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/tracing/pt_test/pt_test.c b/testcases/kernel/tracing/pt_test/pt_test.c
index fe5b1e9..5feb1aa 100644
--- a/testcases/kernel/tracing/pt_test/pt_test.c
+++ b/testcases/kernel/tracing/pt_test/pt_test.c
@@ -14,7 +14,6 @@
  * kconfig requirement: CONFIG_PERF_EVENTS
  */
 
-#include <linux/perf_event.h>
 #include <sched.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -24,6 +23,7 @@
 #include "config.h"
 
 #ifdef HAVE_STRUCT_PERF_EVENT_MMAP_PAGE_AUX_HEAD
+# include <linux/perf_event.h>
 
 #define PAGESIZE 4096
 #define INTEL_PT_MEMSIZE (17*PAGESIZE)
-- 
1.8.3.1





More information about the ltp mailing list