public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/3] kvm-unit-tests: Add memcpy to lib/string.c
@ 2013-06-20 14:36 Arthur Chunqi Li
  2013-06-20 14:36 ` [PATCH v4 2/3] kvm-unit-tests: Add a func to run instruction in emulator Arthur Chunqi Li
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Arthur Chunqi Li @ 2013-06-20 14:36 UTC (permalink / raw)
  To: kvm; +Cc: gleb, pbonzini, jan.kiszka, Arthur Chunqi Li

Add memcpy(void *dest, const void *src, size_t n) to lib/string.c.
This function acts the same as memcpy in libc.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
---
 lib/libcflat.h |    1 +
 lib/string.c   |   12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/lib/libcflat.h b/lib/libcflat.h
index 0875bd9..fadc33d 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -50,6 +50,7 @@ extern int vsnprintf(char *buf, int size, const char *fmt, va_list va);
 extern void puts(const char *s);
 
 extern void *memset(void *s, int c, size_t n);
+extern void *memcpy(void *dest, const void *src, size_t n);
 
 extern long atol(const char *ptr);
 #define ARRAY_SIZE(_a)  (sizeof(_a)/sizeof((_a)[0]))
diff --git a/lib/string.c b/lib/string.c
index 9dc94a1..e798f86 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -42,6 +42,18 @@ void *memset(void *s, int c, size_t n)
     return s;
 }
 
+void *memcpy(void *dest, const void *src, size_t n)
+{
+    size_t i;
+    char *a = dest;
+    char *b = src;
+
+    for (i = 0; i < n; ++i)
+        a[i] = b[i];
+
+    return dest;
+}
+
 long atol(const char *ptr)
 {
     long acc = 0;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-06-21 15:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-20 14:36 [PATCH v4 1/3] kvm-unit-tests: Add memcpy to lib/string.c Arthur Chunqi Li
2013-06-20 14:36 ` [PATCH v4 2/3] kvm-unit-tests: Add a func to run instruction in emulator Arthur Chunqi Li
2013-06-20 14:36 ` [PATCH v4 3/3] kvm-unit-tests: Change two cases to use trap_emulator Arthur Chunqi Li
2013-06-21 15:01 ` [PATCH v4 1/3] kvm-unit-tests: Add memcpy to lib/string.c Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox