[Devel] [PATCH 1/1] mktree: use clone_with_pid on s390
Serge E. Hallyn
serue at us.ibm.com
Mon Jun 15 10:13:37 PDT 2009
Signed-off-by: Serge Hallyn <serue at us.ibm.com>
---
mktree.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/mktree.c b/mktree.c
index db5a060..af18b57 100644
--- a/mktree.c
+++ b/mktree.c
@@ -1720,6 +1720,47 @@ static int clone_with_pids(int (*fn)(void *), void *child_stack, int flags,
}
#else
+#elif defined __s390__
+
+#ifndef __NR_clone_with_pids
+#define __NR_clone_with_pids 332
+#endif
+
+#define do_clone_with_pids(stack, flags, ptid, ctid, setp) ({ \
+ register unsigned long int __r2 asm ("2") = (unsigned long int)(stack);\
+ register unsigned long int __r3 asm ("3") = (unsigned long int)(flags);\
+ register unsigned long int __r4 asm ("4") = (unsigned long int)(ptid); \
+ register unsigned long int __r5 asm ("5") = (unsigned long int)(ctid); \
+ register unsigned long int __r6 asm ("6") = (unsigned long int)(NULL); \
+ register unsigned long int __r7 asm ("7") = (unsigned long int)(setp); \
+ register unsigned long int __result asm ("2"); \
+ __asm__ __volatile__( \
+ " lghi %%r1,332\n" \
+ " svc 0\n" \
+ : "=d" (__result) \
+ : "0" (__r2), "d" (__r3), \
+ "d" (__r4), "d" (__r5), "d" (__r6), "d" (__r7) \
+ : "1", "cc", "memory" \
+ ); \
+ __result; \
+ })
+
+int clone_with_pids(int (*fn)(void *), void *child_stack, int flags,
+ struct target_pid_set *target_pids, void *arg)
+{
+ long retval;
+ retval = do_clone_with_pids(child_stack, flags, NULL, NULL,
+ target_pids);
+
+ if (retval < 0) {
+ errno = -retval;
+ return -1;
+ } else if (retval == 0) {
+ return fn(arg);
+ } else
+ return retval;
+}
+
#error mktree requires arch support for clone_with_pids() syscall
/*
--
1.6.1.1
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
More information about the Devel
mailing list