Blame src/thread/nt32/clone.c
|
|
296178 |
#include <syscall.h>
|
|
|
296178 |
|
|
|
296178 |
struct pt_regs {
|
|
|
296178 |
unsigned long ebp;
|
|
|
296178 |
unsigned long ebx;
|
|
|
296178 |
unsigned long eax;
|
|
|
296178 |
unsigned long ecx;
|
|
|
296178 |
unsigned long edx;
|
|
|
296178 |
unsigned long esi;
|
|
|
296178 |
unsigned long edi;
|
|
|
296178 |
unsigned long orig_eax;
|
|
|
296178 |
unsigned long eip;
|
|
|
296178 |
unsigned long cs;
|
|
|
296178 |
unsigned long eflags;
|
|
|
296178 |
unsigned long esp;
|
|
|
296178 |
unsigned long ss;
|
|
|
296178 |
};
|
|
|
296178 |
|
|
|
296178 |
typedef long __sys_clone(
|
|
|
296178 |
unsigned long flags,
|
|
|
296178 |
void * child_stack,
|
|
|
296178 |
void * ptid,
|
|
|
296178 |
void * ctid,
|
|
|
296178 |
struct pt_regs *regs);
|
|
|
296178 |
|
|
|
296178 |
typedef int __entry_point(void *);
|
|
|
296178 |
|
|
|
296178 |
extern unsigned long ** __syscall_vtbl;
|
|
|
296178 |
|
|
|
296178 |
int __clone(
|
|
|
296178 |
__entry_point * fn,
|
|
|
296178 |
void * child_stack,
|
|
|
296178 |
int flags,
|
|
|
296178 |
void * arg,
|
|
|
296178 |
int * ptid,
|
|
|
296178 |
void * pthread_self_addr,
|
|
|
296178 |
int * ctid)
|
|
|
296178 |
{
|
|
|
296178 |
struct pt_regs regs;
|
|
|
296178 |
__sys_clone * pfn_clone;
|
|
|
296178 |
|
|
|
296178 |
regs.eip = (unsigned long)fn;
|
|
|
296178 |
regs.ecx = (unsigned long)arg;
|
|
|
296178 |
regs.edx = (unsigned long)pthread_self_addr;
|
|
|
296178 |
|
|
|
296178 |
pfn_clone = (__sys_clone *)(__syscall_vtbl[SYS_clone]);
|
|
|
296178 |
|
|
|
296178 |
return (int)pfn_clone(
|
|
|
296178 |
flags,
|
|
|
296178 |
child_stack,
|
|
|
296178 |
ptid,
|
|
|
296178 |
ctid,
|
|
|
296178 |
®s;;
|
|
|
296178 |
}
|