Commit fa098801 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Andrei Vagin

zdtm: Add sys_clone_unified()

Cleanup fork() definition and make a generic function
for all archs. It may be useful, when you want to add
more clone flags to fork(), or if you want to pass more,
than one argument to child function (glibc's clone
alows only one).
Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent e23806f3
......@@ -61,6 +61,9 @@ extern int open_pid_proc(pid_t pid);
extern int close_pid_proc(void);
extern int set_proc_fd(int fd);
extern pid_t sys_clone_unified(unsigned long flags, void *child_stack, void *parent_tid,
void *child_tid, unsigned long newtls);
/*
* Values for pid argument of the proc opening routines below.
* SELF would open file under /proc/self
......
......@@ -296,3 +296,17 @@ void test_waitsig(void)
{
futex_wait_while(&sig_received, 0);
}
pid_t sys_clone_unified(unsigned long flags, void *child_stack, void *parent_tid,
void *child_tid, unsigned long newtls)
{
#ifdef __x86_64__
return (pid_t)syscall(__NR_clone, flags, child_stack, parent_tid, child_tid, newtls);
#elif (__i386__ || __arm__ || __aarch64__ ||__powerpc64__)
return (pid_t)syscall(__NR_clone, flags, child_stack, parent_tid, newtls, child_tid);
#elif __s390x__
return (pid_t)syscall(__NR_clone, child_stack, flags, parent_tid, child_tid, newtls);
#else
#error "Unsupported architecture"
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment