[lkml]   [2012]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH v2 01/12] perf tools: include wrapper for magic.h
From: Irina Tirdea <>

perf is currently including magic.h directly from the kernel. If the glibc
magic.h is also included, this leads to warnings that the constants are
redefined. This happens on some systems (e.g. Android).

Redefinition errors on Android:
In file included from util/util.h:79:0,
from util/cache.h:5,
from util/abspath.c:1:
error: "AFFS_SUPER_MAGIC" redefined [-Werror]
note: this is the location of the previous definition
error: "EFS_SUPER_MAGIC" redefined [-Werror]
note: this is the location of the previous definition
error: "HPFS_SUPER_MAGIC" redefined [-Werror]
note: this is the location of the previous definition

Only two constants from magic.h are used by perf (DEBUGFS_MAGIC and
SYSFS_MAGIC). This fix provides a wrapper for magic.h that includes only
these constants instead of including the kernel header file directly.

Signed-off-by: Irina Tirdea <>
tools/perf/Makefile | 1 +
tools/perf/util/include/linux/magic.h | 12 ++++++++++++
tools/perf/util/util.h | 2 +-
3 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 tools/perf/util/include/linux/magic.h

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index afd5075..25d2bab 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -264,6 +264,7 @@ LIB_H += util/include/linux/ctype.h
LIB_H += util/include/linux/kernel.h
LIB_H += util/include/linux/list.h
LIB_H += util/include/linux/export.h
+LIB_H += util/include/linux/magic.h
LIB_H += util/include/linux/poison.h
LIB_H += util/include/linux/prefetch.h
LIB_H += util/include/linux/rbtree.h
diff --git a/tools/perf/util/include/linux/magic.h b/tools/perf/util/include/linux/magic.h
new file mode 100644
index 0000000..58b64ed
--- /dev/null
+++ b/tools/perf/util/include/linux/magic.h
@@ -0,0 +1,12 @@
+#define DEBUGFS_MAGIC 0x64626720
+#ifndef SYSFS_MAGIC
+#define SYSFS_MAGIC 0x62656572
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 67a3713..70fa70b 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -70,7 +70,7 @@
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <inttypes.h>
-#include "../../../include/linux/magic.h"
+#include <linux/magic.h>
#include "types.h"
#include <sys/ttydefaults.h>


 \ /
  Last update: 2012-09-08 03:41    [W:0.147 / U:1.668 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site