[CRIU] [PATCH 07/38] compel: plugins, std -- Implement simple memcpy for non x86 archs

Cyrill Gorcunov gorcunov at openvz.org
Tue Oct 11 09:03:57 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 6e5d42ed1ea7..e5377f613744 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