Mercurial > hg > nginx-quic
comparison src/os/unix/rfork_thread.S @ 267:83205e0b5522
nginx-0.0.2-2004-02-24-20:31:46 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 24 Feb 2004 17:31:46 +0000 |
parents | |
children | da8c5707af39 |
comparison
equal
deleted
inserted
replaced
266:5238e93961a1 | 267:83205e0b5522 |
---|---|
1 | |
2 #include <sys/syscall.h> | |
3 #include <machine/asm.h> | |
4 | |
5 /* | |
6 * rfork_thread(3) - rfork_thread(flags, stack, func, arg); | |
7 */ | |
8 | |
9 #define KERNCALL int $0x80 | |
10 | |
11 ENTRY(rfork_thread) | |
12 push %ebp | |
13 mov %esp, %ebp | |
14 push %esi | |
15 | |
16 mov 12(%ebp), %esi # the stack address | |
17 | |
18 sub $4, %esi | |
19 mov 20(%ebp), %eax # the thread argument | |
20 mov %eax, (%esi) | |
21 | |
22 sub $4, %esi | |
23 mov 16(%ebp), %eax # the start thread address | |
24 mov %eax, (%esi) | |
25 | |
26 push 8(%ebp) # rfork(2) flags | |
27 push $0 | |
28 mov $SYS_rfork, %eax | |
29 KERNCALL | |
30 jc error | |
31 | |
32 cmp $0, %edx | |
33 jne child | |
34 | |
35 parent: | |
36 add $8, %esp | |
37 pop %esi | |
38 mov %ebp, %esp | |
39 pop %ebp | |
40 ret | |
41 | |
42 child: | |
43 mov %esi, %esp | |
44 pop %eax | |
45 call *%eax # call a thread start address ... | |
46 add $4, %esp | |
47 | |
48 push %eax | |
49 push $0 | |
50 mov $SYS_exit, %eax # ... and exit(2) after a thread would return | |
51 KERNCALL | |
52 | |
53 error: | |
54 add $8, %esp | |
55 pop %esi | |
56 mov %ebp, %esp | |
57 pop %ebp | |
58 PIC_PROLOGUE | |
59 | |
60 /* libc's cerror: jmp PIC_PLT(HIDENAME(cerror)) */ | |
61 | |
62 push %eax | |
63 call PIC_PLT(CNAME(__error)) | |
64 pop %ecx | |
65 PIC_EPILOGUE | |
66 mov %ecx, (%eax) | |
67 mov $-1, %eax | |
68 mov $-1, %edx | |
69 ret |