Blame src/thread/nt64/clone.c

860627
#include <syscall.h>
860627
860627
struct pt_regs {
860627
	unsigned long	r15;
860627
	unsigned long	r14;
860627
	unsigned long	r13;
860627
	unsigned long	r12;
860627
	unsigned long	rbp;
860627
	unsigned long	rbx;
860627
	unsigned long	r11;
860627
	unsigned long	r10;
860627
	unsigned long	r9;
860627
	unsigned long	r8;
860627
	unsigned long	rax;
860627
	unsigned long	rcx;
860627
	unsigned long	rdx;
860627
	unsigned long	rsi;
860627
	unsigned long	rdi;
860627
	unsigned long	orig_rax;
860627
	unsigned long	rip;
860627
	unsigned long	cs;
860627
	unsigned long	eflags;
860627
	unsigned long	rsp;
860627
	unsigned long	ss;
860627
};
860627
860627
typedef long __sys_clone(
860627
	unsigned long	flags,
860627
	void *		child_stack,
860627
	void *		ptid,
860627
	void *		ctid,
860627
	struct pt_regs *regs);
860627
860627
typedef int __entry_point(void *);
860627
860627
extern unsigned long ** __syscall_vtbl;
860627
860627
int __clone(
860627
	__entry_point *	fn,
860627
	void *		child_stack,
860627
	int		flags,
860627
	void *		arg,
860627
	int *		ptid,
860627
	void *		pthread_self_addr,
860627
	int *		ctid)
860627
{
860627
	struct pt_regs	regs;
860627
	__sys_clone *	pfn_clone;
860627
860627
	regs.rip = (unsigned long)fn;
860627
	regs.rcx = (unsigned long)arg;
860627
	regs.rdx = (unsigned long)pthread_self_addr;
860627
860627
	pfn_clone = (__sys_clone *)(__syscall_vtbl[SYS_clone]);
860627
860627
	return (int)pfn_clone(
860627
		flags,
860627
		child_stack,
860627
		ptid,
860627
		ctid,
860627
		®s;;
860627
}