All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 12/13 v1.1] perf tools: Move tools/lib/string.c to libapi
Date: Fri, 4 Dec 2015 16:21:02 -0600	[thread overview]
Message-ID: <20151204222102.GL11394@treble.redhat.com> (raw)
In-Reply-To: <f90e98dca049dcaddc4ad7e3efa3e1b6850526c8.1449265570.git.jpoimboe@redhat.com>

On Fri, Dec 04, 2015 at 03:59:23PM -0600, Josh Poimboeuf wrote:
> The perf subcommand framework will soon be needed by stacktool.  Move
> parse-options.c, run-command.c, exec_cmd.c, help.c, usage.c, and their
> dependencies over to libapi in 'tools/lib/api/util'.
> 
> Functions with 'perf' in their name have been given more generic names.
> 
> Also created a util_cfg struct for passing perf-specific configuration
> to the library.  Specifying the configuration at runtime allows the same
> binary to be shared by multiple tools without having to recompile it.
> 
> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>

Oops!  Right patch, wrong description.  Not sure how I borked that one
up.  Should be:

----8<----

Subject: [PATCH] perf tools: Move tools/lib/string.c to libapi

Get rid of libstring and move tools/lib/string.c to libapi where it can
more easily be used by other tools.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 tools/lib/api/Build                              |  1 +
 tools/lib/api/string/Build                       |  1 +
 tools/lib/{ => api/string}/string.c              |  7 ++++---
 tools/{include/linux => lib/api/string}/string.h | 10 +++++-----
 tools/perf/MANIFEST                              |  2 --
 tools/perf/builtin-kmem.c                        |  2 +-
 tools/perf/util/Build                            |  6 ------
 tools/perf/util/auxtrace.c                       |  2 +-
 tools/perf/util/bpf-loader.c                     |  2 +-
 tools/perf/util/intel-pt-decoder/insn.c          |  2 +-
 tools/perf/util/map.c                            |  2 +-
 tools/perf/util/ordered-events.c                 |  2 +-
 tools/perf/util/parse-options.c                  |  2 +-
 tools/perf/util/util.h                           |  2 +-
 14 files changed, 19 insertions(+), 24 deletions(-)
 create mode 100644 tools/lib/api/string/Build
 rename tools/lib/{ => api/string}/string.c (93%)
 rename tools/{include/linux => lib/api/string}/string.h (66%)

diff --git a/tools/lib/api/Build b/tools/lib/api/Build
index e8b8a23..9e3967e 100644
--- a/tools/lib/api/Build
+++ b/tools/lib/api/Build
@@ -1,3 +1,4 @@
 libapi-y += fd/
 libapi-y += fs/
 libapi-y += cpu.o
+libapi-y += string/
diff --git a/tools/lib/api/string/Build b/tools/lib/api/string/Build
new file mode 100644
index 0000000..7707d3d
--- /dev/null
+++ b/tools/lib/api/string/Build
@@ -0,0 +1 @@
+libapi-y += string.o
diff --git a/tools/lib/string.c b/tools/lib/api/string/string.c
similarity index 93%
rename from tools/lib/string.c
rename to tools/lib/api/string/string.c
index 3366582..3140ba3 100644
--- a/tools/lib/string.c
+++ b/tools/lib/api/string/string.c
@@ -1,5 +1,5 @@
 /*
- *  linux/tools/lib/string.c
+ *  linux/tools/lib/api/string/string.c
  *
  *  Copied from linux/lib/string.c, where it is:
  *
@@ -15,8 +15,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
-#include <linux/string.h>
-#include <linux/compiler.h>
+#include "string.h"
+
+#define __weak __attribute__((weak))
 
 /**
  * memdup - duplicate region of memory
diff --git a/tools/include/linux/string.h b/tools/lib/api/string/string.h
similarity index 66%
rename from tools/include/linux/string.h
rename to tools/lib/api/string/string.h
index eae1d87..74bd4fd 100644
--- a/tools/include/linux/string.h
+++ b/tools/lib/api/string/string.h
@@ -1,8 +1,8 @@
-#ifndef _TOOLS_LINUX_STRING_H_
-#define _TOOLS_LINUX_STRING_H_
+#ifndef _API_STRING_H
+#define _API_STRING_H
 
-
-#include <linux/types.h>	/* for size_t */
+#include <stddef.h>
+#include <stdbool.h>
 
 void *memdup(const void *src, size_t len);
 
@@ -13,4 +13,4 @@ int strtobool(const char *s, bool *res);
 extern size_t strlcpy(char *dest, const char *src, size_t size);
 #endif
 
-#endif /* _LINUX_STRING_H_ */
+#endif /* _API_STRING_H */
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index 2562eac..39c38cb 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -22,7 +22,6 @@ tools/lib/api
 tools/lib/bpf
 tools/lib/hweight.c
 tools/lib/rbtree.c
-tools/lib/string.c
 tools/lib/symbol/kallsyms.c
 tools/lib/symbol/kallsyms.h
 tools/lib/util/find_next_bit.c
@@ -51,7 +50,6 @@ tools/include/linux/log2.h
 tools/include/linux/poison.h
 tools/include/linux/rbtree.h
 tools/include/linux/rbtree_augmented.h
-tools/include/linux/string.h
 tools/include/linux/types.h
 tools/include/linux/err.h
 include/asm-generic/bitops/arch_hweight.h
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 1c3d3d9..cdf487b 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -19,7 +19,7 @@
 #include "util/debug.h"
 
 #include <linux/rbtree.h>
-#include <linux/string.h>
+#include <api/string/string.h>
 #include <locale.h>
 #include <regex.h>
 
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 99b3dae..02d3a54 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -20,7 +20,6 @@ libperf-y += parse-events.o
 libperf-y += perf_regs.o
 libperf-y += path.o
 libperf-y += rbtree.o
-libperf-y += libstring.o
 libperf-y += bitmap.o
 libperf-y += hweight.o
 libperf-y += run-command.o
