Skip to contentSkip to conversation

perf srccode: Move struct definition from map.h to srccode.h

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Feb 9, 2019 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  4fed072609b8aae27eac7169033f762867a5ab4c
Gitweb:     https://git.kernel.org/tip/4fed072609b8aae27eac7169033f762867a5ab4c
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Sun, 27 Jan 2019 11:31:39 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 6 Feb 2019 10:00:38 -0300

perf srccode: Move struct definition from map.h to srccode.h

To reduce the header dependencies, since we already have a srccode.h header, then there is where the 'struct srccode_state' should be, and map.h, that is more widely used should have just a forward declaraion of 'struct srccode_state'.

---
 tools/perf/util/map.h     | 13 +------------
 tools/perf/util/srccode.h | 13 +++++++++++++
 tools/perf/util/thread.h  |  2 +-
 3 files changed, 15 insertions(+), 13 deletions(-)
tools/perf/util/map.h +1 -12
index 09282aa45c80..5a889db4fca5 100644
@@ -174,18 +174,7 @@ char *map__srcline(struct map *map, u64 addr, struct symbol *sym);
 int map__fprintf_srcline(struct map *map, u64 addr, const char *prefix,
 			 FILE *fp);
 
-struct srccode_state {
-	char *srcfile;
-	unsigned line;
-};
-
-static inline void srccode_state_init(struct srccode_state *state)
-{
-	state->srcfile = NULL;
-	state->line = 0;
-}
-
-void srccode_state_free(struct srccode_state *state);
+struct srccode_state;
 
 int map__fprintf_srccode(struct map *map, u64 addr,
 			 FILE *fp, struct srccode_state *state);
tools/perf/util/srccode.h +13 -0
index e500a746d5f1..1b5ed769779c 100644
@@ -1,6 +1,19 @@
 #ifndef SRCCODE_H
 #define SRCCODE_H 1
 
+struct srccode_state {
+	char	 *srcfile;
+	unsigned line;
+};
+
+static inline void srccode_state_init(struct srccode_state *state)
+{
+	state->srcfile = NULL;
+	state->line    = 0;
+}
+
+void srccode_state_free(struct srccode_state *state);
+
 /* Result is not 0 terminated */
 char *find_sourceline(char *fn, unsigned line, int *lenp);
 
tools/perf/util/thread.h +1 -1
index f3c939150f90..856cf1a9040a 100644
@@ -7,8 +7,8 @@
 #include <linux/list.h>
 #include <unistd.h>
 #include <sys/types.h>
+#include "srccode.h"
 #include "symbol.h"
-#include "map.h"
 #include <strlist.h>
 #include <intlist.h>
 #include "rwsem.h"