[CRIU] [PATCH 11/22] compel: plugins, std -- Implement std_memcpy for x86

Cyrill Gorcunov gorcunov at openvz.org
Wed Oct 19 12:21:26 PDT 2016


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 compel/plugins/std/string.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/compel/plugins/std/string.c b/compel/plugins/std/string.c
index 6f4ade7c5d92..472bfc60e480 100644
--- a/compel/plugins/std/string.c
+++ b/compel/plugins/std/string.c
@@ -222,8 +222,7 @@ fin:
 
 void *std_memcpy(void *to, const void *from, unsigned int n)
 {
-	/* FIXME: Per-arch support */
-#if 0
+#if defined(__i386__) || defined(__x86_64__)
 	int d0, d1, d2;
 	asm volatile("rep ; movsl		\n"
 		     "movl %4,%%ecx		\n"
@@ -234,6 +233,11 @@ void *std_memcpy(void *to, const void *from, unsigned int n)
 		     : "=&c" (d0), "=&D" (d1), "=&S" (d2)
 		     : "0" (n / 4), "g" (n), "1" ((long)to), "2" ((long)from)
 		     : "memory");
+#else
+	unsigned int i;
+
+	for (i = 0; i < n; i++)
+		((char *)to)[i] = ((char *)from)[i];
 #endif
 	return to;
 }
-- 
2.7.4



More information about the CRIU mailing list