- thread_t thread;
- volatile int *rval;
- struct i386_saved_state *regs;
- struct proc *p;
- unsigned short code;
- vm_offset_t params;
- struct sysent *callp;
- volatile int *lowpri_delay;
-
- thread = current_thread();
- rval = get_bsduthreadrval(thread);
- lowpri_delay = get_bsduthreadlowpridelay(thread);
- p = current_proc();
-
- regs = USER_REGS(thread);
-
- /* reconstruct code for tracing before blasting eax */
- code = regs->eax;
- params = (vm_offset_t) ((caddr_t)regs->uesp + sizeof (int));
- callp = (code >= nsysent) ? &sysent[63] : &sysent[code];
- if (callp == sysent) {
- code = fuword(params);
- }
-
- if (error == ERESTART) {
- regs->eip -= 7;
- }
- else if (error != EJUSTRETURN) {
- if (error) {
- regs->eax = error;
- regs->efl |= EFL_CF; /* carry bit */
- } else { /* (not error) */
- regs->eax = rval[0];
- regs->edx = rval[1];
- regs->efl &= ~EFL_CF;
- }
- }
-
- ktrsysret(p, code, error, rval[0], (callp->sy_funnel & FUNNEL_MASK));
-
- __pthread_creset(callp);
-
- if ((callp->sy_funnel & FUNNEL_MASK) != NO_FUNNEL)
- (void) thread_funnel_set(current_thread()->funnel_lock, FALSE);
-
- if (*lowpri_delay) {
- /*
- * task is marked as a low priority I/O type
- * and the I/O we issued while in this system call
- * collided with normal I/O operations... we'll
- * delay in order to mitigate the impact of this
- * task on the normal operation of the system
- */
- IOSleep(*lowpri_delay);
- *lowpri_delay = 0;
- }
- KERNEL_DEBUG_CONSTANT(BSDDBG_CODE(DBG_BSD_EXCP_SC, code) | DBG_FUNC_END,
- error, rval[0], rval[1], 0, 0);
-
- thread_exception_return();
- /* NOTREACHED */
-}
-
-
-void
-unix_syscall(struct i386_saved_state *regs)
-{
- thread_t thread;
- void *vt;
- unsigned short code;
- struct sysent *callp;
- int nargs;
- int error;
- int *rval;
- int funnel_type;
- vm_offset_t params;
- struct proc *p;
- volatile int *lowpri_delay;
-
- thread = current_thread();
- p = current_proc();
- rval = get_bsduthreadrval(thread);
- lowpri_delay = get_bsduthreadlowpridelay(thread);
-
- thread->task->syscalls_unix++; /* MP-safety ignored */
-
- //printf("[scall : eax %x]", regs->eax);
- code = regs->eax;
- params = (vm_offset_t) ((caddr_t)regs->uesp + sizeof (int));
- callp = (code >= nsysent) ? &sysent[63] : &sysent[code];
- if (callp == sysent) {
- code = fuword(params);
- params += sizeof (int);
- callp = (code >= nsysent) ? &sysent[63] : &sysent[code];
- }