@@ -141,7 +140,6 @@ $(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c
 
 CFLAGS_find_next_bit.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_rbtree.o        += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
-CFLAGS_libstring.o     += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_hweight.o       += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_parse-events.o  += -Wno-redundant-decls
 
@@ -157,10 +155,6 @@ $(OUTPUT)util/rbtree.o: ../lib/rbtree.c FORCE
 	$(call rule_mkdir)
 	$(call if_changed_dep,cc_o_c)
 
-$(OUTPUT)util/libstring.o: ../lib/string.c FORCE
-	$(call rule_mkdir)
-	$(call if_changed_dep,cc_o_c)
-
 $(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE
 	$(call rule_mkdir)
 	$(call if_changed_dep,cc_o_c)
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index 7f10430..cc83262 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -22,7 +22,7 @@
 #include <linux/types.h>
 #include <linux/bitops.h>
 #include <linux/log2.h>
-#include <linux/string.h>
+#include <api/string/string.h>
 
 #include <sys/param.h>
 #include <stdlib.h>
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 540a7ef..5a99b6a 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -8,7 +8,7 @@
 #include <linux/bpf.h>
 #include <bpf/libbpf.h>
 #include <linux/err.h>
-#include <linux/string.h>
+#include <api/string/string.h>
 #include "perf.h"
 #include "debug.h"
 #include "bpf-loader.h"
diff --git a/tools/perf/util/intel-pt-decoder/insn.c b/tools/perf/util/intel-pt-decoder/insn.c
index 47314a6..bcf3a8e 100644
--- a/tools/perf/util/intel-pt-decoder/insn.c
+++ b/tools/perf/util/intel-pt-decoder/insn.c
@@ -19,7 +19,7 @@
  */
 
 #ifdef __KERNEL__
-#include <linux/string.h>
+#include <api/string/string.h>
 #else
 #include <string.h>
 #endif
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 93d9f1c..c9f716d 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -14,7 +14,7 @@
 #include "util.h"
 #include "debug.h"
 #include "machine.h"
-#include <linux/string.h>
+#include <api/string/string.h>
 
 static void __maps__insert(struct maps *maps, struct map *map);
 
diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c
index b1b9e23..867ae98 100644
--- a/tools/perf/util/ordered-events.c
+++ b/tools/perf/util/ordered-events.c
@@ -1,6 +1,6 @@
 #include <linux/list.h>
 #include <linux/compiler.h>
-#include <linux/string.h>
+#include <api/string/string.h>
 #include "ordered-events.h"
 #include "session.h"
 #include "asm/bug.h"
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index 735c8c8..8d70c1b 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -1,7 +1,7 @@
 #include "util.h"
 #include "parse-options.h"
 #include "header.h"
-#include <linux/string.h>
+#include <api/string/string.h>
 
 #define OPT_SHORT 1
 #define OPT_UNSET 2
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 2c6db35..f1c07f6 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -3,7 +3,7 @@
 
 #include "compat-util.h"
 
-#include <linux/string.h>
+#include <api/string/string.h>
 #include "../perf.h"
 #include "abspath.h"
 #include "alias.h"
-- 
2.4.3


  reply	other threads:[~2015-12-04 22:21 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-04 21:59 [PATCH 00/13] perf tools: Move perf subcommand framework into lib/tools Josh Poimboeuf
2015-12-04 21:59 ` [PATCH 01/13] perf: Use -iquote for local include paths Josh Poimboeuf
2015-12-04 21:59 ` [PATCH 02/13] perf: Split up util.h Josh Poimboeuf
2015-12-04 21:59 ` [PATCH 03/13] perf: Move term functions out of util.c Josh Poimboeuf
2015-12-04 21:59 ` [PATCH 04/13] perf: Remove unused pager_use_color variable Josh Poimboeuf
2015-12-04 21:59 ` [PATCH 05/13] perf: Split up cache.h Josh Poimboeuf
2015-12-04 21:59 ` [PATCH 06/13] perf: Remove cache.h Josh Poimboeuf
2015-12-04 21:59 ` [PATCH 07/13] perf: Save cmdline arguments earlier Josh Poimboeuf
2015-12-04 21:59 ` [PATCH 08/13] perf: Remove check for unused PERF_PAGER_IN_USE Josh Poimboeuf
2015-12-04 21:59 ` [PATCH 09/13] perf: Move cmd_version() to builtin-version.c Josh Poimboeuf
2015-12-04 21:59 ` [PATCH 10/13] perf: Move help_unknown_cmd() to its own file Josh Poimboeuf
2015-12-04 21:59 ` [PATCH 11/13] perf tools: Move strlcpy() to tools/lib/string.c Josh Poimboeuf
2015-12-04 21:59 ` [PATCH 12/13] perf tools: Move perf subcommand framework into a library Josh Poimboeuf
2015-12-04 22:21   ` Josh Poimboeuf [this message]
2015-12-04 21:59 ` [PATCH 13/13] perf tools: Move subcommand framework and related utils to libapi Josh Poimboeuf
2015-12-06  9:37 ` [PATCH 00/13] perf tools: Move perf subcommand framework into lib/tools Ingo Molnar
2015-12-06 15:50   ` Jiri Olsa
2015-12-06 20:02     ` Josh Poimboeuf
2015-12-07  8:46       ` Jiri Olsa
2015-12-08 14:52         ` Arnaldo Carvalho de Melo
2015-12-08 14:55           ` Arnaldo Carvalho de Melo
2015-12-08 15:27             ` Josh Poimboeuf
2015-12-08 15:29             ` Arnaldo Carvalho de Melo
2015-12-08 15:41               ` Arnaldo Carvalho de Melo
2015-12-06 18:28   ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151204222102.GL11394@treble.redhat.com \
    --to=jpoimboe@redhat.com \
    --cc=acme@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.