All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>
Subject: [PATCH 01/16] tools: Adopt memdup() from tools/perf, moving it to tools/lib/string.c
Date: Tue, 17 Nov 2015 12:31:16 -0300	[thread overview]
Message-ID: <1447774291-14532-2-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1447774291-14532-1-git-send-email-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

That will contain more string functions with counterparts, sometimes
verbatim copies, in the kernel.

Acked-by: Wang Nan <wangnan0@huawei.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/n/tip-rah6g97kn21vfgmlramorz6o@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/include/linux/string.h           |  9 +++++++++
 tools/lib/string.c                     | 19 +++++++++++++++++++
 tools/perf/MANIFEST                    |  2 ++
 tools/perf/util/Build                  |  6 ++++++
 tools/perf/util/include/linux/string.h |  3 ---
 tools/perf/util/string.c               | 16 ----------------
 6 files changed, 36 insertions(+), 19 deletions(-)
 create mode 100644 tools/include/linux/string.h
 create mode 100644 tools/lib/string.c
 delete mode 100644 tools/perf/util/include/linux/string.h

diff --git a/tools/include/linux/string.h b/tools/include/linux/string.h
new file mode 100644
index 000000000000..f3a6db6ad732
--- /dev/null
+++ b/tools/include/linux/string.h
@@ -0,0 +1,9 @@
+#ifndef _TOOLS_LINUX_STRING_H_
+#define _TOOLS_LINUX_STRING_H_
+
+
+#include <linux/types.h>	/* for size_t */
+
+void *memdup(const void *src, size_t len);
+
+#endif /* _LINUX_STRING_H_ */
diff --git a/tools/lib/string.c b/tools/lib/string.c
new file mode 100644
index 000000000000..ecfd43a9b24e
--- /dev/null
+++ b/tools/lib/string.c
@@ -0,0 +1,19 @@
+#include <stdlib.h>
+#include <string.h>
+#include <linux/string.h>
+
+/**
+ * memdup - duplicate region of memory
+ *
+ * @src: memory region to duplicate
+ * @len: memory region length
+ */
+void *memdup(const void *src, size_t len)
+{
+	void *p = malloc(len);
+
+	if (p)
+		memcpy(p, src, len);
+
+	return p;
+}
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index 39c38cb45b00..2562eac6451d 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -22,6 +22,7 @@ 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
@@ -50,6 +51,7 @@ 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/util/Build b/tools/perf/util/Build
index 591b3fe3ed49..e2316900f96f 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -21,6 +21,7 @@ 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
@@ -138,6 +139,7 @@ $(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
 
@@ -153,6 +155,10 @@ $(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/include/linux/string.h b/tools/perf/util/include/linux/string.h
deleted file mode 100644
index 6f19c548ecc0..000000000000
--- a/tools/perf/util/include/linux/string.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <string.h>
-
-void *memdup(const void *src, size_t len);
diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
index fc8781de62db..7f7e072be746 100644
--- a/tools/perf/util/string.c
+++ b/tools/perf/util/string.c
@@ -342,22 +342,6 @@ char *rtrim(char *s)
 	return s;
 }
 
-/**
- * memdup - duplicate region of memory
- * @src: memory region to duplicate
- * @len: memory region length
- */
-void *memdup(const void *src, size_t len)
-{
-	void *p;
-
-	p = malloc(len);
-	if (p)
-		memcpy(p, src, len);
-
-	return p;
-}
-
 char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints)
 {
 	/*
-- 
2.1.0


  reply	other threads:[~2015-11-17 15:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-17 15:31 [GIT PULL 00/16] perf/ebpf improvements and fixes Arnaldo Carvalho de Melo
2015-11-17 15:31 ` Arnaldo Carvalho de Melo [this message]
2015-11-17 15:31 ` [PATCH 02/16] tools: Clone the kernel's strtobool function Arnaldo Carvalho de Melo
2015-11-17 15:31 ` [PATCH 03/16] bpf tools: Load a program with different instances using preprocessor Arnaldo Carvalho de Melo
2015-11-17 15:31 ` [PATCH 04/16] perf bpf: Add BPF_PROLOGUE config options for further patches Arnaldo Carvalho de Melo
2015-11-17 15:31 ` [PATCH 05/16] perf bpf: Compile dwarf-regs.c if CONFIG_BPF_PROLOGUE is on Arnaldo Carvalho de Melo
2015-11-17 15:31 ` [PATCH 06/16] perf bpf: Allow BPF program attach to uprobe events Arnaldo Carvalho de Melo
2015-11-17 15:31 ` [PATCH 07/16] perf bpf: Allow attaching BPF programs to modules symbols Arnaldo Carvalho de Melo
2015-11-17 15:31 ` [PATCH 08/16] perf bpf: Allow BPF program config probing options Arnaldo Carvalho de Melo
2015-11-17 15:31 ` [PATCH 09/16] perf bpf: Add prologue for BPF programs for fetching arguments Arnaldo Carvalho de Melo
2015-11-17 15:31 ` [PATCH 10/16] perf bpf: Generate prologue for BPF programs Arnaldo Carvalho de Melo
2015-11-17 15:31 ` [PATCH 11/16] perf test: Test the BPF prologue adding infrastructure Arnaldo Carvalho de Melo
2015-11-17 15:31 ` [PATCH 12/16] perf test: Fix 'perf test BPF' when it fails to find a suitable vmlinux Arnaldo Carvalho de Melo
2015-11-17 15:31 ` [PATCH 13/16] perf bpf: Use same BPF program if arguments are identical Arnaldo Carvalho de Melo
2015-11-17 15:31 ` [PATCH 14/16] perf test: Print result for each LLVM subtest Arnaldo Carvalho de Melo
2015-11-17 15:31 ` [PATCH 15/16] perf test: Print result for each BPF subtest Arnaldo Carvalho de Melo
2015-11-17 15:31 ` [PATCH 16/16] perf test: Mute test cases error messages if verbose == 0 Arnaldo Carvalho de Melo
2015-11-18  6:32 ` [GIT PULL 00/16] perf/ebpf improvements and fixes Ingo Molnar
2015-11-18 12:44   ` Arnaldo Carvalho de Melo
2015-11-18 13:06     ` pi3orama
2015-11-18 13:27       ` 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=1447774291-14532-2-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adobriyan@gmail.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.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.