++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/syscall/_exit.s ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 0 .sect .text 1 .extern ___exit 2 .define __exit 3 .align 2 4 __exit: 5 jmp ___exit ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/posix/__exit.c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 110 #define _exit __exit 111 #include 112 #include 113 PUBLIC void _exit(status) 114 int status; 115 { 116 message m; 117 m.m1_i1 = status; 118 _syscall(MM, EXIT, &m); 119 } ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/other/syscall.s ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 200 #include 201 PUBLIC int _syscall(who, syscallnr, msgptr) 202 int who; 203 int syscallnr; 204 register message *msgptr; 205 { 206 int status; 207 msgptr->m_type = syscallnr; 208 status = _sendrec(who, msgptr); 209 if (status != 0) { 210 /* 'sendrec' itself failed. */ 211 /* XXX - strerror doesn't know all the codes */ 212 msgptr->m_type = status; 213 } 214 if (msgptr->m_type < 0) { 215 errno = -msgptr->m_type; 216 return(-1); 217 } 218 return(msgptr->m_type); 219 } ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/i386/rts/_sendrec.s ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 300 .sect .text; .sect .rom; .sect .data; .sect .bss 301 .define __send, __receive, __sendrec 302 ! See ../h/com.h for C definitions 303 SEND = 1 304 RECEIVE = 2 305 BOTH = 3 306 SYSVEC = 33 307 SRCDEST = 8 308 MESSAGE = 12 309 !*========================================================================* 310 ! _send and _receive * 311 !*========================================================================* 312 ! _send(), _receive(), _sendrec() all save ebp, but destroy eax and ecx. 313 .define __send, __receive, __sendrec 314 .sect .text 315 __send: 316 push ebp 317 mov ebp, esp 318 push ebx 319 mov eax, SRCDEST(ebp) ! eax = dest-src 320 mov ebx, MESSAGE(ebp) ! ebx = message pointer 321 mov ecx, SEND ! _send(dest, ptr) 322 int SYSVEC ! trap to the kernel 323 pop ebx 324 pop ebp 325 ret 326 __receive: 327 push ebp 328 mov ebp, esp 329 push ebx 330 mov eax, SRCDEST(ebp) ! eax = dest-src 331 mov ebx, MESSAGE(ebp) ! ebx = message pointer 332 mov ecx, RECEIVE ! _receive(src, ptr) 333 int SYSVEC ! trap to the kernel 334 pop ebx 335 pop ebp 336 ret 337 __sendrec: 338 push ebp 339 mov ebp, esp 340 push ebx 341 mov eax, SRCDEST(ebp) ! eax = dest-src 342 mov ebx, MESSAGE(ebp) ! ebx = message pointer 343 mov ecx, BOTH ! _sendrec(srcdest, ptr) 344 int SYSVEC ! trap to the kernel 345 pop ebx 346 pop ebp 347 ret