Index: sys/sa-TODO =================================================================== RCS file: sa-TODO diff -N sa-TODO --- /dev/null Tue Apr 24 13:41:34 2001 +++ /tmp/cvslZN7XUgeu9 Tue Apr 24 17:05:50 2001 @@ -0,0 +1,55 @@ +Things to do for scheduler activations/LWP code. + +- Document! Not everyone wants to read the thesis. Man pages, etc. + +- Prevent multiple LWP/SAs from entering sigexit(). Not at all useful, + and causes deadlock panics in exit1(). + +- Port to other architectures. I have alpha, m68k, arm32, mips, sparc. + Other people will need to do the intimately MD parts for ppc, sh3, sparc64, + pc532, vax. Documenting what is needed and what changes have been made + to the MI/MD boundary would be a good step here. + +- Rethink scheduler. Verify that behavior is still correct for a system + of single-LWP ("traditional") processes (I believe it is, but it should + still be verified). Study scheduling behavior of multi-LWP and SA processes. + Notions of fairness and appropriate scheduling may need changing. + XXX when combined with multiprocessor support, usefully scheduling multi-lwp + processes requires a whole new kind of scheduling. Implementing such a thing + (such as an "equal-space" scheduler) is a major project unto itself. + +- Make multi-LWP process core dumps include multiple CORE_CPU sections, and + rework coredump() to only dump memory regions once per process, not once + per LWP. + +- Adapt gdb to cope with above (somehow). + +- Adapt /proc and libkvm interfaces to support examining LWP/SA data + structures. Adapt ps and friends to display such. + +- scheduler activation "preemption" upcall: currently called once per + clock tick, as preempt() is called whether or not there are other + runnable processes. This introduces a large upcall-handling overhead + on a process. Figure out how to make this cheaper, or ideally, only + invoke the preemption upcall for "real" preemption. + +- scheduler activation upcalls: user-stack storage of all upcall state + has problems if a process causes multiple upcalls in one kernel entry. + Upcalls will be lost, and stacks will be leaked (never returned to process). + Obvious alternate solution of storing upcall state in process and checking + at return to userspace has per-context-switch overhead for all processes, + sa or otherwise. This needs a solution; perhaps making some part of the + return-to-userlevel path dispactched through a function pointer, like + syscalls. + +- Implement better management of the lwp cache for a sa process. High-water + mark needed, at the very least. + +- exit1() is too fragile. A cleaner solution to the LWPWAIT_EXITCONTROL + problem is also needed. + +- Debugging interface needs work; ptrace(2) interface can't handle multi-LWP + or SA processes. + +- Of course, check all new XXX'd parts. + Index: sys/arch/i386/i386/compat_13_machdep.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/compat_13_machdep.c,v retrieving revision 1.5 retrieving revision 1.5.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.5 -r1.5.4.1 --- sys/arch/i386/i386/compat_13_machdep.c 2000/12/22 22:58:53 1.5 +++ sys/arch/i386/i386/compat_13_machdep.c 2001/03/05 22:49:11 1.5.4.1 @@ -40,8 +40,9 @@ #include #include #include #include +#include #include #include #include #include @@ -50,16 +51,17 @@ #include #endif int -compat_13_sys_sigreturn(p, v, retval) - struct proc *p; +compat_13_sys_sigreturn(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct compat_13_sys_sigreturn_args /* { syscallarg(struct sigcontext13 *) sigcntxp; } */ *uap = v; + struct proc *p = l->l_proc; struct sigcontext13 *scp, context; struct trapframe *tf; sigset_t mask; @@ -72,18 +74,18 @@ if (copyin((caddr_t)scp, &context, sizeof(*scp)) != 0) return (EFAULT); /* Restore register context. */ - tf = p->p_md.md_regs; + tf = l->l_md.md_regs; #ifdef VM86 if (context.sc_eflags & PSL_VM) { void syscall_vm86 __P((struct trapframe)); tf->tf_vm86_gs = context.sc_gs; tf->tf_vm86_fs = context.sc_fs; tf->tf_vm86_es = context.sc_es; tf->tf_vm86_ds = context.sc_ds; - set_vflags(p, context.sc_eflags); + set_vflags(l, context.sc_eflags); p->p_md.md_syscall = syscall_vm86; } else #endif { Index: sys/arch/i386/i386/db_trace.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/db_trace.c,v retrieving revision 1.29 retrieving revision 1.29.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.29 -r1.29.2.1 --- sys/arch/i386/i386/db_trace.c 2001/01/18 10:54:27 1.29 +++ sys/arch/i386/i386/db_trace.c 2001/03/05 22:49:11 1.29.2.1 @@ -27,8 +27,9 @@ */ #include #include +#include #include #include #include @@ -215,19 +216,21 @@ } else { if (trace_thread) { struct proc *p; struct user *u; + struct lwp *l; (*pr)("trace: pid %d ", (int)addr); p = pfind(addr); if (p == NULL) { (*pr)("not found\n"); return; } - if (!(p->p_flag&P_INMEM)) { + l = LIST_FIRST(&p->p_lwps); /* XXX NJWLWP */ + if (!(l->l_flag&L_INMEM)) { (*pr)("swapped out\n"); return; } - u = p->p_addr; + u = l->l_addr; frame = (struct i386_frame *) u->u_pcb.pcb_ebp; (*pr)("at %p\n", frame); } else frame = (struct i386_frame *)addr; Index: sys/arch/i386/i386/freebsd_machdep.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/freebsd_machdep.c,v retrieving revision 1.26 retrieving revision 1.26.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.26 -r1.26.4.1 --- sys/arch/i386/i386/freebsd_machdep.c 2000/12/22 22:58:53 1.26 +++ sys/arch/i386/i386/freebsd_machdep.c 2001/03/05 22:49:11 1.26.4.1 @@ -42,8 +42,9 @@ #include #include #include +#include #include #include #include #include @@ -59,16 +60,16 @@ #include #include void -freebsd_setregs(p, epp, stack) - struct proc *p; +freebsd_setregs(l, epp, stack) + struct lwp *l; struct exec_package *epp; u_long stack; { - register struct pcb *pcb = &p->p_addr->u_pcb; + register struct pcb *pcb = &l->l_addr->u_pcb; - setregs(p, epp, stack); + setregs(l, epp, stack); pcb->pcb_savefpu.sv_env.en_cw = __FreeBSD_NPXCW__; } /* @@ -91,14 +92,15 @@ int sig; sigset_t *mask; u_long code; { - register struct proc *p = curproc; + struct lwp *l = curproc; + register struct proc *p = l->l_proc; register struct trapframe *tf; struct freebsd_sigframe *fp, frame; int onstack; - tf = p->p_md.md_regs; + tf = l->l_md.md_regs; /* Do we need to jump onto the signal stack? */ onstack = (p->p_sigctx.ps_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 && @@ -123,9 +125,9 @@ #ifdef VM86 if (tf->tf_eflags & PSL_VM) { frame.sf_sc.sc_es = tf->tf_vm86_es; frame.sf_sc.sc_ds = tf->tf_vm86_ds; - frame.sf_sc.sc_eflags = get_vflags(p); + frame.sf_sc.sc_eflags = get_vflags(l); (*p->p_emul->e_syscall_intern)(p); } else #endif { @@ -156,9 +158,9 @@ /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ - sigexit(p, SIGILL); + sigexit(l, SIGILL); /* NOTREACHED */ } /* @@ -187,16 +189,17 @@ * psl to gain improper privileges or to cause * a machine fault. */ int -freebsd_sys_sigreturn(p, v, retval) - struct proc *p; +freebsd_sys_sigreturn(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_sigreturn_args /* { syscallarg(struct freebsd_sigcontext *) scp; } */ *uap = v; + struct proc *p = l->l_proc; struct freebsd_sigcontext *scp, context; register struct trapframe *tf; sigset_t mask; @@ -209,16 +212,16 @@ if (copyin((caddr_t)scp, &context, sizeof(*scp)) != 0) return (EFAULT); /* Restore register context. */ - tf = p->p_md.md_regs; + tf = l->l_md.md_regs; #ifdef VM86 if (context.sc_eflags & PSL_VM) { void syscall_vm86 __P((struct trapframe)); tf->tf_vm86_es = context.sc_es; tf->tf_vm86_ds = context.sc_ds; - set_vflags(p, context.sc_eflags); + set_vflags(l, context.sc_eflags); p->p_md.md_syscall = syscall_vm86; } else #endif { Index: sys/arch/i386/i386/freebsd_syscall.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/freebsd_syscall.c,v retrieving revision 1.5 retrieving revision 1.5.6.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.5 -r1.5.6.1 --- sys/arch/i386/i386/freebsd_syscall.c 2000/12/27 23:20:29 1.5 +++ sys/arch/i386/i386/freebsd_syscall.c 2001/03/05 22:49:11 1.5.6.1 @@ -42,8 +42,9 @@ #endif #include #include +#include #include #include #include #ifdef KTRACE @@ -86,15 +87,17 @@ struct trapframe frame; { register caddr_t params; register const struct sysent *callp; + struct lwp *l; register struct proc *p; int error; size_t argsize; register_t code, args[8], rval[2]; uvmexp.syscalls++; - p = curproc; + l = curproc; + p = l->l_proc; code = frame.tf_eax; callp = p->p_emul->e_sysent; params = (caddr_t)frame.tf_esp + sizeof(int); @@ -128,14 +131,14 @@ goto bad; } #ifdef SYSCALL_DEBUG - scdebug_call(p, code, args); + scdebug_call(l, code, args); #endif /* SYSCALL_DEBUG */ rval[0] = 0; rval[1] = frame.tf_edx; /* need to keep edx for shared FreeBSD bins */ - error = (*callp->sy_call)(p, args, rval); + error = (*callp->sy_call)(l, args, rval); switch (error) { case 0: frame.tf_eax = rval[0]; frame.tf_edx = rval[1]; @@ -159,26 +162,28 @@ break; } #ifdef SYSCALL_DEBUG - scdebug_ret(p, code, error, rval); + scdebug_ret(l, code, error, rval); #endif /* SYSCALL_DEBUG */ - userret(p); + userret(l); } void freebsd_syscall_fancy(frame) struct trapframe frame; { register caddr_t params; register const struct sysent *callp; + struct lwp *l; register struct proc *p; int error; size_t argsize; register_t code, args[8], rval[2]; uvmexp.syscalls++; - p = curproc; + l = curproc; + p = l->l_proc; code = frame.tf_eax; callp = p->p_emul->e_sysent; params = (caddr_t)frame.tf_esp + sizeof(int); @@ -212,18 +217,18 @@ goto bad; } #ifdef SYSCALL_DEBUG - scdebug_call(p, code, args); + scdebug_call(l, code, args); #endif /* SYSCALL_DEBUG */ #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) ktrsyscall(p, code, argsize, args); #endif /* KTRACE */ rval[0] = 0; rval[1] = frame.tf_edx; /* need to keep edx for shared FreeBSD bins */ - error = (*callp->sy_call)(p, args, rval); + error = (*callp->sy_call)(l, args, rval); switch (error) { case 0: frame.tf_eax = rval[0]; frame.tf_edx = rval[1]; @@ -247,11 +252,11 @@ break; } #ifdef SYSCALL_DEBUG - scdebug_ret(p, code, error, rval); + scdebug_ret(l, code, error, rval); #endif /* SYSCALL_DEBUG */ - userret(p); + userret(l); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) ktrsysret(p, code, error, rval[0]); #endif /* KTRACE */ Index: sys/arch/i386/i386/gdt.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/gdt.c,v retrieving revision 1.23 retrieving revision 1.23.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.23 -r1.23.2.1 --- sys/arch/i386/i386/gdt.c 2000/08/16 04:44:35 1.23 +++ sys/arch/i386/i386/gdt.c 2001/03/05 22:49:11 1.23.2.1 @@ -37,8 +37,9 @@ */ #include #include +#include #include #include #include @@ -102,24 +103,24 @@ */ void gdt_compact() { - struct proc *p; + struct lwp *l; pmap_t pmap; int slot = NGDT, oslot; proclist_lock_read(); - for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) { - pmap = p->p_vmspace->vm_map.pmap; - oslot = IDXSEL(p->p_md.md_tss_sel); + for (l = alllwp.lh_first; l != 0; l = l->l_list.le_next) { + pmap = l->l_proc->p_vmspace->vm_map.pmap; + oslot = IDXSEL(l->l_md.md_tss_sel); if (oslot >= gdt_count) { while (gdt[slot].sd.sd_type != SDT_SYSNULL) { if (++slot >= gdt_count) panic("gdt_compact botch 1"); } gdt[slot] = gdt[oslot]; gdt[oslot].gd.gd_type = SDT_SYSNULL; - p->p_md.md_tss_sel = GSEL(slot, SEL_KPL); + l->l_md.md_tss_sel = GSEL(slot, SEL_KPL); } simple_lock(&pmap->pm_lock); oslot = IDXSEL(pmap->pm_ldt_sel); if (oslot >= gdt_count) { @@ -271,26 +272,26 @@ gdt_unlock(); } void -tss_alloc(p) - struct proc *p; +tss_alloc(l) + struct lwp *l; { - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = &l->l_addr->u_pcb; int slot; slot = gdt_get_slot(); setsegment(&gdt[slot].sd, &pcb->pcb_tss, sizeof(struct pcb) - 1, SDT_SYS386TSS, SEL_KPL, 0, 0); - p->p_md.md_tss_sel = GSEL(slot, SEL_KPL); + l->l_md.md_tss_sel = GSEL(slot, SEL_KPL); } void -tss_free(p) - struct proc *p; +tss_free(l) + struct lwp *l; { - gdt_put_slot(IDXSEL(p->p_md.md_tss_sel)); + gdt_put_slot(IDXSEL(l->l_md.md_tss_sel)); } void ldt_alloc(pmap, ldt, len) Index: sys/arch/i386/i386/genassym.cf =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/genassym.cf,v retrieving revision 1.25 retrieving revision 1.24.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.25 -r1.24.2.2 --- sys/arch/i386/i386/genassym.cf 2001/03/06 14:55:14 1.25 +++ sys/arch/i386/i386/genassym.cf 2001/04/09 01:53:30 1.24.2.2 @@ -80,8 +80,9 @@ include "opt_compat_linux.h" endif include +include include include include include @@ -124,10 +125,10 @@ if NISA > 0 include endif -define SRUN SRUN -define SONPROC SONPROC +define LSRUN LSRUN +define LSONPROC LSONPROC define PDSLOT_PTE PDSLOT_PTE define PDSLOT_APTE PDSLOT_APTE define PDSLOT_KERN PDSLOT_KERN @@ -137,17 +138,19 @@ define VM_MAXUSER_ADDRESS (int)VM_MAXUSER_ADDRESS define UVM_PAGE_IDLE_ZERO offsetof(struct uvm, page_idle_zero) -define P_ADDR offsetof(struct proc, p_addr) -define P_BACK offsetof(struct proc, p_back) -define P_FORW offsetof(struct proc, p_forw) -define P_PRIORITY offsetof(struct proc, p_priority) -define P_STAT offsetof(struct proc, p_stat) -define P_WCHAN offsetof(struct proc, p_wchan) +define L_ADDR offsetof(struct lwp, l_addr) +define L_BACK offsetof(struct lwp, l_back) +define L_FORW offsetof(struct lwp, l_forw) +define L_PRIORITY offsetof(struct lwp, l_priority) +define L_STAT offsetof(struct lwp, l_stat) +define L_WCHAN offsetof(struct lwp, l_wchan) +define L_PROC offsetof(struct lwp, l_proc) +define L_MD_TSS_SEL offsetof(struct lwp, l_md.md_tss_sel) +define L_MD_REGS offsetof(struct lwp, l_md.md_regs) +define L_MD_TSS_SEL offsetof(struct lwp, l_md.md_tss_sel) define P_FLAG offsetof(struct proc, p_flag) -define P_MD_TSS_SEL offsetof(struct proc, p_md.md_tss_sel) -define P_MD_REGS offsetof(struct proc, p_md.md_regs) define P_MD_SYSCALL offsetof(struct proc, p_md.md_syscall) define P_SYSTEM P_SYSTEM @@ -183,8 +186,9 @@ define SC_FS offsetof(struct sigcontext, sc_fs) define SC_GS offsetof(struct sigcontext, sc_gs) define SC_EFLAGS offsetof(struct sigcontext, sc_eflags) +define SAF_UPCALL offsetof(struct saframe, sa_upcall) ifdef COMPAT_SVR4 define SVR4_SIGF_HANDLER offsetof(struct svr4_sigframe, sf_handler) define SVR4_SIGF_UC offsetof(struct svr4_sigframe, sf_uc) define SVR4_UC_FS offsetof(struct svr4_ucontext, uc_mcontext.greg[SVR4_X86_FS]) Index: sys/arch/i386/i386/ibcs2_machdep.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/ibcs2_machdep.c,v retrieving revision 1.13 retrieving revision 1.13.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.13 -r1.13.4.1 --- sys/arch/i386/i386/ibcs2_machdep.c 2000/12/22 22:58:53 1.13 +++ sys/arch/i386/i386/ibcs2_machdep.c 2001/03/05 22:49:12 1.13.4.1 @@ -41,8 +41,9 @@ #endif #include #include +#include #include #include #include #include @@ -65,19 +66,19 @@ #include #include void -ibcs2_setregs(p, epp, stack) - struct proc *p; +ibcs2_setregs(l, epp, stack) + struct lwp *l; struct exec_package *epp; u_long stack; { - register struct pcb *pcb = &p->p_addr->u_pcb; + register struct pcb *pcb = &l->l_addr->u_pcb; register struct trapframe *tf; - setregs(p, epp, stack); + setregs(l, epp, stack); pcb->pcb_savefpu.sv_env.en_cw = __iBCS2_NPXCW__; - tf = p->p_md.md_regs; + tf = l->l_md.md_regs; tf->tf_eax = 0x2000000; /* XXX base of heap */ } /* @@ -97,14 +98,15 @@ sigset_t *mask; u_long code; { /* XXX Need SCO sigframe format. */ - struct proc *p = curproc; + struct lwp *l = curproc; + struct proc *p = l->l_proc; struct trapframe *tf; struct sigframe *fp, frame; int onstack; - tf = p->p_md.md_regs; + tf = l->l_md.md_regs; /* Do we need to jump onto the signal stack? */ onstack = (p->p_sigctx.ps_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 && @@ -130,9 +132,9 @@ frame.sf_sc.sc_gs = tf->tf_vm86_gs; frame.sf_sc.sc_fs = tf->tf_vm86_fs; frame.sf_sc.sc_es = tf->tf_vm86_es; frame.sf_sc.sc_ds = tf->tf_vm86_ds; - frame.sf_sc.sc_eflags = get_vflags(p); + frame.sf_sc.sc_eflags = get_vflags(l); (*p->p_emul->e_syscall_intern)(p); } else #endif { @@ -166,9 +168,9 @@ /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ - sigexit(p, SIGILL); + sigexit(l, SIGILL); /* NOTREACHED */ } /* @@ -189,10 +191,10 @@ p->p_sigctx.ps_sigstk.ss_flags |= SS_ONSTACK; } int -ibcs2_sys_sysmachine(p, v, retval) - struct proc *p; +ibcs2_sys_sysmachine(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_sysmachine_args /* { Index: sys/arch/i386/i386/ibcs2_syscall.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/ibcs2_syscall.c,v retrieving revision 1.14 retrieving revision 1.14.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.14 -r1.14.4.1 --- sys/arch/i386/i386/ibcs2_syscall.c 2000/12/13 01:24:46 1.14 +++ sys/arch/i386/i386/ibcs2_syscall.c 2001/03/05 22:49:12 1.14.4.1 @@ -90,15 +90,15 @@ struct trapframe frame; { register caddr_t params; register const struct sysent *callp; - register struct proc *p; + struct lwp *l; int error; size_t argsize; register_t code, args[8], rval[2]; uvmexp.syscalls++; - p = curproc; + l = curproc; code = frame.tf_eax; if (IBCS2_HIGH_SYSCALL(code)) code = IBCS2_CVT_HIGH_SYSCALL(code); @@ -126,14 +126,14 @@ goto bad; } #ifdef SYSCALL_DEBUG - scdebug_call(p, code, args); + scdebug_call(l, code, args); #endif /* SYSCALL_DEBUG */ rval[0] = 0; rval[1] = 0; - error = (*callp->sy_call)(p, args, rval); + error = (*callp->sy_call)(l, args, rval); switch (error) { case 0: frame.tf_eax = rval[0]; frame.tf_edx = rval[1]; @@ -158,11 +158,11 @@ break; } #ifdef SYSCALL_DEBUG - scdebug_ret(p, code, error, rval); + scdebug_ret(l, code, error, rval); #endif /* SYSCALL_DEBUG */ - userret(p); + userret(l); } /* * syscall(frame): @@ -174,15 +174,17 @@ struct trapframe frame; { register caddr_t params; register const struct sysent *callp; + struct lwp *l; register struct proc *p; int error; size_t argsize; register_t code, args[8], rval[2]; uvmexp.syscalls++; - p = curproc; + l = curproc; + p = l->l_proc; code = frame.tf_eax; if (IBCS2_HIGH_SYSCALL(code)) code = IBCS2_CVT_HIGH_SYSCALL(code); @@ -210,18 +212,18 @@ goto bad; } #ifdef SYSCALL_DEBUG - scdebug_call(p, code, args); + scdebug_call(l, code, args); #endif /* SYSCALL_DEBUG */ #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) ktrsyscall(p, code, argsize, args); #endif /* KTRACE */ rval[0] = 0; rval[1] = 0; - error = (*callp->sy_call)(p, args, rval); + error = (*callp->sy_call)(l, args, rval); switch (error) { case 0: frame.tf_eax = rval[0]; frame.tf_edx = rval[1]; @@ -246,11 +248,11 @@ break; } #ifdef SYSCALL_DEBUG - scdebug_ret(p, code, error, rval); + scdebug_ret(l, code, error, rval); #endif /* SYSCALL_DEBUG */ - userret(p); + userret(l); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) ktrsysret(p, code, error, rval[0]); #endif /* KTRACE */ Index: sys/arch/i386/i386/linux_syscall.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/linux_syscall.c,v retrieving revision 1.15 retrieving revision 1.15.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.15 -r1.15.4.1 --- sys/arch/i386/i386/linux_syscall.c 2000/12/14 18:35:13 1.15 +++ sys/arch/i386/i386/linux_syscall.c 2001/03/05 22:49:12 1.15.4.1 @@ -90,15 +90,15 @@ linux_syscall_plain(frame) struct trapframe frame; { register const struct sysent *callp; - register struct proc *p; + struct lwp *l; int error; size_t argsize; register_t code, args[8], rval[2]; uvmexp.syscalls++; - p = curproc; + l = curproc; code = frame.tf_eax; callp = linux_sysent; @@ -128,13 +128,13 @@ break; } } #ifdef SYSCALL_DEBUG - scdebug_call(p, code, args); + scdebug_call(l, code, args); #endif /* SYSCALL_DEBUG */ rval[0] = 0; rval[1] = 0; - error = (*callp->sy_call)(p, args, rval); + error = (*callp->sy_call)(l, args, rval); switch (error) { case 0: frame.tf_eax = rval[0]; frame.tf_eflags &= ~PSL_C; /* carry bit */ @@ -157,11 +157,11 @@ break; } #ifdef SYSCALL_DEBUG - scdebug_ret(p, code, error, rval); + scdebug_ret(l, code, error, rval); #endif /* SYSCALL_DEBUG */ - userret(p); + userret(l); } /* * syscall(frame): @@ -172,15 +172,17 @@ linux_syscall_fancy(frame) struct trapframe frame; { register const struct sysent *callp; + struct lwp *l; register struct proc *p; int error; size_t argsize; register_t code, args[8], rval[2]; uvmexp.syscalls++; - p = curproc; + l = curproc; + p = l->l_proc; code = frame.tf_eax; callp = linux_sysent; @@ -210,17 +212,17 @@ break; } } #ifdef SYSCALL_DEBUG - scdebug_call(p, code, args); + scdebug_call(l, code, args); #endif /* SYSCALL_DEBUG */ #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) ktrsyscall(p, code, argsize, args); #endif /* KTRACE */ rval[0] = 0; rval[1] = 0; - error = (*callp->sy_call)(p, args, rval); + error = (*callp->sy_call)(l, args, rval); switch (error) { case 0: frame.tf_eax = rval[0]; frame.tf_eflags &= ~PSL_C; /* carry bit */ @@ -243,11 +245,11 @@ break; } #ifdef SYSCALL_DEBUG - scdebug_ret(p, code, error, rval); + scdebug_ret(l, code, error, rval); #endif /* SYSCALL_DEBUG */ - userret(p); + userret(l); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) ktrsysret(p, code, error, rval[0]); #endif /* KTRACE */ Index: sys/arch/i386/i386/locore.s =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/locore.s,v retrieving revision 1.235 retrieving revision 1.233.2.3 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.235 -r1.233.2.3 --- sys/arch/i386/i386/locore.s 2001/04/01 23:54:14 1.235 +++ sys/arch/i386/i386/locore.s 2001/04/09 01:53:30 1.233.2.3 @@ -723,8 +723,16 @@ movl $SYS___sigreturn14,%eax int $0x80 # enter kernel with args on stack movl $SYS_exit,%eax int $0x80 # exit if sigreturn fails + +/* + * Scheduler activations upcall trampoline. + */ +NENTRY(upcallcode) + call SAF_UPCALL(%esp) + movl $SYS_sa_yield,%eax + int $0x80 # upcalls should not return. .globl _C_LABEL(esigcode) _C_LABEL(esigcode): /*****************************************************************************/ @@ -1642,30 +1650,30 @@ .globl _C_LABEL(sched_whichqs),_C_LABEL(sched_qs) .globl _C_LABEL(uvmexp),_C_LABEL(panic) /* - * setrunqueue(struct proc *p); + * setrunqueue(struct lwp *l); * Insert a process on the appropriate queue. Should be called at splclock(). */ NENTRY(setrunqueue) movl 4(%esp),%eax #ifdef DIAGNOSTIC - cmpl $0,P_BACK(%eax) # should not be on q already + cmpl $0,L_BACK(%eax) # should not be on q already jne 1f - cmpl $0,P_WCHAN(%eax) + cmpl $0,L_WCHAN(%eax) jne 1f - cmpb $SRUN,P_STAT(%eax) + cmpb $LSRUN,L_STAT(%eax) jne 1f #endif /* DIAGNOSTIC */ - movzbl P_PRIORITY(%eax),%edx + movzbl L_PRIORITY(%eax),%edx shrl $2,%edx btsl %edx,_C_LABEL(sched_whichqs) # set q full bit leal _C_LABEL(sched_qs)(,%edx,8),%edx # locate q hdr - movl P_BACK(%edx),%ecx - movl %edx,P_FORW(%eax) # link process on tail of q - movl %eax,P_BACK(%edx) - movl %eax,P_FORW(%ecx) - movl %ecx,P_BACK(%eax) + movl L_BACK(%edx),%ecx + movl %edx,L_FORW(%eax) # link process on tail of q + movl %eax,L_BACK(%edx) + movl %eax,L_FORW(%ecx) + movl %ecx,L_BACK(%eax) ret #ifdef DIAGNOSTIC 1: pushl $2f call _C_LABEL(panic) @@ -1673,24 +1681,24 @@ 2: .asciz "setrunqueue" #endif /* DIAGNOSTIC */ /* - * remrunqueue(struct proc *p); + * remrunqueue(struct lwp *l); * Remove a process from its queue. Should be called at splclock(). */ NENTRY(remrunqueue) movl 4(%esp),%ecx - movzbl P_PRIORITY(%ecx),%eax + movzbl L_PRIORITY(%ecx),%eax #ifdef DIAGNOSTIC shrl $2,%eax btl %eax,_C_LABEL(sched_whichqs) jnc 1f #endif /* DIAGNOSTIC */ - movl P_BACK(%ecx),%edx # unlink process - movl $0,P_BACK(%ecx) # zap reverse link to indicate off list - movl P_FORW(%ecx),%ecx - movl %ecx,P_FORW(%edx) - movl %edx,P_BACK(%ecx) + movl L_BACK(%ecx),%edx # unlink process + movl $0,L_BACK(%ecx) # zap reverse link to indicate off list + movl L_FORW(%ecx),%ecx + movl %ecx,L_FORW(%edx) + movl %edx,L_BACK(%ecx) cmpl %ecx,%edx # q still has something? jne 2f #ifndef DIAGNOSTIC shrl $2,%eax @@ -1808,16 +1816,16 @@ jz _C_LABEL(idle) # if none, idle leal _C_LABEL(sched_qs)(,%ebx,8),%eax # select q - movl P_FORW(%eax),%edi # unlink from front of process q + movl L_FORW(%eax),%edi # unlink from front of process q #ifdef DIAGNOSTIC cmpl %edi,%eax # linked to self (i.e. nothing queued)? je _C_LABEL(switch_error) # not possible #endif /* DIAGNOSTIC */ - movl P_FORW(%edi),%edx - movl %edx,P_FORW(%eax) - movl %eax,P_BACK(%edx) + movl L_FORW(%edi),%edx + movl %edx,L_FORW(%eax) + movl %eax,L_BACK(%edx) cmpl %edx,%eax # q empty? jne 3f @@ -1828,16 +1836,16 @@ xorl %eax,%eax movl %eax,_C_LABEL(want_resched) #ifdef DIAGNOSTIC - cmpl %eax,P_WCHAN(%edi) # Waiting for something? + cmpl %eax,L_WCHAN(%edi) # Waiting for something? jne _C_LABEL(switch_error) # Yes; shouldn't be queued. - cmpb $SRUN,P_STAT(%edi) # In run state? + cmpb $LSRUN,L_STAT(%edi) # In run state? jne _C_LABEL(switch_error) # No; shouldn't be queued. #endif /* DIAGNOSTIC */ /* Isolate process. XXX Is this necessary? */ - movl %eax,P_BACK(%edi) + movl %eax,L_BACK(%edi) #if defined(LOCKDEBUG) /* * Unlock the sched_lock, but leave interrupts off, for now. @@ -1852,15 +1860,16 @@ */ #endif /* Record new process. */ - movb $SONPROC,P_STAT(%edi) # p->p_stat = SONPROC + movb $LSONPROC,L_STAT(%edi) # l->l_stat = LSONPROC movl %edi,_C_LABEL(curproc) /* It's okay to take interrupts here. */ sti /* Skip context switch if same process. */ + movl $1, %eax cmpl %edi,%esi je switch_return /* If old process exited, don't bother. */ @@ -1875,9 +1884,9 @@ * %esi - old process, then old pcb * %edi - new process */ - movl P_ADDR(%esi),%esi + movl L_ADDR(%esi),%esi /* Save segment registers. */ movl %fs,%ax movl %gs,%cx @@ -1899,17 +1908,17 @@ */ /* No interrupts while loading new state. */ cli - movl P_ADDR(%edi),%esi + movl L_ADDR(%edi),%esi /* Restore stack pointers. */ movl PCB_ESP(%esi),%esp movl PCB_EBP(%esi),%ebp #if 0 /* Don't bother with the rest if switching to a system process. */ - testl $P_SYSTEM,P_FLAG(%edi) + testl $P_SYSTEM,L_FLAG(%edi); XXX NJWLWP lwp's don't have P_SYSTEM! jnz switch_restored #endif /* @@ -1923,9 +1932,9 @@ addl $4,%esp /* Load TSS info. */ movl _C_LABEL(gdt),%eax - movl P_MD_TSS_SEL(%edi),%edx + movl L_MD_TSS_SEL(%edi),%edx /* Switch TSS. Reset "task busy" flag before */ andl $~0x0200,4(%eax,%edx, 1) ltr %dx @@ -1957,47 +1966,263 @@ movl %esi,_C_LABEL(curpcb) /* Interrupts are okay again. */ sti - + xor %eax,%eax switch_return: /* * Restore old cpl from stack. Note that this is always an increase, * due to the spl0() on entry. */ popl _C_LABEL(cpl) - movl %edi,%eax # return (p); popl %edi popl %esi popl %ebx ret + + +#ifdef DIAGNOSTIC +NENTRY(preempt_error) + pushl $1f + call _C_LABEL(panic) + /* NOTREACHED */ +1: .asciz "cpu_preempt" +#endif /* DIAGNOSTIC */ + /* - * switch_exit(struct proc *p); + * void cpu_preempt(struct lwp *current, struct lwp *next) + * Switch to the specified next LWP. + */ +ENTRY(cpu_preempt) + pushl %ebx + pushl %esi + pushl %edi + pushl _C_LABEL(cpl) + + movl _C_LABEL(curproc),%esi # why don't we look on the stack here? + movl 24(%esp),%edi # next + + /* + * Clear curproc so that we don't accumulate system time while idle. + * This also insures that schedcpu() will move the old process to + * the correct queue if it happens to get called from the spllower() + * below and changes the priority. (See corresponding comment in + * userret()). + */ + movl $0,_C_LABEL(curproc) + +#if defined(LOCKDEBUG) + /* Release the sched_lock before processing interrupts. */ + call _C_LABEL(sched_unlock_idle) +#endif + + movl $0,_C_LABEL(cpl) # spl0() + call _C_LABEL(Xspllower) # process pending interrupts + +preempt_search: + /* + * First phase: remove new process from queue. + */ + + /* Lock the scheduler. */ + cli # splhigh doesn't do a cli +#if defined(LOCKDEBUG) + call _C_LABEL(sched_lock_idle) +#endif + + movzbl L_PRIORITY(%edi),%eax +#ifdef DIAGNOSTIC + shrl $2,%eax + btl %eax,_C_LABEL(sched_whichqs) + jnc _C_LABEL(preempt_error) +#endif /* DIAGNOSTIC */ + movl L_BACK(%edi),%edx # unlink process + movl $0,L_BACK(%edi) # zap reverse link to indicate off list + movl L_FORW(%edi),%ecx + movl %ecx,L_FORW(%edx) + movl %edx,L_BACK(%ecx) + cmpl %ecx,%edx # q still has something? + jne 3f +#ifndef DIAGNOSTIC + shrl $2,%eax +#endif + btrl %eax,_C_LABEL(sched_whichqs) # no; clear bit + +3: + xorl %eax,%eax + +#ifdef DIAGNOSTIC + cmpl %eax,L_WCHAN(%edi) # Waiting for something? + jne _C_LABEL(preempt_error) # Yes; shouldn't be queued. + cmpb $LSRUN,L_STAT(%edi) # In run state? + jne _C_LABEL(preempt_error) # No; shouldn't be queued. +#endif /* DIAGNOSTIC */ + + /* Isolate process. XXX Is this necessary? */ + movl %eax,L_BACK(%edi) + +#if defined(LOCKDEBUG) + /* + * Unlock the sched_lock, but leave interrupts off, for now. + */ + call _C_LABEL(sched_unlock_idle) +#endif + +#if defined(MULTIPROCESSOR) + /* + * p->p_cpu = curcpu() + * XXXSMP + */ +#endif + + /* Record new process. */ + movb $LSONPROC,L_STAT(%edi) # l->l_stat = LSONPROC + movl %edi,_C_LABEL(curproc) + + /* It's okay to take interrupts here. */ + sti + + /* Skip context switch if same process. */ + cmpl %edi,%esi + je switch_return + + /* If old process exited, don't bother. */ + testl %esi,%esi + jz switch_exited + + /* + * Second phase: save old context. + * + * Registers: + * %eax, %ecx - scratch + * %esi - old process, then old pcb + * %edi - new process + */ + + movl L_ADDR(%esi),%esi + + /* Save segment registers. */ + movl %fs,%ax + movl %gs,%cx + movl %eax,PCB_FS(%esi) + movl %ecx,PCB_GS(%esi) + + /* Save stack pointers. */ + movl %esp,PCB_ESP(%esi) + movl %ebp,PCB_EBP(%esi) + +preempt_exited: + /* + * Third phase: restore saved context. + * + * Registers: + * %eax, %ecx, %edx - scratch + * %esi - new pcb + * %edi - new process + */ + + /* No interrupts while loading new state. */ + cli + movl L_ADDR(%edi),%esi + + /* Restore stack pointers. */ + movl PCB_ESP(%esi),%esp + movl PCB_EBP(%esi),%ebp + +#if 0 + /* Don't bother with the rest if switching to a system process. */ + testl $P_SYSTEM,L_FLAG(%edi); XXX NJWLWP lwp's don't have P_SYSTEM! + jnz switch_restored +#endif + + /* + * Activate the address space. We're curproc, so %cr3 will + * be reloaded, but we're not yet curpcb, so the LDT won't + * be reloaded, although the PCB copy of the selector will + * be refreshed from the pmap. + */ + pushl %edi + call _C_LABEL(pmap_activate) + addl $4,%esp + + /* Load TSS info. */ + movl _C_LABEL(gdt),%eax + movl L_MD_TSS_SEL(%edi),%edx + + /* Switch TSS. Reset "task busy" flag before */ + andl $~0x0200,4(%eax,%edx, 1) + ltr %dx + +#ifdef USER_LDT + /* + * Switch LDT. + * + * XXX + * Always do this, because the LDT could have been swapped into a + * different selector after a process exited. (See gdt_compact().) + */ + movl PCB_LDT_SEL(%esi),%edx + lldt %dx +#endif /* USER_LDT */ + + /* Restore segment registers. */ + movl PCB_FS(%esi),%eax + movl PCB_GS(%esi),%ecx + movl %ax,%fs + movl %cx,%gs + +preempt_restored: + /* Restore cr0 (including FPU state). */ + movl PCB_CR0(%esi),%ecx + movl %ecx,%cr0 + + /* Record new pcb. */ + movl %esi,_C_LABEL(curpcb) + + /* Interrupts are okay again. */ + sti + +preempt_return: + /* + * Restore old cpl from stack. Note that this is always an increase, + * due to the spl0() on entry. + */ + popl _C_LABEL(cpl) + + movl %edi,%eax # return (p); + popl %edi + popl %esi + popl %ebx + ret +/* NJW */ + +/* + * switch_exit(struct lwp *l); * Switch to proc0's saved context and deallocate the address space and kernel * stack for p. Then jump into cpu_switch(), as if we were in proc0 all along. */ - .globl _C_LABEL(proc0),_C_LABEL(uvmspace_free),_C_LABEL(kernel_map) + .globl _C_LABEL(lwp0),_C_LABEL(uvmspace_free),_C_LABEL(kernel_map) .globl _C_LABEL(uvm_km_free),_C_LABEL(tss_free) ENTRY(switch_exit) movl 4(%esp),%edi # old process - movl $_C_LABEL(proc0),%ebx + movl $_C_LABEL(lwp0),%ebx /* In case we fault... */ movl $0,_C_LABEL(curproc) - /* Restore proc0's context. */ + /* Restore lwp0's context. */ cli - movl P_ADDR(%ebx),%esi + movl L_ADDR(%ebx),%esi /* Restore stack pointers. */ movl PCB_ESP(%esi),%esp movl PCB_EBP(%esi),%ebp /* Load TSS info. */ movl _C_LABEL(gdt),%eax - movl P_MD_TSS_SEL(%ebx),%edx + movl L_MD_TSS_SEL(%ebx),%edx /* Switch address space. */ movl PCB_CR3(%esi),%ecx movl %ecx,%cr3 @@ -2025,17 +2250,81 @@ /* * Schedule the dead process's vmspace and stack to be freed. */ - pushl %edi /* exit2(p) */ + pushl %edi /* exit2(l) */ call _C_LABEL(exit2) addl $4,%esp /* Jump into cpu_switch() with the right state. */ movl %ebx,%esi movl $0,_C_LABEL(curproc) jmp switch_search + + +/* switch_lwp_exit(struct lwp *l); + * Switch to lwp0's saved context and deallocate the address space and kernel + * stack for p. Then jump into cpu_switch(), as if we were in proc0 all along. + */ + .globl _C_LABEL(lwp0),_C_LABEL(uvmspace_free),_C_LABEL(kernel_map) + .globl _C_LABEL(uvm_km_free),_C_LABEL(tss_free) +ENTRY(switch_lwp_exit) + movl 4(%esp),%edi # old process + movl $_C_LABEL(lwp0),%ebx + + /* In case we fault... */ + movl $0,_C_LABEL(curproc) + + /* Restore lwp0's context. */ + cli + movl L_ADDR(%ebx),%esi + + /* Restore stack pointers. */ + movl PCB_ESP(%esi),%esp + movl PCB_EBP(%esi),%ebp + + /* Load TSS info. */ + movl _C_LABEL(gdt),%eax + movl L_MD_TSS_SEL(%ebx),%edx + + /* Switch address space. */ + movl PCB_CR3(%esi),%ecx + movl %ecx,%cr3 + + /* Switch TSS. */ + andl $~0x0200,4-SEL_KPL(%eax,%edx,1) + ltr %dx + + /* We're always in the kernel, so we don't need the LDT. */ + + /* Clear segment registers; always null in proc0. */ + xorl %ecx,%ecx + movl %cx,%fs + movl %cx,%gs + + /* Restore cr0 (including FPU state). */ + movl PCB_CR0(%esi),%ecx + movl %ecx,%cr0 + + /* Record new pcb. */ + movl %esi,_C_LABEL(curpcb) + + /* Interrupts are okay again. */ + sti + + /* + * Schedule the dead process's vmspace and stack to be freed. + */ + pushl %edi /* lwp_exit2(l) */ + call _C_LABEL(lwp_exit2) + addl $4,%esp + + /* Jump into cpu_switch() with the right state. */ + movl %ebx,%esi + movl $0,_C_LABEL(curproc) + jmp switch_search + /* * savectx(struct pcb *pcb); * Update pcb, saving current processor state. */ @@ -2363,9 +2652,10 @@ movl _C_LABEL(curproc),%edx # get pointer to curproc #ifdef DIAGNOSTIC movl _C_LABEL(cpl),%ebx #endif /* DIAGNOSTIC */ - movl %esp,P_MD_REGS(%edx) # save pointer to frame + movl %esp,L_MD_REGS(%edx) # save pointer to frame + movl L_PROC(%edx),%edx call P_MD_SYSCALL(%edx) # get pointer to syscall() function 2: /* Check for ASTs on exit to user mode. */ cli cmpb $0,_C_LABEL(astpending) Index: sys/arch/i386/i386/machdep.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/machdep.c,v retrieving revision 1.430 retrieving revision 1.429.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.430 -r1.429.2.2 --- sys/arch/i386/i386/machdep.c 2001/03/15 06:10:40 1.430 +++ sys/arch/i386/i386/machdep.c 2001/04/09 01:53:31 1.429.2.2 @@ -89,8 +89,9 @@ #include #include #include #include +#include #include #include #include #include @@ -105,9 +106,12 @@ #include #include #include #include +#include #include +#include +#include #ifdef IPKDB #include #endif @@ -159,9 +163,9 @@ #include "isa.h" #include "isadma.h" #include "npx.h" #if NNPX > 0 -extern struct proc *npxproc; +extern struct lwp *npxproc; #endif #include "mca.h" #if NMCA > 0 @@ -489,9 +493,9 @@ struct pcb *pcb; int x; gdt_init(); - curpcb = pcb = &proc0.p_addr->u_pcb; + curpcb = pcb = &lwp0.l_addr->u_pcb; pcb->pcb_flags = 0; pcb->pcb_tss.tss_ioopt = ((caddr_t)pcb->pcb_iomap - (caddr_t)&pcb->pcb_tss) << 16; for (x = 0; x < sizeof(pcb->pcb_iomap) / 4; x++) @@ -499,15 +503,15 @@ pcb->pcb_ldt_sel = pmap_kernel()->pm_ldt_sel = GSEL(GLDT_SEL, SEL_KPL); pcb->pcb_cr0 = rcr0(); pcb->pcb_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL); - pcb->pcb_tss.tss_esp0 = (int)proc0.p_addr + USPACE - 16; - tss_alloc(&proc0); + pcb->pcb_tss.tss_esp0 = (int)lwp0.l_addr + USPACE - 16; + tss_alloc(&lwp0); - ltr(proc0.p_md.md_tss_sel); + ltr(lwp0.l_md.md_tss_sel); lldt(pcb->pcb_ldt_sel); - proc0.p_md.md_regs = (struct trapframe *)pcb->pcb_tss.tss_esp0 - 1; + lwp0.l_md.md_regs = (struct trapframe *)pcb->pcb_tss.tss_esp0 - 1; } /* * XXX Finish up the deferred buffer cache allocation and initialization. @@ -1159,15 +1163,24 @@ int sig; sigset_t *mask; u_long code; { - struct proc *p = curproc; + struct lwp *l = curproc; + struct proc *p = l->l_proc; struct trapframe *tf; struct sigframe *fp, frame; int onstack; - tf = p->p_md.md_regs; + if (p->p_flag & P_SA) { + if (code) + sa_upcall(l, SA_UPCALL_SIGNAL, l, NULL, sig, code); + else + sa_upcall(l, SA_UPCALL_SIGNAL, NULL, l, sig, 0); + return; + } + tf = l->l_md.md_regs; + /* Do we need to jump onto the signal stack? */ onstack = (p->p_sigctx.ps_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 && (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0; @@ -1192,9 +1205,9 @@ frame.sf_sc.sc_gs = tf->tf_vm86_gs; frame.sf_sc.sc_fs = tf->tf_vm86_fs; frame.sf_sc.sc_es = tf->tf_vm86_es; frame.sf_sc.sc_ds = tf->tf_vm86_ds; - frame.sf_sc.sc_eflags = get_vflags(p); + frame.sf_sc.sc_eflags = get_vflags(l); (*p->p_emul->e_syscall_intern)(p); } else #endif { @@ -1238,9 +1251,9 @@ /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ - sigexit(p, SIGILL); + sigexit(l, SIGILL); /* NOTREACHED */ } /* @@ -1260,8 +1273,103 @@ if (onstack) p->p_sigctx.ps_sigstk.ss_flags |= SS_ONSTACK; } +/* Save the user-level ucontext_t on the LWP's own stack. */ +ucontext_t * +cpu_stashcontext(struct lwp *l) +{ + ucontext_t u, *up; + struct trapframe *tf; + void *stack; + + tf = l->l_md.md_regs; + stack = (char *)tf->tf_esp - sizeof(ucontext_t); + getucontext(l, &u); + up = stack; + + if (copyout(&u, stack, sizeof(ucontext_t)) != 0) { + /* Copying onto the stack didn't work. Die. */ + sigexit(l, SIGILL); + /* NOTREACHED */ + } + + return up; +} + + +void +cpu_upcall(struct lwp *l, stack_t *st, int type, int events, int interrupted, + struct sa_t *sas[]) +{ + struct proc *p = l->l_proc; + + struct sadata *sd = p->p_sa; + struct saframe *sf, frame; + struct sa_t **sapp, *sap; + struct trapframe *tf; + void *stack; + ucontext_t u, *up; + int i, nsas; + + extern char sigcode[], upcallcode[]; + + tf = l->l_md.md_regs; + + stack = (char *)st->ss_sp + st->ss_size; + + /* First, copy out the activation's ucontext */ + u.uc_stack = *st; + u.uc_flags = _UC_STACK; + up = stack; + up--; + if (copyout(&u, up, sizeof(ucontext_t)) != 0) { + sigexit(l, SIGILL); + /* NOTREACHED */ + } + stack = up; + sas[0]->sa_context = up; + + /* Next, copy out the sa_t's and pointers to them. */ + sap = stack; + nsas = events + interrupted; + sapp = (struct sa_t **)(sap - (nsas + 1)); + for (i = nsas; i >= 0; i--) { + sap--; + sapp--; + if ((copyout(sas[i], sap, sizeof(struct sa_t)) != 0) || + (copyout(&sap, sapp, sizeof(struct sa_t *)) != 0)) { + /* Copying onto the stack didn't work. Die. */ + sigexit(l, SIGILL); + /* NOTREACHED */ + } + } + + /* Finally, copy out the rest of the frame. */ + sf = (struct saframe *)sapp - 1; + frame.sa_type = type; + frame.sa_sas = sapp; + frame.sa_events = events; + frame.sa_interrupted = interrupted; + frame.sa_upcall = sd->sa_upcall; + + if (copyout(&frame, sf, sizeof(frame)) != 0) { + /* Copying onto the stack didn't work. Die. */ + sigexit(l, SIGILL); + /* NOTREACHED */ + } + + /* XXX hack-o-matic */ + tf->tf_eip = (int)((caddr_t) p->p_sigctx.ps_sigcode + ( + (caddr_t)upcallcode - (caddr_t)sigcode)); + tf->tf_esp = (int) sf; + tf->tf_es = GSEL(GUDATA_SEL, SEL_UPL); + tf->tf_ds = GSEL(GUDATA_SEL, SEL_UPL); + tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL); + tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL); + tf->tf_eflags &= ~(PSL_T|PSL_VM|PSL_AC); +} + /* * System call to cleanup state after a signal * has been taken. Reset signal mask and * stack state from context left by sendsig (above). @@ -1271,16 +1379,17 @@ * psl to gain improper privileges or to cause * a machine fault. */ int -sys___sigreturn14(p, v, retval) - struct proc *p; +sys___sigreturn14(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys___sigreturn14_args /* { syscallarg(struct sigcontext *) sigcntxp; } */ *uap = v; + struct proc *p = l->l_proc; struct sigcontext *scp, context; struct trapframe *tf; /* @@ -1292,18 +1401,18 @@ if (copyin((caddr_t)scp, &context, sizeof(*scp)) != 0) return (EFAULT); /* Restore register context. */ - tf = p->p_md.md_regs; + tf = l->l_md.md_regs; #ifdef VM86 if (context.sc_eflags & PSL_VM) { void syscall_vm86 __P((struct trapframe)); tf->tf_vm86_gs = context.sc_gs; tf->tf_vm86_fs = context.sc_fs; tf->tf_vm86_es = context.sc_es; tf->tf_vm86_ds = context.sc_ds; - set_vflags(p, context.sc_eflags); + set_vflags(l, context.sc_eflags); p->p_md.md_syscall = syscall_vm86; } else #endif { @@ -1345,8 +1454,9 @@ return (EJUSTRETURN); } + int waittime = -1; struct pcb dumppcb; void @@ -1678,31 +1788,31 @@ /* * Clear registers on exec */ void -setregs(p, pack, stack) - struct proc *p; +setregs(l, pack, stack) + struct lwp *l; struct exec_package *pack; u_long stack; { - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = &l->l_addr->u_pcb; struct trapframe *tf; #if NNPX > 0 /* If we were using the FPU, forget about it. */ - if (npxproc == p) + if (npxproc == l) npxdrop(); #endif #ifdef USER_LDT - pmap_ldt_cleanup(p); + pmap_ldt_cleanup(l); #endif - p->p_md.md_flags &= ~MDP_USEDFPU; + l->l_md.md_flags &= ~MDP_USEDFPU; pcb->pcb_flags = 0; pcb->pcb_savefpu.sv_env.en_cw = __NetBSD_NPXCW__; - tf = p->p_md.md_regs; + tf = l->l_md.md_regs; __asm("movl %w0,%%gs" : : "r" (LSEL(LUDATA_SEL, SEL_UPL))); __asm("movl %w0,%%fs" : : "r" (LSEL(LUDATA_SEL, SEL_UPL))); tf->tf_es = LSEL(LUDATA_SEL, SEL_UPL); tf->tf_ds = LSEL(LUDATA_SEL, SEL_UPL); @@ -1802,10 +1912,10 @@ int x, first16q; u_int64_t seg_start, seg_end; u_int64_t seg_start1, seg_end1; - proc0.p_addr = proc0paddr; - curpcb = &proc0.p_addr->u_pcb; + lwp0.l_addr = proc0paddr; + curpcb = &lwp0.l_addr->u_pcb; i386_bus_space_init(); consinit(); /* XXX SHOULD NOT BE DONE HERE */ @@ -2456,5 +2566,153 @@ tlbflush(); #endif for (;;); +} + +void +cpu_getmcontext(l, mcp, flags) + struct lwp *l; + mcontext_t *mcp; + unsigned int *flags; +{ + const struct trapframe *tf = l->l_md.md_regs; + __greg_t *gr = mcp->__gregs; + + /* Save register context. */ +#ifdef VM86 + if (tf->tf_eflags & PSL_VM) { + gr[_REG_GS] = tf->tf_vm86_gs; + gr[_REG_FS] = tf->tf_vm86_fs; + gr[_REG_ES] = tf->tf_vm86_es; + gr[_REG_DS] = tf->tf_vm86_ds; + gr[_REG_EFL] = get_vflags(l); + } else +#endif + { + __asm("movl %%gs,%w0" : "=r" (gr[_REG_GS])); + __asm("movl %%fs,%w0" : "=r" (gr[_REG_FS])); + gr[_REG_ES] = tf->tf_es; + gr[_REG_DS] = tf->tf_ds; + gr[_REG_EFL] = tf->tf_eflags; + } + gr[_REG_EDI] = tf->tf_edi; + gr[_REG_ESI] = tf->tf_esi; + gr[_REG_EBP] = tf->tf_ebp; + gr[_REG_EBX] = tf->tf_ebx; + gr[_REG_EDX] = tf->tf_edx; + gr[_REG_ECX] = tf->tf_ecx; + gr[_REG_EAX] = tf->tf_eax; + gr[_REG_EIP] = tf->tf_eip; + gr[_REG_CS] = tf->tf_cs; + gr[_REG_ESP] = tf->tf_esp; + gr[_REG_UESP] = tf->tf_esp; + gr[_REG_SS] = tf->tf_ss; + gr[_REG_TRAPNO] = tf->tf_trapno; + gr[_REG_ERR] = tf->tf_err; + *flags |= _UC_CPU; + + /* Save floating point register context, if any. */ + if ((l->l_md.md_flags & MDP_USEDFPU) != 0) { +#if NNPX > 0 + /* + * If this process is the current FP owner, dump its + * context to the PCB first. + * XXX npxsave() also clears the FPU state; depending on the + * XXX application this might be a penalty. + */ + if (l == npxproc) { + npxsave(); + } +#endif + memcpy(&mcp->__fpregs.__fp_reg_set.__fpchip_state.__fp_state, + &l->l_addr->u_pcb.pcb_savefpu, + sizeof (mcp->__fpregs.__fp_reg_set.__fpchip_state.__fp_state)); +#if 0 + /* Apparently nothing ever touches this. */ + ucp->mcp.mc_fp.fp_emcsts = l->l_addr->u_pcb.pcb_saveemc; +#endif + *flags |= _UC_FPU; + } +} + +int +cpu_setmcontext(l, mcp, flags) + struct lwp *l; + const mcontext_t *mcp; + unsigned int flags; +{ + struct trapframe *tf = l->l_md.md_regs; + __greg_t *gr = mcp->__gregs; + + /* Restore register context, if any. */ + if ((flags & _UC_CPU) != 0) { +#ifdef VM86 + if (tf->tf_eflags & PSL_VM) { + tf->tf_vm86_gs = gr[_REG_GS]; + tf->tf_vm86_fs = gr[_REG_FS]; + tf->tf_vm86_es = gr[_REG_ES]; + tf->tf_vm86_ds = gr[_REG_DS]; + set_vflags(l, gr[_REG_EFL]); + } else +#endif + { + /* + * Check for security violations. If we're returning + * to protected mode, the CPU will validate the segment + * registers automatically and generate a trap on + * violations. We handle the trap, rather than doing + * all of the checking here. + */ + if (!USERMODE(gr[_REG_CS], gr[_REG_EFL])) { + printf("cpu_setmcontext error: uc EFL: %08x tf EFL: %08x uc CS: %d", + gr[_REG_EFL], tf->tf_eflags, gr[_REG_CS]); + return (EINVAL); + } + __asm("movl %w0,%%gs" : : "r" (gr[_REG_GS])); + __asm("movl %w0,%%fs" : : "r" (gr[_REG_FS])); + tf->tf_es = gr[_REG_ES]; + tf->tf_ds = gr[_REG_DS]; + /* Only change the user-alterable part of eflags */ + tf->tf_eflags &= ~PSL_USER; + tf->tf_eflags |= (gr[_REG_EFL] & PSL_USER); + } + tf->tf_edi = gr[_REG_EDI]; + tf->tf_esi = gr[_REG_ESI]; + tf->tf_ebp = gr[_REG_EBP]; + tf->tf_ebx = gr[_REG_EBX]; + tf->tf_edx = gr[_REG_EDX]; + tf->tf_ecx = gr[_REG_ECX]; + tf->tf_eax = gr[_REG_EAX]; + tf->tf_eip = gr[_REG_EIP]; + tf->tf_cs = gr[_REG_CS]; + tf->tf_esp = gr[_REG_UESP]; + tf->tf_ss = gr[_REG_SS]; +#if 0 /* XXX nonzero trapno/err values will crash the box with "unknown trap" */ + tf->tf_trapno = gr[_REG_TRAPNO]; + tf->tf_err = gr[_REG_ERR]; +#endif + } + + /* Restore floating point register context, if any. */ + if ((flags & _UC_FPU) != 0) { +#if NNPX > 0 + /* + * If this process happens to be the current FPU owner, + * forget about its (to be overwritten) context. + */ + if (l == npxproc) + npxdrop(); +#endif + (void)memcpy(&l->l_addr->u_pcb.pcb_savefpu, + &mcp->__fpregs.__fp_reg_set.__fpchip_state.__fp_state, + sizeof (l->l_addr->u_pcb.pcb_savefpu)); + /* If not set already. */ + l->l_md.md_flags |= MDP_USEDFPU; +#if 0 + /* Apparently unused. */ + l->l_addr->u_pcb.pcb_saveemc = mcp->mc_fp.fp_emcsts; +#endif + } + + return (0); } Index: sys/arch/i386/i386/math_emulate.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/math_emulate.c,v retrieving revision 1.21 retrieving revision 1.21.16.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.21 -r1.21.16.1 --- sys/arch/i386/i386/math_emulate.c 1999/04/22 00:23:33 1.21 +++ sys/arch/i386/i386/math_emulate.c 2001/03/05 22:49:13 1.21.16.1 @@ -37,8 +37,9 @@ */ #include #include +#include #include #include #include #include @@ -84,13 +85,13 @@ if (!USERMODE(info->tf_cs, info->tf_eflags)) panic("math emulator called from supervisor mode"); /* ever used fp? */ - if ((curproc->p_md.md_flags & MDP_USEDFPU) == 0) { - cw = curproc->p_addr->u_pcb.pcb_savefpu.sv_env.en_cw; + if ((curproc->l_md.md_flags & MDP_USEDFPU) == 0) { + cw = curproc->l_addr->u_pcb.pcb_savefpu.sv_env.en_cw; fninit(); I387.cwd = cw; - curproc->p_md.md_flags |= MDP_USEDFPU; + curproc->l_md.md_flags |= MDP_USEDFPU; } if (I387.cwd & I387.swd & 0x3f) I387.swd |= 0x8000; @@ -575,9 +576,9 @@ static int __regoffset[] = { tEAX, tECX, tEDX, tEBX, tESP, tEBP, tESI, tEDI }; -#define REG(x) (((int *)curproc->p_md.md_regs)[__regoffset[(x)]]) +#define REG(x) (((int *)curproc->l_md.md_regs)[__regoffset[(x)]]) static char * sib(struct trapframe * info, int mod) { u_char ss,index,base; Index: sys/arch/i386/i386/mem.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/mem.c,v retrieving revision 1.47 retrieving revision 1.47.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.47 -r1.47.4.1 --- sys/arch/i386/i386/mem.c 2000/11/14 22:55:06 1.47 +++ sys/arch/i386/i386/mem.c 2001/03/05 22:49:13 1.47.4.1 @@ -50,8 +50,9 @@ #include #include #include #include +#include #include #include #include @@ -75,9 +76,9 @@ /* This is done by i386_iopl(3) now. */ case 14: if (flag & FWRITE) { struct trapframe *fp; - fp = curproc->p_md.md_regs; + fp = curproc->l_md.md_regs; fp->tf_eflags |= PSL_IOPL; } break; #endif @@ -197,9 +198,9 @@ dev_t dev; off_t off; int prot; { - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ /* * /dev/mem is the only one that makes sense through this * interface. For /dev/kmem any physaddr we return here Index: sys/arch/i386/i386/pmap.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/pmap.c,v retrieving revision 1.119 retrieving revision 1.118.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.119 -r1.118.2.2 --- sys/arch/i386/i386/pmap.c 2001/03/15 06:10:40 1.119 +++ sys/arch/i386/i386/pmap.c 2001/04/09 01:53:32 1.118.2.2 @@ -64,8 +64,9 @@ #include "opt_largepages.h" #include #include +#include #include #include #include #include @@ -766,10 +767,10 @@ TAILQ_INIT(&kpm->pm_obj.memq); kpm->pm_obj.uo_npages = 0; kpm->pm_obj.uo_refs = 1; memset(&kpm->pm_list, 0, sizeof(kpm->pm_list)); /* pm_list not used */ - kpm->pm_pdir = (pd_entry_t *)(proc0.p_addr->u_pcb.pcb_cr3 + KERNBASE); - kpm->pm_pdirpa = (u_int32_t) proc0.p_addr->u_pcb.pcb_cr3; + kpm->pm_pdir = (pd_entry_t *)(lwp0.l_addr->u_pcb.pcb_cr3 + KERNBASE); + kpm->pm_pdirpa = (u_int32_t) lwp0.l_addr->u_pcb.pcb_cr3; kpm->pm_stats.wired_count = kpm->pm_stats.resident_count = i386_btop(kva_start - VM_MIN_KERNEL_ADDRESS); /* @@ -1693,13 +1694,13 @@ * restore the default. */ void -pmap_ldt_cleanup(p) - struct proc *p; +pmap_ldt_cleanup(l) + struct lwp *l; { - struct pcb *pcb = &p->p_addr->u_pcb; - pmap_t pmap = p->p_vmspace->vm_map.pmap; + struct pcb *pcb = &l->l_addr->u_pcb; + pmap_t pmap = l->l_proc->p_vmspace->vm_map.pmap; union descriptor *old_ldt = NULL; size_t len = 0; simple_lock(&pmap->pm_obj.vmobjlock); @@ -1731,18 +1732,18 @@ * => if proc is the curproc, then load it into the MMU */ void -pmap_activate(p) - struct proc *p; +pmap_activate(l) + struct lwp *l; { - struct pcb *pcb = &p->p_addr->u_pcb; - struct pmap *pmap = p->p_vmspace->vm_map.pmap; + struct pcb *pcb = &l->l_addr->u_pcb; + struct pmap *pmap = l->l_proc->p_vmspace->vm_map.pmap; pcb->pcb_pmap = pmap; pcb->pcb_ldt_sel = pmap->pm_ldt_sel; pcb->pcb_cr3 = pmap->pm_pdirpa; - if (p == curproc) + if (l == curproc) lcr3(pcb->pcb_cr3); if (pcb == curpcb) lldt(pcb->pcb_ldt_sel); } @@ -1753,10 +1754,10 @@ * => XXX: what should this do, if anything? */ void -pmap_deactivate(p) - struct proc *p; +pmap_deactivate(l) + struct lwp *l; { } /* Index: sys/arch/i386/i386/process_machdep.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/process_machdep.c,v retrieving revision 1.32 retrieving revision 1.32.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.32 -r1.32.2.1 --- sys/arch/i386/i386/process_machdep.c 2000/12/11 17:36:03 1.32 +++ sys/arch/i386/i386/process_machdep.c 2001/03/05 22:49:14 1.32.2.1 @@ -64,8 +64,9 @@ #include #include #include #include +#include #include #include #include #include @@ -79,42 +80,38 @@ #ifdef VM86 #include #endif -static __inline struct trapframe *process_frame __P((struct proc *)); -static __inline struct save87 *process_fpframe __P((struct proc *)); +static __inline struct trapframe *process_frame (struct lwp *); +static __inline struct save87 *process_fpframe (struct lwp *); static __inline struct trapframe * -process_frame(p) - struct proc *p; +process_frame(struct lwp *l) { - return (p->p_md.md_regs); + return (l->l_md.md_regs); } static __inline struct save87 * -process_fpframe(p) - struct proc *p; +process_fpframe(struct lwp *l) { - return (&p->p_addr->u_pcb.pcb_savefpu); + return (&l->l_addr->u_pcb.pcb_savefpu); } int -process_read_regs(p, regs) - struct proc *p; - struct reg *regs; +process_read_regs(struct lwp *l, struct reg *regs) { - struct trapframe *tf = process_frame(p); - struct pcb *pcb = &p->p_addr->u_pcb; + struct trapframe *tf = process_frame(l); + struct pcb *pcb = &l->l_addr->u_pcb; #ifdef VM86 if (tf->tf_eflags & PSL_VM) { regs->r_gs = tf->tf_vm86_gs; regs->r_fs = tf->tf_vm86_fs; regs->r_es = tf->tf_vm86_es; regs->r_ds = tf->tf_vm86_ds; - regs->r_eflags = get_vflags(p); + regs->r_eflags = get_vflags(l); } else #endif { regs->r_gs = pcb->pcb_gs; @@ -138,19 +135,17 @@ return (0); } int -process_read_fpregs(p, regs) - struct proc *p; - struct fpreg *regs; +process_read_fpregs(struct lwp *l, struct fpreg *regs) { - struct save87 *frame = process_fpframe(p); + struct save87 *frame = process_fpframe(l); - if (p->p_md.md_flags & MDP_USEDFPU) { + if (l->l_md.md_flags & MDP_USEDFPU) { #if NNPX > 0 - extern struct proc *npxproc; + extern struct lwp *npxproc; - if (npxproc == p) + if (npxproc == l) npxsave(); #endif } else { u_short cw; @@ -164,23 +159,21 @@ memset(frame, 0, sizeof(*regs)); frame->sv_env.en_cw = cw; frame->sv_env.en_sw = 0x0000; frame->sv_env.en_tw = 0xffff; - p->p_md.md_flags |= MDP_USEDFPU; + l->l_md.md_flags |= MDP_USEDFPU; } memcpy(regs, frame, sizeof(*regs)); return (0); } int -process_write_regs(p, regs) - struct proc *p; - struct reg *regs; +process_write_regs(struct lwp *l, struct reg *regs) { - struct trapframe *tf = process_frame(p); - struct pcb *pcb = &p->p_addr->u_pcb; - pmap_t pmap = p->p_vmspace->vm_map.pmap; + struct trapframe *tf = process_frame(l); + struct pcb *pcb = &l->l_addr->u_pcb; + pmap_t pmap = l->l_proc->p_vmspace->vm_map.pmap; #ifdef VM86 if (regs->r_eflags & PSL_VM) { void syscall_vm86 __P((struct trapframe)); @@ -188,10 +181,10 @@ tf->tf_vm86_gs = regs->r_gs; tf->tf_vm86_fs = regs->r_fs; tf->tf_vm86_es = regs->r_es; tf->tf_vm86_ds = regs->r_ds; - set_vflags(p, regs->r_eflags); - p->p_md.md_syscall = syscall_vm86; + set_vflags(l, regs->r_eflags); + l->l_proc->p_md.md_syscall = syscall_vm86; } else #endif { #define verr_ldt(slot) (slot < pmap->pm_ldt_len && \ @@ -229,9 +222,9 @@ tf->tf_es = regs->r_es; tf->tf_ds = regs->r_ds; #ifdef VM86 if (tf->tf_eflags & PSL_VM) - (*p->p_emul->e_syscall_intern)(p); + (*l->l_proc->p_emul->e_syscall_intern)(l->l_proc); #endif tf->tf_eflags = regs->r_eflags; } tf->tf_edi = regs->r_edi; @@ -249,34 +242,31 @@ return (0); } int -process_write_fpregs(p, regs) - struct proc *p; - struct fpreg *regs; +process_write_fpregs(struct lwp *l, struct fpreg *regs) { - struct save87 *frame = process_fpframe(p); + struct save87 *frame = process_fpframe(l); - if (p->p_md.md_flags & MDP_USEDFPU) { + if (l->l_md.md_flags & MDP_USEDFPU) { #if NNPX > 0 - extern struct proc *npxproc; + extern struct lwp *npxproc; - if (npxproc == p) + if (npxproc == l) npxdrop(); #endif } else { - p->p_md.md_flags |= MDP_USEDFPU; + l->l_md.md_flags |= MDP_USEDFPU; } memcpy(frame, regs, sizeof(*regs)); return (0); } int -process_sstep(p, sstep) - struct proc *p; +process_sstep(struct lwp *l, int sstep) { - struct trapframe *tf = process_frame(p); + struct trapframe *tf = process_frame(l); if (sstep) tf->tf_eflags |= PSL_T; else @@ -285,13 +275,11 @@ return (0); } int -process_set_pc(p, addr) - struct proc *p; - caddr_t addr; +process_set_pc(struct lwp *l, caddr_t addr) { - struct trapframe *tf = process_frame(p); + struct trapframe *tf = process_frame(l); tf->tf_eip = (int)addr; return (0); Index: sys/arch/i386/i386/svr4_machdep.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/svr4_machdep.c,v retrieving revision 1.50 retrieving revision 1.50.4.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.50 -r1.50.4.2 --- sys/arch/i386/i386/svr4_machdep.c 2000/12/22 22:58:54 1.50 +++ sys/arch/i386/i386/svr4_machdep.c 2001/03/13 20:45:41 1.50.4.2 @@ -43,8 +43,9 @@ #include #include #include +#include #include #include #include #include @@ -114,37 +115,37 @@ } #endif void -svr4_setregs(p, epp, stack) - struct proc *p; +svr4_setregs(l, epp, stack) + struct lwp *l; struct exec_package *epp; u_long stack; { - register struct pcb *pcb = &p->p_addr->u_pcb; + register struct pcb *pcb = &l->l_addr->u_pcb; - setregs(p, epp, stack); + setregs(l, epp, stack); pcb->pcb_savefpu.sv_env.en_cw = __SVR4_NPXCW__; } void * -svr4_getmcontext(p, mc, flags) - struct proc *p; +svr4_getmcontext(l, mc, flags) + struct lwp *l; svr4_mcontext_t *mc; u_long *flags; { - register struct trapframe *tf = p->p_md.md_regs; + register struct trapframe *tf = l->l_md.md_regs; svr4_greg_t *r = mc->greg; /* Save register context. */ - tf = p->p_md.md_regs; + tf = l->l_md.md_regs; #ifdef VM86 if (tf->tf_eflags & PSL_VM) { r[SVR4_X86_GS] = tf->tf_vm86_gs; r[SVR4_X86_FS] = tf->tf_vm86_fs; r[SVR4_X86_ES] = tf->tf_vm86_es; r[SVR4_X86_DS] = tf->tf_vm86_ds; - r[SVR4_X86_EFL] = get_vflags(p); + r[SVR4_X86_EFL] = get_vflags(l); } else #endif { __asm("movl %%gs,%w0" : "=r" (r[SVR4_X86_GS])); @@ -186,15 +187,18 @@ * psl to gain improper privileges or to cause * a machine fault. */ int -svr4_setmcontext(p, mc, flags) - struct proc *p; +svr4_setmcontext(l, mc, flags) + struct lwp *l; svr4_mcontext_t *mc; u_long flags; { register struct trapframe *tf; svr4_greg_t *r = mc->greg; +#ifdef VM86 + struct proc *p = l->l_proc; +#endif #ifdef DEBUG_SVR4 svr4_printcontext("setmcontext", mc); #endif @@ -204,18 +208,18 @@ if ((flags & SVR4_UC_CPU) == 0) return 0; /* Restore register context. */ - tf = p->p_md.md_regs; + tf = l->l_md.md_regs; #ifdef VM86 if (r[SVR4_X86_EFL] & PSL_VM) { void syscall_vm86 __P((struct trapframe)); tf->tf_vm86_gs = r[SVR4_X86_GS]; tf->tf_vm86_fs = r[SVR4_X86_FS]; tf->tf_vm86_es = r[SVR4_X86_ES]; tf->tf_vm86_ds = r[SVR4_X86_DS]; - set_vflags(p, r[SVR4_X86_EFL]); + set_vflags(l, r[SVR4_X86_EFL]); p->p_md.md_syscall = syscall_vm86; } else #endif { @@ -365,14 +369,15 @@ int sig; sigset_t *mask; u_long code; { - register struct proc *p = curproc; + register struct lwp *l = curproc; + struct proc *p = l->l_proc; register struct trapframe *tf; struct svr4_sigframe *fp, frame; int onstack; - tf = p->p_md.md_regs; + tf = l->l_md.md_regs; /* Do we need to jump onto the signal stack? */ onstack = (p->p_sigctx.ps_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 && @@ -394,9 +399,9 @@ * to pass all sf_si and sf_uc] * - we don't pass the correct signal address [we need to * modify many kernel files to enable that] */ - svr4_getcontext(p, &frame.sf_uc, mask); + svr4_getcontext(l, &frame.sf_uc); svr4_getsiginfo(&frame.sf_si, sig, code, (caddr_t) tf->tf_eip); /* Build stack frame for signal trampoline. */ frame.sf_signum = frame.sf_si.si_signo; @@ -413,9 +418,9 @@ /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ - sigexit(p, SIGILL); + sigexit(l, SIGILL); /* NOTREACHED */ } /* @@ -437,14 +442,15 @@ /* * sysi86 */ int -svr4_sys_sysarch(p, v, retval) - struct proc *p; +svr4_sys_sysarch(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_sysarch_args *uap = v; + struct proc *p = l->l_proc; #ifdef USER_LDT caddr_t sg = stackgap_init(p->p_emul); int error; #endif @@ -515,9 +521,9 @@ printf("Cannot copyout desc\n"); return error; } - return sys_sysarch(p, &ua, retval); + return sys_sysarch(l, &ua, retval); } #endif default: @@ -534,14 +540,15 @@ svr4_fasttrap(frame) struct trapframe frame; { extern struct emul emul_svr4; - struct proc *p = curproc; + struct lwp *l = curproc; + struct proc *p = l->l_proc; - p->p_md.md_regs = &frame; + l->l_md.md_regs = &frame; if (p->p_emul != &emul_svr4) { - trapsignal(p, SIGBUS, 0); + trapsignal(l, SIGBUS, 0); return; } switch (frame.tf_eax) { Index: sys/arch/i386/i386/svr4_syscall.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/svr4_syscall.c,v retrieving revision 1.13 retrieving revision 1.13.6.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.13 -r1.13.6.1 --- sys/arch/i386/i386/svr4_syscall.c 2000/12/13 01:24:46 1.13 +++ sys/arch/i386/i386/svr4_syscall.c 2001/03/05 22:49:14 1.13.6.1 @@ -89,15 +89,15 @@ struct trapframe frame; { register caddr_t params; register const struct sysent *callp; - register struct proc *p; + struct lwp *l; int error; size_t argsize; register_t code, args[8], rval[2]; uvmexp.syscalls++; - p = curproc; + l = curproc; code = frame.tf_eax; callp = svr4_sysent; params = (caddr_t)frame.tf_esp + sizeof(int); @@ -123,14 +123,14 @@ goto bad; } #ifdef SYSCALL_DEBUG - scdebug_call(p, code, args); + scdebug_call(l, code, args); #endif /* SYSCALL_DEBUG */ rval[0] = 0; rval[1] = 0; - error = (*callp->sy_call)(p, args, rval); + error = (*callp->sy_call)(l, args, rval); switch (error) { case 0: frame.tf_eax = rval[0]; frame.tf_edx = rval[1]; @@ -155,11 +155,11 @@ break; } #ifdef SYSCALL_DEBUG - scdebug_ret(p, code, error, rval); + scdebug_ret(l, code, error, rval); #endif /* SYSCALL_DEBUG */ - userret(p); + userret(l); } /* * syscall(frame): @@ -171,15 +171,17 @@ struct trapframe frame; { register caddr_t params; register const struct sysent *callp; - register struct proc *p; + register struct lwp *l; + struct proc *p; int error; size_t argsize; register_t code, args[8], rval[2]; uvmexp.syscalls++; - p = curproc; + l = curproc; + p = l->l_proc; code = frame.tf_eax; callp = svr4_sysent; params = (caddr_t)frame.tf_esp + sizeof(int); @@ -205,18 +207,18 @@ goto bad; } #ifdef SYSCALL_DEBUG - scdebug_call(p, code, args); + scdebug_call(l, code, args); #endif /* SYSCALL_DEBUG */ #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) ktrsyscall(p, code, argsize, args); #endif /* KTRACE */ rval[0] = 0; rval[1] = 0; - error = (*callp->sy_call)(p, args, rval); + error = (*callp->sy_call)(l, args, rval); switch (error) { case 0: frame.tf_eax = rval[0]; frame.tf_edx = rval[1]; @@ -241,11 +243,11 @@ break; } #ifdef SYSCALL_DEBUG - scdebug_ret(p, code, error, rval); + scdebug_ret(l, code, error, rval); #endif /* SYSCALL_DEBUG */ - userret(p); + userret(l); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) ktrsysret(p, code, error, rval[0]); #endif /* KTRACE */ Index: sys/arch/i386/i386/sys_machdep.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/sys_machdep.c,v retrieving revision 1.56 retrieving revision 1.56.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.56 -r1.56.2.1 --- sys/arch/i386/i386/sys_machdep.c 2001/02/14 01:29:46 1.56 +++ sys/arch/i386/i386/sys_machdep.c 2001/03/05 22:49:14 1.56.2.1 @@ -44,8 +44,9 @@ #include #include #include #include +#include #include #include #include #include @@ -73,20 +74,21 @@ #endif extern vm_map_t kernel_map; -int i386_iopl __P((struct proc *, void *, register_t *)); -int i386_get_ioperm __P((struct proc *, void *, register_t *)); -int i386_set_ioperm __P((struct proc *, void *, register_t *)); +int i386_iopl __P((struct lwp *, void *, register_t *)); +int i386_get_ioperm __P((struct lwp *, void *, register_t *)); +int i386_set_ioperm __P((struct lwp *, void *, register_t *)); #ifdef USER_LDT int -i386_get_ldt(p, args, retval) - struct proc *p; +i386_get_ldt(l, args, retval) + struct lwp *l; void *args; register_t *retval; { int error; + struct proc *p = l->l_proc; pmap_t pmap = p->p_vmspace->vm_map.pmap; int nldt, num; union descriptor *lp; struct i386_get_ldt_args ua; @@ -128,15 +130,16 @@ return (0); } int -i386_set_ldt(p, args, retval) - struct proc *p; +i386_set_ldt(l, args, retval) + struct lwp *l; void *args; register_t *retval; { int error, i, n; - struct pcb *pcb = &p->p_addr->u_pcb; + struct proc *p = l->l_proc; + struct pcb *pcb = &l->l_addr->u_pcb; pmap_t pmap = p->p_vmspace->vm_map.pmap; int fsslot, gsslot; struct i386_set_ldt_args ua; union descriptor desc; @@ -287,15 +290,16 @@ } #endif /* USER_LDT */ int -i386_iopl(p, args, retval) - struct proc *p; +i386_iopl(l, args, retval) + struct lwp *l; void *args; register_t *retval; { int error; - struct trapframe *tf = p->p_md.md_regs; + struct proc *p = l->l_proc; + struct trapframe *tf = l->l_md.md_regs; struct i386_iopl_args ua; if (securelevel > 1) return EPERM; @@ -314,15 +318,15 @@ return 0; } int -i386_get_ioperm(p, args, retval) - struct proc *p; +i386_get_ioperm(l, args, retval) + struct lwp *l; void *args; register_t *retval; { int error; - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = &l->l_addr->u_pcb; struct i386_get_ioperm_args ua; if ((error = copyin(args, &ua, sizeof(ua))) != 0) return (error); @@ -330,15 +334,16 @@ return copyout(pcb->pcb_iomap, ua.iomap, sizeof(pcb->pcb_iomap)); } int -i386_set_ioperm(p, args, retval) - struct proc *p; +i386_set_ioperm(l, args, retval) + struct lwp *l; void *args; register_t *retval; { int error; - struct pcb *pcb = &p->p_addr->u_pcb; + struct proc *p = l->l_proc; + struct pcb *pcb = &l->l_addr->u_pcb; struct i386_set_ioperm_args ua; if (securelevel > 1) return EPERM; @@ -352,12 +357,9 @@ return copyin(ua.iomap, pcb->pcb_iomap, sizeof(pcb->pcb_iomap)); } int -sys_sysarch(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_sysarch(struct lwp *l, void *v, register_t *retval) { struct sys_sysarch_args /* { syscallarg(int) op; syscallarg(void *) parms; @@ -366,45 +368,46 @@ switch(SCARG(uap, op)) { #ifdef USER_LDT case I386_GET_LDT: - error = i386_get_ldt(p, SCARG(uap, parms), retval); + error = i386_get_ldt(l, SCARG(uap, parms), retval); break; case I386_SET_LDT: - error = i386_set_ldt(p, SCARG(uap, parms), retval); + error = i386_set_ldt(l, SCARG(uap, parms), retval); break; #endif case I386_IOPL: - error = i386_iopl(p, SCARG(uap, parms), retval); + error = i386_iopl(l, SCARG(uap, parms), retval); break; case I386_GET_IOPERM: - error = i386_get_ioperm(p, SCARG(uap, parms), retval); + error = i386_get_ioperm(l, SCARG(uap, parms), retval); break; case I386_SET_IOPERM: - error = i386_set_ioperm(p, SCARG(uap, parms), retval); + error = i386_set_ioperm(l, SCARG(uap, parms), retval); break; #ifdef VM86 case I386_VM86: - error = i386_vm86(p, SCARG(uap, parms), retval); + error = i386_vm86(l, SCARG(uap, parms), retval); break; #endif + #ifdef PERFCTRS case I386_PMC_INFO: - error = pmc_info(p, SCARG(uap, parms), retval); + error = pmc_info(l, SCARG(uap, parms), retval); break; case I386_PMC_STARTSTOP: - error = pmc_startstop(p, SCARG(uap, parms), retval); + error = pmc_startstop(l, SCARG(uap, parms), retval); break; case I386_PMC_READ: - error = pmc_read(p, SCARG(uap, parms), retval); + error = pmc_read(l, SCARG(uap, parms), retval); break; #endif default: Index: sys/arch/i386/i386/syscall.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/syscall.c,v retrieving revision 1.10 retrieving revision 1.10.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.10 -r1.10.4.1 --- sys/arch/i386/i386/syscall.c 2000/12/18 20:40:25 1.10 +++ sys/arch/i386/i386/syscall.c 2001/03/05 22:49:14 1.10.4.1 @@ -42,8 +42,9 @@ #include #include #include +#include #include #include #ifdef KTRACE #include @@ -86,15 +87,17 @@ struct trapframe frame; { register caddr_t params; register const struct sysent *callp; + register struct lwp *l; register struct proc *p; int error; size_t argsize; register_t code, args[8], rval[2]; uvmexp.syscalls++; - p = curproc; + l = curproc; + p = l->l_proc; code = frame.tf_eax; callp = p->p_emul->e_sysent; params = (caddr_t)frame.tf_esp + sizeof(int); @@ -133,9 +136,9 @@ #endif /* SYSCALL_DEBUG */ rval[0] = 0; rval[1] = 0; - error = (*callp->sy_call)(p, args, rval); + error = (*callp->sy_call)(l, args, rval); switch (error) { case 0: frame.tf_eax = rval[0]; frame.tf_edx = rval[1]; @@ -159,26 +162,28 @@ break; } #ifdef SYSCALL_DEBUG - scdebug_ret(p, code, error, rval); + scdebug_ret(l, code, error, rval); #endif /* SYSCALL_DEBUG */ - userret(p); + userret(l); } void syscall_fancy(frame) struct trapframe frame; { register caddr_t params; register const struct sysent *callp; + register struct lwp *l; register struct proc *p; int error; size_t argsize; register_t code, args[8], rval[2]; uvmexp.syscalls++; - p = curproc; + l = curproc; + p = l->l_proc; code = frame.tf_eax; callp = p->p_emul->e_sysent; params = (caddr_t)frame.tf_esp + sizeof(int); @@ -212,18 +217,18 @@ goto bad; } #ifdef SYSCALL_DEBUG - scdebug_call(p, code, args); + scdebug_call(l, code, args); #endif /* SYSCALL_DEBUG */ #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) ktrsyscall(p, code, argsize, args); #endif /* KTRACE */ rval[0] = 0; rval[1] = 0; - error = (*callp->sy_call)(p, args, rval); + error = (*callp->sy_call)(l, args, rval); switch (error) { case 0: frame.tf_eax = rval[0]; frame.tf_edx = rval[1]; @@ -247,11 +252,11 @@ break; } #ifdef SYSCALL_DEBUG - scdebug_ret(p, code, error, rval); + scdebug_ret(l, code, error, rval); #endif /* SYSCALL_DEBUG */ - userret(p); + userret(l); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) ktrsysret(p, code, error, rval[0]); #endif /* KTRACE */ @@ -261,27 +266,28 @@ void syscall_vm86(frame) struct trapframe frame; { - register struct proc *p; + register struct lwp *l; - p = curproc; - trapsignal(p, SIGBUS, T_PROTFLT); - userret(p); + l = curproc; + trapsignal(l, SIGBUS, T_PROTFLT); + userret(l); } #endif void child_return(arg) void *arg; { - struct proc *p = arg; - struct trapframe *tf = p->p_md.md_regs; + struct lwp *l = arg; + struct proc *p = l->l_proc; + struct trapframe *tf = l->l_md.md_regs; tf->tf_eax = 0; tf->tf_eflags &= ~PSL_C; - userret(p); + userret(l); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) ktrsysret(p, SYS_fork, 0, 0); #endif Index: sys/arch/i386/i386/trap.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/trap.c,v retrieving revision 1.156 retrieving revision 1.154.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.156 -r1.154.2.2 --- sys/arch/i386/i386/trap.c 2001/03/18 02:53:09 1.156 +++ sys/arch/i386/i386/trap.c 2001/04/09 01:53:34 1.154.2.2 @@ -84,15 +84,20 @@ #include "opt_cputype.h" #include #include +#include #include +#include #include #include #include #include #include +#include +#include +#include #include #include #include @@ -163,9 +168,10 @@ void trap(frame) struct trapframe frame; { - register struct proc *p = curproc; + struct lwp *l = curproc; + struct proc *p = l ? l->l_proc : 0; int type = frame.tf_trapno; struct pcb *pcb = NULL; extern char fusubail[], resume_iret[], resume_pop_ds[], resume_pop_es[], @@ -181,15 +187,17 @@ if (trapdebug) { printf("trap %d code %x eip %x cs %x eflags %x cr2 %x cpl %x\n", frame.tf_trapno, frame.tf_err, frame.tf_eip, frame.tf_cs, frame.tf_eflags, rcr2(), cpl); - printf("curproc %p\n", curproc); + printf("curproc %p%s", curproc, curproc ? " " : "\n"); + if (curproc) + printf("pid %d lid %d\n", l->l_proc->p_pid, l->l_lid); } #endif if (!KERNELMODE(frame.tf_cs, frame.tf_eflags)) { type |= T_USER; - p->p_md.md_regs = &frame; + l->l_md.md_regs = &frame; } switch (type) { @@ -228,9 +236,9 @@ case T_SEGNPFLT: case T_ALIGNFLT: case T_TSSFLT: /* Check for copyin/copyout fault. */ - pcb = &p->p_addr->u_pcb; + pcb = &l->l_addr->u_pcb; if (pcb->pcb_onfault != 0) { copyefault: error = EFAULT; copyfault: @@ -278,23 +286,23 @@ case T_PROTFLT|T_USER: /* protection fault */ #ifdef VM86 if (frame.tf_eflags & PSL_VM) { - vm86_gpfault(p, type & ~T_USER); + vm86_gpfault(l, type & ~T_USER); goto out; } #endif case T_TSSFLT|T_USER: case T_SEGNPFLT|T_USER: case T_STKFLT|T_USER: case T_ALIGNFLT|T_USER: case T_NMI|T_USER: - trapsignal(p, SIGBUS, type &~ T_USER); + trapsignal(l, SIGBUS, type &~ T_USER); goto out; case T_PRIVINFLT|T_USER: /* privileged instruction fault */ case T_FPOPFLT|T_USER: /* coprocessor operand fault */ - trapsignal(p, SIGILL, type &~ T_USER); + trapsignal(l, SIGILL, type &~ T_USER); goto out; case T_ASTFLT|T_USER: /* Allow process switch */ uvmexp.softs++; @@ -314,32 +322,32 @@ if (frame.tf_eflags & PSL_T) goto trace; return; } - trapsignal(p, rv, type &~ T_USER); + trapsignal(l, rv, type &~ T_USER); goto out; #else printf("pid %d killed due to lack of floating point\n", p->p_pid); - trapsignal(p, SIGKILL, type &~ T_USER); + trapsignal(l, SIGKILL, type &~ T_USER); goto out; #endif } case T_BOUND|T_USER: case T_OFLOW|T_USER: case T_DIVIDE|T_USER: - trapsignal(p, SIGFPE, type &~ T_USER); + trapsignal(l, SIGFPE, type &~ T_USER); goto out; case T_ARITHTRAP|T_USER: - trapsignal(p, SIGFPE, frame.tf_err); + trapsignal(l, SIGFPE, frame.tf_err); goto out; case T_PAGEFLT: /* allow page faults in kernel mode */ - if (p == 0) + if (l == 0) goto we_re_toast; - pcb = &p->p_addr->u_pcb; + pcb = &l->l_addr->u_pcb; /* * fusubail is used by [fs]uswintr() to prevent page faulting * from inside the profiling interrupt. */ @@ -406,12 +414,12 @@ } } /* Fault the original page in. */ - onfault = p->p_addr->u_pcb.pcb_onfault; - p->p_addr->u_pcb.pcb_onfault = NULL; + onfault = l->l_addr->u_pcb.pcb_onfault; + l->l_addr->u_pcb.pcb_onfault = NULL; error = uvm_fault(map, va, 0, ftype); - p->p_addr->u_pcb.pcb_onfault = onfault; + l->l_addr->u_pcb.pcb_onfault = onfault; if (error == 0) { if (nss > vm->vm_ssize) vm->vm_ssize = nss; @@ -434,11 +442,11 @@ printf("UVM: pid %d (%s), uid %d killed: out of swap\n", p->p_pid, p->p_comm, p->p_cred && p->p_ucred ? p->p_ucred->cr_uid : -1); - trapsignal(p, SIGKILL, T_PAGEFLT); + trapsignal(l, SIGKILL, T_PAGEFLT); } else { - trapsignal(p, SIGSEGV, T_PAGEFLT); + trapsignal(l, SIGSEGV, T_PAGEFLT); } break; } @@ -456,9 +464,9 @@ case T_TRCTRAP|T_USER: /* trace trap */ #ifdef MATH_EMULATE trace: #endif - trapsignal(p, SIGTRAP, type &~ T_USER); + trapsignal(l, SIGTRAP, type &~ T_USER); break; #if NISA > 0 || NMCA > 0 case T_NMI: @@ -494,9 +502,9 @@ if ((type & T_USER) == 0) return; out: - userret(p); + userret(l); } #if defined(I386_CPU) /* @@ -515,9 +523,9 @@ if (va >= VM_MAXUSER_ADDRESS) return 1; nss = 0; - p = curproc; + p = curproc->l_proc; vm = p->p_vmspace; if ((caddr_t)va >= vm->vm_maxsaddr) { nss = btoc(USRSTACK-(unsigned)va); if (nss > btoc(p->p_rlimit[RLIMIT_STACK].rlim_cur)) @@ -532,4 +540,42 @@ return 0; } #endif /* I386_CPU */ + +/* + * Start a new LWP + */ +void +startlwp(arg) + void *arg; +{ + int err; + ucontext_t *uc = arg; + struct lwp *l = curproc; + struct trapframe *tf; + + tf = l->l_md.md_regs; + + + err = cpu_setmcontext(l, &uc->uc_mcontext, uc->uc_flags); +#if DIAGNOSTIC + if (err) { + printf("Error %d from cpu_setmcontext.", err); + } +#endif + pool_put(&lwp_uc_pool, uc); + + userret(l); +} + +/* + * XXX This is a terrible name. + */ +void +upcallret(arg) + void *arg; +{ + struct lwp *l = curproc; + + userret(l); +} Index: sys/arch/i386/i386/vm86.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/vm86.c,v retrieving revision 1.23 retrieving revision 1.23.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.23 -r1.23.4.1 --- sys/arch/i386/i386/vm86.c 2000/12/22 22:58:54 1.23 +++ sys/arch/i386/i386/vm86.c 2001/03/05 22:49:15 1.23.4.1 @@ -60,9 +60,9 @@ #include #include -static void fast_intxx __P((struct proc *, int)); +static void fast_intxx __P((struct lwp *, int)); static __inline int is_bitset __P((int, caddr_t)); #define CS(tf) (*(u_short *)&tf->tf_cs) #define IP(tf) (*(u_short *)&tf->tf_eip) @@ -153,13 +153,13 @@ #define V86_AH(regs) (((u_char *)&((regs)->tf_eax))[1]) #define V86_AL(regs) (((u_char *)&((regs)->tf_eax))[0]) static void -fast_intxx(p, intrno) - struct proc *p; +fast_intxx(l, intrno) + struct lwp *l; int intrno; { - struct trapframe *tf = p->p_md.md_regs; + struct trapframe *tf = l->l_md.md_regs; /* * handle certain interrupts directly by pushing the interrupt * frame and resetting registers, but only if user said that's ok * (i.e. not revectored.) Otherwise bump to 32-bit user handler. @@ -173,9 +173,9 @@ * Note: u_vm86p points to user-space, we only compute offsets * and don't deref it. is_revectored() above does fubyte() to * get stuff from it */ - u_vm86p = (struct vm86_struct *)p->p_addr->u_pcb.vm86_userp; + u_vm86p = (struct vm86_struct *)l->l_addr->u_pcb.vm86_userp; /* * If user requested special handling, return to user space with * indication of which INT was requested. @@ -204,9 +204,9 @@ */ ss = SS(tf) << 4; sp = SP(tf); - putword(ss, sp, get_vflags_short(p)); + putword(ss, sp, get_vflags_short(l)); putword(ss, sp, CS(tf)); putword(ss, sp, IP(tf)); SP(tf) = sp; @@ -215,36 +215,36 @@ return; vector: - vm86_return(p, VM86_MAKEVAL(VM86_INTx, intrno)); + vm86_return(l, VM86_MAKEVAL(VM86_INTx, intrno)); return; bad: - vm86_return(p, VM86_UNKNOWN); + vm86_return(l, VM86_UNKNOWN); return; } void -vm86_return(p, retval) - struct proc *p; +vm86_return(l, retval) + struct lwp *l; int retval; { /* * We can't set the virtual flags in our real trap frame, * since it's used to jump to the signal handler. Instead we * let sendsig() pull in the vm86_eflags bits. */ - if (sigismember(&p->p_sigctx.ps_sigmask, SIGURG)) { + if (sigismember(&l->l_proc->p_sigctx.ps_sigmask, SIGURG)) { #ifdef DIAGNOSTIC printf("pid %d killed on VM86 protocol screwup (SIGURG blocked)\n", - p->p_pid); + l->l_proc->p_pid); #endif - sigexit(p, SIGILL); + sigexit(l, SIGILL); /* NOTREACHED */ } - trapsignal(p, SIGURG, retval); + trapsignal(l, SIGURG, retval); } #define CLI 0xFA #define STI 0xFB @@ -262,13 +262,13 @@ * to handle here are done here (much more efficient than trapping to 32-bit * handler code and then having it restart VM86 mode). */ void -vm86_gpfault(p, type) - struct proc *p; +vm86_gpfault(l, type) + struct lwp *l; int type; { - struct trapframe *tf = p->p_md.md_regs; + struct trapframe *tf = l->l_md.md_regs; /* * we want to fetch some stuff from the current user virtual * address space for checking. remember that the frame's * segment selectors are real-mode style selectors. @@ -292,58 +292,58 @@ IP(tf) = ip; switch (tmpbyte) { case CLI: /* simulate handling of IF */ - clr_vif(p); + clr_vif(l); break; case STI: /* simulate handling of IF. * XXX the i386 enables interrupts one instruction later. * code here is wrong, but much simpler than doing it Right. */ - set_vif(p); + set_vif(l); break; case INTxx: /* try fast intxx, or return to 32bit mode to handle it. */ tmpbyte = getbyte(cs, ip); IP(tf) = ip; - fast_intxx(p, tmpbyte); + fast_intxx(l, tmpbyte); break; case INTO: if (tf->tf_eflags & PSL_V) - fast_intxx(p, 4); + fast_intxx(l, 4); break; case PUSHF: - putword(ss, sp, get_vflags_short(p)); + putword(ss, sp, get_vflags_short(l)); SP(tf) = sp; break; case IRET: IP(tf) = getword(ss, sp); CS(tf) = getword(ss, sp); case POPF: - set_vflags_short(p, getword(ss, sp)); + set_vflags_short(l, getword(ss, sp)); SP(tf) = sp; break; case OPSIZ: tmpbyte = getbyte(cs, ip); IP(tf) = ip; switch (tmpbyte) { case PUSHF: - putdword(ss, sp, get_vflags(p) & ~PSL_VM); + putdword(ss, sp, get_vflags(l) & ~PSL_VM); SP(tf) = sp; break; case IRET: IP(tf) = getdword(ss, sp); CS(tf) = getdword(ss, sp); case POPF: - set_vflags(p, getdword(ss, sp) | PSL_VM); + set_vflags(l, getdword(ss, sp) | PSL_VM); SP(tf) = sp; break; default: @@ -358,24 +358,24 @@ goto bad; } if (trace && tf->tf_eflags & PSL_VM) - trapsignal(p, SIGTRAP, T_TRCTRAP); + trapsignal(l, SIGTRAP, T_TRCTRAP); return; bad: - vm86_return(p, VM86_UNKNOWN); + vm86_return(l, VM86_UNKNOWN); return; } int -i386_vm86(p, args, retval) - struct proc *p; +i386_vm86(l, args, retval) + struct lwp *l; char *args; register_t *retval; { - struct trapframe *tf = p->p_md.md_regs; - struct pcb *pcb = &p->p_addr->u_pcb; + struct trapframe *tf = l->l_md.md_regs; + struct pcb *pcb = &l->l_addr->u_pcb; struct vm86_kern vm86s; int error; error = copyin(args, &vm86s, sizeof(vm86s)); @@ -429,10 +429,10 @@ #undef DOVREG #undef DOREG /* Going into vm86 mode jumps off the signal stack. */ - p->p_sigctx.ps_sigstk.ss_flags &= ~SS_ONSTACK; + l->l_proc->p_sigctx.ps_sigstk.ss_flags &= ~SS_ONSTACK; - set_vflags(p, vm86s.regs.vmsc.sc_eflags | PSL_VM); + set_vflags(l, vm86s.regs.vmsc.sc_eflags | PSL_VM); return (EJUSTRETURN); } Index: sys/arch/i386/i386/vm_machdep.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/i386/vm_machdep.c,v retrieving revision 1.97 retrieving revision 1.97.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.97 -r1.97.2.1 --- sys/arch/i386/i386/vm_machdep.c 2001/01/25 20:14:28 1.97 +++ sys/arch/i386/i386/vm_machdep.c 2001/03/05 22:49:15 1.97.2.1 @@ -49,8 +49,9 @@ #include "opt_largepages.h" #include #include +#include #include #include #include #include @@ -67,88 +68,88 @@ #include #include "npx.h" #if NNPX > 0 -extern struct proc *npxproc; +extern struct lwp *npxproc; #endif void setredzone __P((u_short *, caddr_t)); /* - * Finish a fork operation, with process p2 nearly set up. + * Finish a new thread operation, with LWP l2 nearly set up. * Copy and update the pcb and trap frame, making the child ready to run. * * Rig the child's kernel stack so that it will start out in - * proc_trampoline() and call child_return() with p2 as an + * proc_trampoline() and call child_return() with l2 as an * argument. This causes the newly-created child process to go * directly to user level with an apparent return value of 0 from * fork(), while the parent process returns normally. * - * p1 is the process being forked; if p1 == &proc0, we are creating + * l1 is the thread being forked; if l1 == &lwp0, we are creating * a kernel thread, and the return path and argument are specified with * `func' and `arg'. * * If an alternate user-level stack is requested (with non-zero values * in both the stack and stacksize args), set up the user stack pointer * accordingly. */ void -cpu_fork(p1, p2, stack, stacksize, func, arg) - register struct proc *p1, *p2; +cpu_fork(l1, l2, stack, stacksize, func, arg) + struct lwp *l1, *l2; void *stack; size_t stacksize; void (*func) __P((void *)); void *arg; { - register struct pcb *pcb = &p2->p_addr->u_pcb; - register struct trapframe *tf; - register struct switchframe *sf; + struct pcb *pcb = &l2->l_addr->u_pcb; + struct trapframe *tf; + struct switchframe *sf; #if NNPX > 0 /* - * If npxproc != p1, then the npx h/w state is irrelevant and the + * If npxproc != l1, then the npx h/w state is irrelevant and the * state had better already be in the pcb. This is true for forks * but not for dumps. * - * If npxproc == p1, then we have to save the npx h/w state to + * If npxproc == l1, then we have to save the npx h/w state to * p1's pcb so that we can copy it. */ - if (npxproc == p1) + if (npxproc == l1) npxsave(); #endif - p2->p_md.md_flags = p1->p_md.md_flags; + l2->l_md.md_flags = l1->l_md.md_flags; /* Copy pcb from proc p1 to p2. */ - if (p1 == curproc) { + if (l1 == curproc) { /* Sync the PCB before we copy it. */ savectx(curpcb); } #ifdef DIAGNOSTIC - else if (p1 != &proc0) + else if (l1 != &lwp0) panic("cpu_fork: curproc"); #endif - *pcb = p1->p_addr->u_pcb; + *pcb = l1->l_addr->u_pcb; /* * Preset these so that gdt_compact() doesn't get confused if called * during the allocations below. * * Note: pcb_ldt_sel is handled in the pmap_activate() call when * we run the new process. */ - p2->p_md.md_tss_sel = GSEL(GNULL_SEL, SEL_KPL); + l2->l_md.md_tss_sel = GSEL(GNULL_SEL, SEL_KPL); /* Fix up the TSS. */ pcb->pcb_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL); - pcb->pcb_tss.tss_esp0 = (int)p2->p_addr + USPACE - 16; - tss_alloc(p2); + pcb->pcb_tss.tss_esp0 = (int)l2->l_addr + USPACE - 16; + tss_alloc(l2); /* * Copy the trapframe. */ - p2->p_md.md_regs = tf = (struct trapframe *)pcb->pcb_tss.tss_esp0 - 1; - *tf = *p1->p_md.md_regs; + l2->l_md.md_regs = tf = (struct trapframe *)pcb->pcb_tss.tss_esp0 - 1; + *tf = *l1->l_md.md_regs; /* * If specified, give the child a different stack. */ @@ -164,17 +165,35 @@ pcb->pcb_ebp = 0; } void -cpu_swapout(p) - struct proc *p; +cpu_setfunc(l, func, arg) + struct lwp *l; + void (*func) __P((void *)); + void *arg; { + struct pcb *pcb = &l->l_addr->u_pcb; + struct trapframe *tf = l->l_md.md_regs; + struct switchframe *sf = (struct switchframe *)tf - 1; + sf->sf_ppl = 0; + sf->sf_esi = (int)func; + sf->sf_ebx = (int)arg; + sf->sf_eip = (int)proc_trampoline; + pcb->pcb_esp = (int)sf; + pcb->pcb_ebp = 0; +} + +void +cpu_swapout(l) + struct lwp *l; +{ + #if NNPX > 0 /* * Make sure we save the FP state before the user area vanishes. */ - if (npxproc == p) + if (npxproc == l) npxsave(); #endif } @@ -183,17 +202,20 @@ * * We clean up a little and then call switch_exit() with the old proc as an * argument. switch_exit() first switches to proc0's context, and finally * jumps into switch() to wait for another process to wake up. + * + * If proc==0, we're an exiting lwp, and call switch_lwp_exit() instead of + * switch_exit(), and only do LWP-appropriate cleanup (e.g. don't deactivate + * the pmap). */ void -cpu_exit(p) - register struct proc *p; +cpu_exit(struct lwp *l, int proc) { #if NNPX > 0 /* If we were using the FPU, forget about it. */ - if (npxproc == p) + if (npxproc == l) npxproc = 0; #endif /* @@ -201,23 +223,29 @@ * pmap_destroy(). */ uvmexp.swtch++; - switch_exit(p); + + if (proc) + switch_exit(l); + else + switch_lwp_exit(l); } + + /* * cpu_wait is called from reaper() to let machine-dependent * code free machine-dependent resources that couldn't be freed * in cpu_exit(). */ void -cpu_wait(p) - struct proc *p; +cpu_wait(l) + struct lwp *l; { /* Nuke the TSS. */ - tss_free(p); + tss_free(l); } /* * Dump the machine specific segment at the start of a core dump. @@ -226,14 +254,15 @@ struct reg intreg; struct fpreg freg; }; int -cpu_coredump(p, vp, cred, chdr) - struct proc *p; +cpu_coredump(l, vp, cred, chdr) + struct lwp *l; struct vnode *vp; struct ucred *cred; struct core *chdr; { + struct proc *p = l->l_proc; struct md_core md_core; struct coreseg cseg; int error; @@ -242,14 +271,14 @@ chdr->c_seghdrsize = ALIGN(sizeof(cseg)); chdr->c_cpusize = sizeof(md_core); /* Save integer registers. */ - error = process_read_regs(p, &md_core.intreg); + error = process_read_regs(l, &md_core.intreg); if (error) return error; /* Save floating point registers. */ - error = process_read_fpregs(p, &md_core.freg); + error = process_read_fpregs(l, &md_core.freg); if (error) return error; CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_MACHINE, CORE_CPU); Index: sys/arch/i386/include/Makefile =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/include/Makefile,v retrieving revision 1.14 retrieving revision 1.14.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.14 -r1.14.4.1 --- sys/arch/i386/include/Makefile 2000/11/05 22:28:00 1.14 +++ sys/arch/i386/include/Makefile 2001/03/05 22:49:16 1.14.4.1 @@ -7,11 +7,11 @@ byte_swap.h bus.h cdefs.h conf.h cpu.h cpufunc.h cputypes.h \ db_machdep.h disklabel.h elf_machdep.h endian.h endian_machdep.h \ float.h frame.h freebsd_machdep.h gdt.h ibcs2_machdep.h ieee.h \ ieeefp.h int_types.h intr.h joystick.h kcore.h limits.h lock.h math.h \ - mouse.h npx.h param.h pcb.h pccons.h pio.h pmap.h \ + mcontext.h mouse.h npx.h param.h pcb.h pccons.h pio.h pmap.h \ pmc.h proc.h profile.h psl.h pte.h ptrace.h reg.h segments.h \ setjmp.h signal.h specialreg.h spkr.h stdarg.h \ - svr4_machdep.h sysarch.h trap.h tss.h types.h varargs.h vm86.h \ - vmparam.h + svr4_machdep.h sysarch.h trap.h tss.h types.h varargs.h \ + vm86.h vmparam.h .include Index: sys/arch/i386/include/cpu.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/include/cpu.h,v retrieving revision 1.68 retrieving revision 1.68.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.68 -r1.68.2.1 --- sys/arch/i386/include/cpu.h 2001/02/14 01:29:45 1.68 +++ sys/arch/i386/include/cpu.h 2001/03/05 22:49:16 1.68.2.1 @@ -92,9 +92,9 @@ /* * This is used during profiling to integrate system time. It can safely * assume that the process is resident. */ -#define PROC_PC(p) ((p)->p_md.md_regs->tf_eip) +#define LWP_PC(l) ((l)->l_md.md_regs->tf_eip) /* * Preempt the current process if in interrupt from user mode, * or after the current trap/syscall if in system mode. @@ -170,9 +170,10 @@ void fillw __P((short, void *, size_t)); struct pcb; void savectx __P((struct pcb *)); -void switch_exit __P((struct proc *)); +void switch_exit __P((struct lwp *)); +void switch_lwp_exit __P((struct lwp *)); void proc_trampoline __P((void)); /* clock.c */ void initrtclock __P((void)); @@ -197,10 +198,10 @@ #include "opt_user_ldt.h" #endif #ifdef USER_LDT /* sys_machdep.h */ -int i386_get_ldt __P((struct proc *, void *, register_t *)); -int i386_set_ldt __P((struct proc *, void *, register_t *)); +int i386_get_ldt __P((struct lwp *, void *, register_t *)); +int i386_set_ldt __P((struct lwp *, void *, register_t *)); #endif /* isa_machdep.c */ void isa_defaultirq __P((void)); @@ -210,9 +211,9 @@ #include "opt_vm86.h" #endif #ifdef VM86 /* vm86.c */ -void vm86_gpfault __P((struct proc *, int)); +void vm86_gpfault __P((struct lwp *, int)); #endif /* VM86 */ /* trap.c */ void child_return __P((void *)); Index: sys/arch/i386/include/frame.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/include/frame.h,v retrieving revision 1.15 retrieving revision 1.15.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.15 -r1.15.2.1 --- sys/arch/i386/include/frame.h 2001/02/08 17:54:43 1.15 +++ sys/arch/i386/include/frame.h 2001/03/05 22:49:16 1.15.2.1 @@ -77,8 +77,9 @@ #ifndef _I386_FRAME_H_ #define _I386_FRAME_H_ #include +#include /* * System stack frames. */ @@ -156,7 +157,18 @@ int sf_code; struct sigcontext *sf_scp; sig_t sf_handler; struct sigcontext sf_sc; +}; + +/* + * Scheduler activations upcall frame + */ +struct saframe { + int sa_type; + struct sa_t **sa_sas; + int sa_events; + int sa_interrupted; + sa_upcall_t sa_upcall; }; #endif /* _I386_FRAME_H_ */ Index: sys/arch/i386/include/gdt.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/include/gdt.h,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.8 -r1.8.2.1 --- sys/arch/i386/include/gdt.h 2000/08/16 04:44:37 1.8 +++ sys/arch/i386/include/gdt.h 2001/03/05 22:49:16 1.8.2.1 @@ -39,8 +39,8 @@ struct proc; struct pmap; void gdt_init __P((void)); -void tss_alloc __P((struct proc *)); -void tss_free __P((struct proc *)); +void tss_alloc __P((struct lwp *)); +void tss_free __P((struct lwp *)); void ldt_alloc __P((struct pmap *, union descriptor *, size_t)); void ldt_free __P((struct pmap *)); Index: sys/arch/i386/include/ibcs2_machdep.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/include/ibcs2_machdep.h,v retrieving revision 1.10 retrieving revision 1.10.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.10 -r1.10.4.1 --- sys/arch/i386/include/ibcs2_machdep.h 2000/12/11 05:29:00 1.10 +++ sys/arch/i386/include/ibcs2_machdep.h 2001/03/05 22:49:16 1.10.4.1 @@ -46,11 +46,11 @@ #ifdef _KERNEL struct exec_package; struct exec_vmcmd; -void ibcs2_setregs __P((struct proc *, struct exec_package *, u_long)); +void ibcs2_setregs __P((struct lwp *, struct exec_package *, u_long)); void ibcs2_sendsig __P((sig_t, int, sigset_t *, u_long)); -int ibcs2_sys_sysmachine __P((struct proc *, void *, register_t *retval)); +int ibcs2_sys_sysmachine __P((struct lwp *, void *, register_t *retval)); void ibcs2_syscall_intern __P((struct proc *)); #endif /* _KERNEL */ Index: sys/arch/i386/include/mcontext.h =================================================================== RCS file: mcontext.h diff -N mcontext.h --- /dev/null Tue Apr 24 13:41:34 2001 +++ /tmp/cvsBZQGBqVl3d Tue Apr 24 17:06:41 2001 @@ -0,0 +1,99 @@ +/* $NetBSD: mcontext.h,v 1.1.2.1 2001/03/05 22:49:16 nathanw Exp $ */ + +/*- + * Copyright (c) 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus Klein. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _I386_MCONTEXT_H_ +#define _I386_MCONTEXT_H_ + +/* + * Layout of mcontext_t according to the System V Application Binary Interface, + * Intel386(tm) Architecture Processor Supplement, Fourth Edition. + */ + +/* + * General register state + */ +#define _NGREG 19 +typedef int __greg_t; +typedef __greg_t __gregset_t[_NGREG]; + +#define _REG_GS 0 +#define _REG_FS 1 +#define _REG_ES 2 +#define _REG_DS 3 +#define _REG_EDI 4 +#define _REG_ESI 5 +#define _REG_EBP 6 +#define _REG_ESP 7 +#define _REG_EBX 8 +#define _REG_EDX 9 +#define _REG_ECX 10 +#define _REG_EAX 11 +#define _REG_TRAPNO 12 +#define _REG_ERR 13 +#define _REG_EIP 14 +#define _REG_CS 15 +#define _REG_EFL 16 +#define _REG_UESP 17 +#define _REG_SS 18 + +/* + * Floating point register state + */ +typedef struct { + union { + struct { + int __fp_state[27]; /* Environment and registers */ + int __fp_status; /* Software status word */ + } __fpchip_state; + struct { + char __fp_emul[246]; + char __fp_epad[2]; + } __fp_emul_space; + int __fp_fpregs[62]; + } __fp_reg_set; + long __fp_wregs[33]; /* Weitek? */ +} __fpregset_t; + +typedef struct { + __gregset_t __gregs; + __fpregset_t __fpregs; +} mcontext_t; + +#define _UC_MACHINE_PAD 5 /* Padding appended to ucontext_t */ + +#endif /* !_I386_MCONTEXT_H_ */ Index: sys/arch/i386/include/pmap.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/include/pmap.h,v retrieving revision 1.53 retrieving revision 1.53.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.53 -r1.53.2.1 --- sys/arch/i386/include/pmap.h 2001/01/04 00:17:43 1.53 +++ sys/arch/i386/include/pmap.h 2001/03/05 22:49:16 1.53.2.1 @@ -355,12 +355,12 @@ /* * prototypes */ -void pmap_activate __P((struct proc *)); +void pmap_activate __P((struct lwp *)); void pmap_bootstrap __P((vaddr_t)); boolean_t pmap_change_attrs __P((struct vm_page *, int, int)); -void pmap_deactivate __P((struct proc *)); +void pmap_deactivate __P((struct lwp *)); static void pmap_page_protect __P((struct vm_page *, vm_prot_t)); void pmap_page_remove __P((struct vm_page *)); static void pmap_protect __P((struct pmap *, vaddr_t, vaddr_t, vm_prot_t)); @@ -509,9 +509,9 @@ paddr_t vtophys __P((vaddr_t)); vaddr_t pmap_map __P((vaddr_t, paddr_t, paddr_t, vm_prot_t)); #if defined(USER_LDT) -void pmap_ldt_cleanup __P((struct proc *)); +void pmap_ldt_cleanup __P((struct lwp *)); #define PMAP_FORK #endif /* USER_LDT */ #endif /* _KERNEL */ Index: sys/arch/i386/include/proc.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/include/proc.h,v retrieving revision 1.13 retrieving revision 1.13.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.13 -r1.13.4.1 --- sys/arch/i386/include/proc.h 2000/12/11 10:22:55 1.13 +++ sys/arch/i386/include/proc.h 2001/03/05 22:49:16 1.13.4.1 @@ -34,19 +34,29 @@ * * @(#)proc.h 7.1 (Berkeley) 5/15/91 */ +#ifndef _I386_PROC_H_ +#define _I386_PROC_H_ + #include /* * Machine-dependent part of the proc structure for i386. */ -struct mdproc { +struct mdlwp { struct trapframe *md_regs; /* registers on current frame */ int md_flags; /* machine-dependent flags */ int md_tss_sel; /* TSS selector */ - /* Syscall handling function */ - void (*md_syscall) __P((struct trapframe)); }; /* md_flags */ #define MDP_USEDFPU 0x0001 /* has used the FPU */ + +struct mdproc { + /* Syscall handling function */ + void (*md_syscall) __P((struct trapframe)); +}; + +#endif /* _I386_PROC_H_ */ + + Index: sys/arch/i386/include/psl.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/include/psl.h,v retrieving revision 1.32 retrieving revision 1.32.28.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.32 -r1.32.28.1 --- sys/arch/i386/include/psl.h 1998/01/15 22:26:03 1.32 +++ sys/arch/i386/include/psl.h 2001/03/05 22:49:17 1.32.28.1 @@ -73,8 +73,9 @@ #define PSL_USERSTATIC (PSL_MBO | PSL_MBZ | PSL_I | PSL_IOPL | PSL_NT | PSL_VIF | PSL_VIP) #else #define PSL_USERSTATIC (PSL_MBO | PSL_MBZ | PSL_I | PSL_IOPL | PSL_NT | PSL_VM | PSL_VIF | PSL_VIP) #endif +#define PSL_USER (PSL_C | PSL_MBO | PSL_PF | PSL_AF | PSL_Z | PSL_N | PSL_V) #ifdef _KERNEL #include #endif Index: sys/arch/i386/include/userret.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/include/userret.h,v retrieving revision 1.2 retrieving revision 1.2.6.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.2 -r1.2.6.1 --- sys/arch/i386/include/userret.h 2000/12/10 19:29:31 1.2 +++ sys/arch/i386/include/userret.h 2001/03/05 22:49:17 1.2.6.1 @@ -72,22 +72,28 @@ * SUCH DAMAGE. * */ -static __inline void userret __P((register struct proc *)); +static __inline void userret __P((register struct lwp *)); /* * Define the code needed before returning to user mode, for * trap and syscall. */ static __inline void -userret(p) - register struct proc *p; +userret(l) + register struct lwp *l; { int sig; + struct proc *p = l->l_proc; + + /* If our process is on the way out, die. */ + if (p->p_flag & P_WEXIT) + lwp_exit(l); + /* Take pending signals. */ - while ((sig = CURSIG(p)) != 0) + while ((sig = CURSIG(l)) != 0) postsig(sig); - curcpu()->ci_schedstate.spc_curpriority = p->p_priority = p->p_usrpri; + curcpu()->ci_schedstate.spc_curpriority = l->l_priority = l->l_usrpri; } Index: sys/arch/i386/include/vm86.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/include/vm86.h,v retrieving revision 1.9 retrieving revision 1.9.30.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.9 -r1.9.30.1 --- sys/arch/i386/include/vm86.h 1997/10/09 08:50:43 1.9 +++ sys/arch/i386/include/vm86.h 2001/03/05 22:49:17 1.9.30.1 @@ -79,23 +79,23 @@ #define VCPU_486 4 #define VCPU_586 5 #ifdef _KERNEL -int i386_vm86 __P((struct proc *, char *, register_t *)); -void vm86_gpfault __P((struct proc *, int)); -void vm86_return __P((struct proc *, int)); -static __inline void clr_vif __P((struct proc *)); -static __inline void set_vif __P((struct proc *)); -static __inline void set_vflags __P((struct proc *, int)); -static __inline int get_vflags __P((struct proc *)); -static __inline void set_vflags_short __P((struct proc *, int)); -static __inline int get_vflags_short __P((struct proc *)); +int i386_vm86 __P((struct lwp *, char *, register_t *)); +void vm86_gpfault __P((struct lwp *, int)); +void vm86_return __P((struct lwp *, int)); +static __inline void clr_vif __P((struct lwp *)); +static __inline void set_vif __P((struct lwp *)); +static __inline void set_vflags __P((struct lwp *, int)); +static __inline int get_vflags __P((struct lwp *)); +static __inline void set_vflags_short __P((struct lwp *, int)); +static __inline int get_vflags_short __P((struct lwp *)); static __inline void -clr_vif(p) - struct proc *p; +clr_vif(l) + struct lwp *l; { - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = &l->l_addr->u_pcb; #ifndef VM86_USE_VIF pcb->vm86_eflags &= ~PSL_I; #else @@ -103,30 +103,30 @@ #endif } static __inline void -set_vif(p) - struct proc *p; +set_vif(l) + struct lwp *l; { - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = &l->l_addr->u_pcb; #ifndef VM86_USE_VIF pcb->vm86_eflags |= PSL_I; if ((pcb->vm86_eflags & (PSL_I|PSL_VIP)) == (PSL_I|PSL_VIP)) #else pcb->vm86_eflags |= PSL_VIF; if ((pcb->vm86_eflags & (PSL_VIF|PSL_VIP)) == (PSL_VIF|PSL_VIP)) #endif - vm86_return(p, VM86_STI); + vm86_return(l, VM86_STI); } static __inline void -set_vflags(p, flags) - struct proc *p; +set_vflags(l, flags) + struct lwp *l; int flags; { - struct trapframe *tf = p->p_md.md_regs; - struct pcb *pcb = &p->p_addr->u_pcb; + struct trapframe *tf = l->l_md.md_regs; + struct pcb *pcb = &l->l_addr->u_pcb; flags &= ~pcb->vm86_flagmask; SETFLAGS(pcb->vm86_eflags, flags, VM86_VIRTFLAGS); SETFLAGS(tf->tf_eflags, flags, VM86_REALFLAGS); @@ -134,47 +134,47 @@ if ((pcb->vm86_eflags & (PSL_I|PSL_VIP)) == (PSL_I|PSL_VIP)) #else if ((pcb->vm86_eflags & (PSL_VIF|PSL_VIP)) == (PSL_VIF|PSL_VIP)) #endif - vm86_return(p, VM86_STI); + vm86_return(l, VM86_STI); } static __inline int -get_vflags(p) - struct proc *p; +get_vflags(l) + struct lwp *l; { - struct trapframe *tf = p->p_md.md_regs; - struct pcb *pcb = &p->p_addr->u_pcb; + struct trapframe *tf = l->l_md.md_regs; + struct pcb *pcb = &l->l_addr->u_pcb; int flags = PSL_MBO; SETFLAGS(flags, pcb->vm86_eflags, VM86_VIRTFLAGS); SETFLAGS(flags, tf->tf_eflags, VM86_REALFLAGS); return (flags); } static __inline void -set_vflags_short(p, flags) - struct proc *p; +set_vflags_short(l, flags) + struct lwp *l; int flags; { - struct trapframe *tf = p->p_md.md_regs; - struct pcb *pcb = &p->p_addr->u_pcb; + struct trapframe *tf = l->l_md.md_regs; + struct pcb *pcb = &l->l_addr->u_pcb; flags &= ~pcb->vm86_flagmask; SETFLAGS(pcb->vm86_eflags, flags, VM86_VIRTFLAGS & 0xffff); SETFLAGS(tf->tf_eflags, flags, VM86_REALFLAGS & 0xffff); #ifndef VM86_USE_VIF if ((pcb->vm86_eflags & (PSL_I|PSL_VIP)) == (PSL_I|PSL_VIP)) - vm86_return(p, VM86_STI); + vm86_return(l, VM86_STI); #endif } static __inline int -get_vflags_short(p) - struct proc *p; +get_vflags_short(l) + struct lwp *l; { - struct trapframe *tf = p->p_md.md_regs; - struct pcb *pcb = &p->p_addr->u_pcb; + struct trapframe *tf = l->l_md.md_regs; + struct pcb *pcb = &l->l_addr->u_pcb; int flags = PSL_MBO; SETFLAGS(flags, pcb->vm86_eflags, VM86_VIRTFLAGS & 0xffff); SETFLAGS(flags, tf->tf_eflags, VM86_REALFLAGS & 0xffff); Index: sys/arch/i386/isa/npx.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/arch/i386/isa/npx.c,v retrieving revision 1.74 retrieving revision 1.74.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.74 -r1.74.2.1 --- sys/arch/i386/isa/npx.c 2001/01/17 00:03:02 1.74 +++ sys/arch/i386/isa/npx.c 2001/03/05 22:49:17 1.74.2.1 @@ -46,8 +46,9 @@ #include #include #include #include +#include #include #include #include #include @@ -105,13 +106,13 @@ __asm("pushl %0; popfl" : : "r" (ef));}) #define clts() __asm("clts") #define stts() lcr0(rcr0() | CR0_TS) -int npxdna(struct proc *); +int npxdna(struct lwp *); void npxexit(void); static void npxsave1(void); -struct proc *npxproc; +struct lwp *npxproc; static enum npx_type npx_type; static int npx_nointr; volatile u_int npx_intrs_while_probing; @@ -259,10 +260,10 @@ */ int npxintr(void *arg) { - register struct proc *p = npxproc; - register struct save87 *addr; + struct lwp *l = npxproc; + struct save87 *addr; struct intrframe *frame = arg; struct npx_softc *sc; int code; @@ -270,11 +271,11 @@ uvmexp.traps++; IPRINTF(("Intr")); - if (p == 0 || npx_type == NPX_NONE) { + if (l == 0 || npx_type == NPX_NONE) { printf("npxintr: p = %p, curproc = %p, npx_type = %d\n", - p, curproc, npx_type); + l, curproc, npx_type); panic("npxintr: came from nowhere"); } /* @@ -293,17 +294,17 @@ /* * At this point, npxproc should be curproc. If it wasn't, the TS bit * should be set, and we should have gotten a DNA exception. */ - if (p != curproc) + if (l != curproc) panic("npxintr: wrong process"); #endif /* * Find the address of npxproc's saved FPU state. (Given the invariant * above, this is always the one in curpcb.) */ - addr = &p->p_addr->u_pcb.pcb_savefpu; + addr = &l->l_addr->u_pcb.pcb_savefpu; /* * Save state. This does an implied fninit. It had better not halt * the cpu or we'll hang. */ @@ -339,9 +340,9 @@ * (this is otherwise only necessary for the rescheduling trap * in doreti, and the frame for that could easily be set up * just before it is used). */ - p->p_md.md_regs = (struct trapframe *)&frame->if_es; + l->l_md.md_regs = (struct trapframe *)&frame->if_es; #ifdef notyet /* * Encode the appropriate code for detailed information on * this exception. @@ -349,9 +350,9 @@ code = XXX_ENCODE(addr->sv_ex_sw); #else code = 0; /* XXX */ #endif - trapsignal(p, SIGFPE, code); + trapsignal(l, SIGFPE, code); } else { /* * This is a nested interrupt. This should only happen when * an IRQ13 occurs at the same time as a higher-priority @@ -360,9 +361,9 @@ * XXX * Currently, we treat this like an asynchronous interrupt, but * this has disadvantages. */ - psignal(p, SIGFPE); + psignal(l->l_proc, SIGFPE); } return (1); } @@ -380,12 +381,12 @@ */ static inline void npxsave1(void) { - struct proc *p = npxproc; + struct lwp *l = npxproc; - fnsave(&p->p_addr->u_pcb.pcb_savefpu); - p->p_addr->u_pcb.pcb_cr0 |= CR0_TS; + fnsave(&l->l_addr->u_pcb.pcb_savefpu); + l->l_addr->u_pcb.pcb_cr0 |= CR0_TS; fwait(); } /* @@ -395,9 +396,9 @@ * Otherwise, we save the previous state, if necessary, and restore our last * saved state. */ int -npxdna(struct proc *p) +npxdna(struct lwp *l) { if (npx_type == NPX_NONE) { IPRINTF(("Emul")); @@ -408,31 +409,31 @@ if (cpl != 0 || npx_nointr != 0) panic("npxdna: masked"); #endif - p->p_addr->u_pcb.pcb_cr0 &= ~CR0_TS; + l->l_addr->u_pcb.pcb_cr0 &= ~CR0_TS; clts(); /* * Initialize the FPU state to clear any exceptions. If someone else * was using the FPU, save their state (which does an implicit * initialization). */ npx_nointr = 1; - if (npxproc != 0 && npxproc != p) { + if (npxproc != 0 && npxproc != l) { IPRINTF(("Save")); npxsave1(); } else { IPRINTF(("Init")); fninit(); fwait(); } npx_nointr = 0; - npxproc = p; + npxproc = l; - if ((p->p_md.md_flags & MDP_USEDFPU) == 0) { - fldcw(&p->p_addr->u_pcb.pcb_savefpu.sv_env.en_cw); - p->p_md.md_flags |= MDP_USEDFPU; + if ((l->l_md.md_flags & MDP_USEDFPU) == 0) { + fldcw(&l->l_addr->u_pcb.pcb_savefpu.sv_env.en_cw); + l->l_md.md_flags |= MDP_USEDFPU; } else { /* * The following frstor may cause an IRQ13 when the state being * restored has a pending error. The error will appear to have @@ -445,9 +446,9 @@ * while frstor and fnsave are broken, so our treatment breaks * fnclex if it is the first FPU instruction after a context * switch. */ - frstor(&p->p_addr->u_pcb.pcb_savefpu); + frstor(&l->l_addr->u_pcb.pcb_savefpu); } return (1); } @@ -457,13 +458,13 @@ */ void npxdrop(void) { - struct proc *p = npxproc; + struct lwp *l = npxproc; npxproc = 0; stts(); - p->p_addr->u_pcb.pcb_cr0 |= CR0_TS; + l->l_addr->u_pcb.pcb_cr0 |= CR0_TS; } /* * Save npxproc's FPU state. Index: sys/coda/coda_psdev.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/coda/coda_psdev.c,v retrieving revision 1.15 retrieving revision 1.15.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.15 -r1.15.2.1 --- sys/coda/coda_psdev.c 2000/12/27 22:06:07 1.15 +++ sys/coda/coda_psdev.c 2001/03/05 22:49:17 1.15.2.1 @@ -490,9 +490,9 @@ struct vcomm *vcp; struct vmsg *vmp; int error; #ifdef CTL_C - struct proc *p = curproc; + struct proc *p = curproc->l_proc; sigset_t psig_omask; int i; psig_omask = p->p_sigctx.ps_siglist; /* array assignment */ #endif Index: sys/coda/coda_vfsops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/coda/coda_vfsops.c,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.11 -r1.11.2.1 --- sys/coda/coda_vfsops.c 2001/01/22 12:17:35 1.11 +++ sys/coda/coda_vfsops.c 2001/03/05 22:49:17 1.11.2.1 @@ -334,9 +334,9 @@ { struct coda_mntinfo *mi = vftomi(vfsp); struct vnode **result; int error; - struct proc *p = curproc; /* XXX - bnoble */ + struct proc *p = curproc->l_proc; /* XXX - bnoble */ ViceFid VFid; ENTRY; MARK_ENTRY(CODA_ROOT_STATS); @@ -491,9 +491,9 @@ { struct cfid *cfid = (struct cfid *)fhp; struct cnode *cp = 0; int error; - struct proc *p = curproc; /* XXX -mach */ + struct proc *p = curproc->l_proc; /* XXX -mach */ ViceFid VFid; int vtype; ENTRY; Index: sys/coda/coda_vnops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/coda/coda_vnops.c,v retrieving revision 1.23 retrieving revision 1.23.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.23 -r1.23.2.1 --- sys/coda/coda_vnops.c 2001/01/22 12:17:35 1.23 +++ sys/coda/coda_vnops.c 2001/03/05 22:49:18 1.23.2.1 @@ -837,9 +837,9 @@ struct vop_inactive_args *ap = v; struct vnode *vp = ap->a_vp; struct cnode *cp = VTOC(vp); struct ucred *cred __attribute__((unused)) = NULL; - struct proc *p __attribute__((unused)) = curproc; + struct proc *p __attribute__((unused)) = curproc->l_proc; /* upcall decl */ /* locals */ /* We don't need to send inactive to venus - DCS */ @@ -1758,9 +1758,9 @@ struct vnode *vp __attribute__((unused)) = ap->a_vp; /* file's vnode */ daddr_t bn __attribute__((unused)) = ap->a_bn; /* fs block number */ struct vnode **vpp = ap->a_vpp; /* RETURN vp of device */ daddr_t *bnp __attribute__((unused)) = ap->a_bnp; /* RETURN device block number */ - struct proc *p __attribute__((unused)) = curproc; + struct proc *p __attribute__((unused)) = curproc->l_proc; /* upcall decl */ /* locals */ *vpp = (struct vnode *)0; @@ -1781,9 +1781,9 @@ { /* true args */ struct vop_strategy_args *ap = v; struct buf *bp __attribute__((unused)) = ap->a_bp; - struct proc *p __attribute__((unused)) = curproc; + struct proc *p __attribute__((unused)) = curproc->l_proc; /* upcall decl */ /* locals */ myprintf(("coda_strategy called! ")); Index: sys/compat/aout/aout_misc.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/aout/aout_misc.c,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.6 -r1.6.2.1 --- sys/compat/aout/aout_misc.c 2001/01/22 20:08:03 1.6 +++ sys/compat/aout/aout_misc.c 2001/03/13 20:47:44 1.6.2.1 @@ -50,8 +50,9 @@ #include #include #include #include +#include #include #include #include @@ -60,14 +61,15 @@ #include #include int -aout_sys_open(p, v, retval) - struct proc *p; +aout_sys_open(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_open_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); #if 0 if (SCARG(uap, flags) & O_CREAT) @@ -75,127 +77,134 @@ else #endif CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_open(p, v, retval); + return sys_open(l, v, retval); } int -aout_sys_creat(p, v, retval) - struct proc *p; +aout_sys_creat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #if 0 struct aout_sys_creat_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); #endif - return compat_43_sys_creat(p, v, retval); + return compat_43_sys_creat(l, v, retval); } int -aout_sys_link(p, v, retval) - struct proc *p; +aout_sys_link(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_link_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); #if 0 CHECK_ALT_CREAT(p, &sg, SCARG(uap, link)); #endif - return sys_link(p, v, retval); + return sys_link(l, v, retval); } int -aout_sys_unlink(p, v, retval) - struct proc *p; +aout_sys_unlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_unlink_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_unlink(p, v, retval); + return sys_unlink(l, v, retval); } int -aout_sys_chdir(p, v, retval) - struct proc *p; +aout_sys_chdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_chdir_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_chdir(p, v, retval); + return sys_chdir(l, v, retval); } int -aout_sys_mknod(p, v, retval) - struct proc *p; +aout_sys_mknod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #if 0 struct aout_sys_mknod_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); #endif - return sys_mknod(p, v, retval); + return sys_mknod(l, v, retval); } int -aout_sys_chmod(p, v, retval) - struct proc *p; +aout_sys_chmod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_chmod_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_chmod(p, v, retval); + return sys_chmod(l, v, retval); } int -aout_sys_chown(p, v, retval) - struct proc *p; +aout_sys_chown(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_chown_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_chown(p, v, retval); + return sys_chown(l, v, retval); } int -aout_sys_mount(p, v, retval) - struct proc *p; +aout_sys_mount(l, v, retval) + struct lwp *l; void *v; register_t *retval; { /* @@ -203,498 +212,530 @@ * to avoid e.g. mounting the /usr filesystem on /emul/aout/usr. */ #if 0 struct aout_sys_mount_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); #endif - return sys_mount(p, v, retval); + return sys_mount(l, v, retval); } int -aout_sys_unmount(p, v, retval) - struct proc *p; +aout_sys_unmount(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_unmount_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_unmount(p, v, retval); + return sys_unmount(l, v, retval); } int -aout_sys_access(p, v, retval) - struct proc *p; +aout_sys_access(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_access_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_access(p, v, retval); + return sys_access(l, v, retval); } int -aout_sys_chflags(p, v, retval) - struct proc *p; +aout_sys_chflags(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_chflags_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_chflags(p, v, retval); + return sys_chflags(l, v, retval); } int -aout_compat_43_sys_stat(p, v, retval) - struct proc *p; +aout_compat_43_sys_stat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_compat_43_sys_stat_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return compat_43_sys_stat(p, v, retval); + return compat_43_sys_stat(l, v, retval); } int -aout_compat_43_sys_lstat(p, v, retval) - struct proc *p; +aout_compat_43_sys_lstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_compat_43_sys_lstat_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return compat_43_sys_lstat(p, v, retval); + return compat_43_sys_lstat(l, v, retval); } #ifdef KTRACE int -aout_sys_ktrace(p, v, retval) - struct proc *p; +aout_sys_ktrace(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #if 0 struct aout_sys_ktrace_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_CREAT(p, &sg, SCARG(uap, fname)); #endif - return sys_ktrace(p, v, retval); + return sys_ktrace(l, v, retval); } #endif int -aout_sys_acct(p, v, retval) - struct proc *p; +aout_sys_acct(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #if 0 struct aout_sys_acct_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); #endif - return sys_acct(p, v, retval); + return sys_acct(l, v, retval); } int -aout_sys_revoke(p, v, retval) - struct proc *p; +aout_sys_revoke(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_revoke_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_revoke(p, v, retval); + return sys_revoke(l, v, retval); } int -aout_sys_symlink(p, v, retval) - struct proc *p; +aout_sys_symlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_symlink_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); #if 0 CHECK_ALT_CREAT(p, &sg, SCARG(uap, link)); #endif - return sys_symlink(p, v, retval); + return sys_symlink(l, v, retval); } int -aout_sys_readlink(p, v, retval) - struct proc *p; +aout_sys_readlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_readlink_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path)); - return sys_readlink(p, v, retval); + return sys_readlink(l, v, retval); } int -aout_sys_execve(p, v, retval) - struct proc *p; +aout_sys_execve(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_execve_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_execve(p, v, retval); + return sys_execve(l, v, retval); } int -aout_sys_chroot(p, v, retval) - struct proc *p; +aout_sys_chroot(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_chroot_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_chroot(p, v, retval); + return sys_chroot(l, v, retval); } int -aout_sys_rename(p, v, retval) - struct proc *p; +aout_sys_rename(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_rename_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, from)); #if 0 CHECK_ALT_CREAT(p, &sg, SCARG(uap, to)); #endif - return sys_rename(p, v, retval); + return sys_rename(l, v, retval); } int -aout_compat_43_sys_truncate(p, v, retval) - struct proc *p; +aout_compat_43_sys_truncate(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_compat_43_sys_truncate_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return compat_43_sys_truncate(p, v, retval); + return compat_43_sys_truncate(l, v, retval); } int -aout_sys_mkfifo(p, v, retval) - struct proc *p; +aout_sys_mkfifo(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #if 0 struct aout_sys_mkfifo_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); #endif - return sys_mkfifo(p, v, retval); + return sys_mkfifo(l, v, retval); } int -aout_sys_mkdir(p, v, retval) - struct proc *p; +aout_sys_mkdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #if 0 struct aout_sys_mkdir_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); #endif - return sys_mkdir(p, v, retval); + return sys_mkdir(l, v, retval); } int -aout_sys_rmdir(p, v, retval) - struct proc *p; +aout_sys_rmdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_rmdir_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_rmdir(p, v, retval); + return sys_rmdir(l, v, retval); } int -aout_sys_utimes(p, v, retval) - struct proc *p; +aout_sys_utimes(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_utimes_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_utimes(p, v, retval); + return sys_utimes(l, v, retval); } int -aout_sys_quotactl(p, v, retval) - struct proc *p; +aout_sys_quotactl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #if 0 struct aout_sys_quotactl_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); #endif - return sys_quotactl(p, v, retval); + return sys_quotactl(l, v, retval); } int -aout_sys_statfs(p, v, retval) - struct proc *p; +aout_sys_statfs(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_statfs_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_statfs(p, v, retval); + return sys_statfs(l, v, retval); } #if defined(NFS) || defined(NFSSERVER) int -aout_sys_getfh(p, v, retval) - struct proc *p; +aout_sys_getfh(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_getfh_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, fname)); - return sys_getfh(p, v, retval); + return sys_getfh(l, v, retval); } #endif int -aout_compat_12_sys_stat(p, v, retval) - struct proc *p; +aout_compat_12_sys_stat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_compat_12_sys_stat_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return compat_12_sys_stat(p, v, retval); + return compat_12_sys_stat(l, v, retval); } int -aout_compat_12_sys_lstat(p, v, retval) - struct proc *p; +aout_compat_12_sys_lstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_compat_12_sys_lstat_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return compat_12_sys_lstat(p, v, retval); + return compat_12_sys_lstat(l, v, retval); } int -aout_sys_pathconf(p, v, retval) - struct proc *p; +aout_sys_pathconf(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_pathconf_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_pathconf(p, v, retval); + return sys_pathconf(l, v, retval); } int -aout_sys_truncate(p, v, retval) - struct proc *p; +aout_sys_truncate(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_truncate_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_truncate(p, v, retval); + return sys_truncate(l, v, retval); } int -aout_sys_undelete(p, v, retval) - struct proc *p; +aout_sys_undelete(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_undelete_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_undelete(p, v, retval); + return sys_undelete(l, v, retval); } int -aout_sys___posix_rename(p, v, retval) - struct proc *p; +aout_sys___posix_rename(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys___posix_rename_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, from)); #if 0 CHECK_ALT_CREAT(p, &sg, SCARG(uap, to)); #endif - return sys___posix_rename(p, v, retval); + return sys___posix_rename(l, v, retval); } int -aout_sys_lchmod(p, v, retval) - struct proc *p; +aout_sys_lchmod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_lchmod_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path)); - return sys_lchmod(p, v, retval); + return sys_lchmod(l, v, retval); } int -aout_sys_lchown(p, v, retval) - struct proc *p; +aout_sys_lchown(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_lchown_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path)); - return sys_lchown(p, v, retval); + return sys_lchown(l, v, retval); } int -aout_sys_lutimes(p, v, retval) - struct proc *p; +aout_sys_lutimes(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys_lutimes_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path)); - return sys_lutimes(p, v, retval); + return sys_lutimes(l, v, retval); } int -aout_sys___posix_chown(p, v, retval) - struct proc *p; +aout_sys___posix_chown(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct aout_sys___posix_chown_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys___posix_chown(p, v, retval); + return sys___posix_chown(l, v, retval); } Index: sys/compat/aout/aout_syscallargs.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/aout/aout_syscallargs.h,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.17 -r1.17.2.1 --- sys/compat/aout/aout_syscallargs.h 2001/01/27 07:50:34 1.17 +++ sys/compat/aout/aout_syscallargs.h 2001/03/13 20:48:46 1.17.2.1 @@ -236,308 +236,308 @@ /* * System call prototypes. */ -int sys_exit(struct proc *, void *, register_t *); -int sys_fork(struct proc *, void *, register_t *); -int sys_read(struct proc *, void *, register_t *); -int sys_write(struct proc *, void *, register_t *); -int aout_sys_open(struct proc *, void *, register_t *); -int sys_close(struct proc *, void *, register_t *); -int sys_wait4(struct proc *, void *, register_t *); -int aout_sys_creat(struct proc *, void *, register_t *); -int aout_sys_link(struct proc *, void *, register_t *); -int aout_sys_unlink(struct proc *, void *, register_t *); -int aout_sys_chdir(struct proc *, void *, register_t *); -int sys_fchdir(struct proc *, void *, register_t *); -int aout_sys_mknod(struct proc *, void *, register_t *); -int aout_sys_chmod(struct proc *, void *, register_t *); -int aout_sys_chown(struct proc *, void *, register_t *); -int sys_obreak(struct proc *, void *, register_t *); -int sys_getfsstat(struct proc *, void *, register_t *); -int compat_43_sys_lseek(struct proc *, void *, register_t *); -int sys_getpid(struct proc *, void *, register_t *); -int aout_sys_mount(struct proc *, void *, register_t *); -int aout_sys_unmount(struct proc *, void *, register_t *); -int sys_setuid(struct proc *, void *, register_t *); -int sys_getuid(struct proc *, void *, register_t *); -int sys_geteuid(struct proc *, void *, register_t *); -int sys_ptrace(struct proc *, void *, register_t *); -int sys_recvmsg(struct proc *, void *, register_t *); -int sys_sendmsg(struct proc *, void *, register_t *); -int sys_recvfrom(struct proc *, void *, register_t *); -int sys_accept(struct proc *, void *, register_t *); -int sys_getpeername(struct proc *, void *, register_t *); -int sys_getsockname(struct proc *, void *, register_t *); -int aout_sys_access(struct proc *, void *, register_t *); -int aout_sys_chflags(struct proc *, void *, register_t *); -int sys_fchflags(struct proc *, void *, register_t *); -int sys_sync(struct proc *, void *, register_t *); -int sys_kill(struct proc *, void *, register_t *); -int aout_compat_43_sys_stat(struct proc *, void *, register_t *); -int sys_getppid(struct proc *, void *, register_t *); -int aout_compat_43_sys_lstat(struct proc *, void *, register_t *); -int sys_dup(struct proc *, void *, register_t *); -int sys_pipe(struct proc *, void *, register_t *); -int sys_getegid(struct proc *, void *, register_t *); -int sys_profil(struct proc *, void *, register_t *); +int sys_exit(struct lwp *, void *, register_t *); +int sys_fork(struct lwp *, void *, register_t *); +int sys_read(struct lwp *, void *, register_t *); +int sys_write(struct lwp *, void *, register_t *); +int aout_sys_open(struct lwp *, void *, register_t *); +int sys_close(struct lwp *, void *, register_t *); +int sys_wait4(struct lwp *, void *, register_t *); +int aout_sys_creat(struct lwp *, void *, register_t *); +int aout_sys_link(struct lwp *, void *, register_t *); +int aout_sys_unlink(struct lwp *, void *, register_t *); +int aout_sys_chdir(struct lwp *, void *, register_t *); +int sys_fchdir(struct lwp *, void *, register_t *); +int aout_sys_mknod(struct lwp *, void *, register_t *); +int aout_sys_chmod(struct lwp *, void *, register_t *); +int aout_sys_chown(struct lwp *, void *, register_t *); +int sys_obreak(struct lwp *, void *, register_t *); +int sys_getfsstat(struct lwp *, void *, register_t *); +int compat_43_sys_lseek(struct lwp *, void *, register_t *); +int sys_getpid(struct lwp *, void *, register_t *); +int aout_sys_mount(struct lwp *, void *, register_t *); +int aout_sys_unmount(struct lwp *, void *, register_t *); +int sys_setuid(struct lwp *, void *, register_t *); +int sys_getuid(struct lwp *, void *, register_t *); +int sys_geteuid(struct lwp *, void *, register_t *); +int sys_ptrace(struct lwp *, void *, register_t *); +int sys_recvmsg(struct lwp *, void *, register_t *); +int sys_sendmsg(struct lwp *, void *, register_t *); +int sys_recvfrom(struct lwp *, void *, register_t *); +int sys_accept(struct lwp *, void *, register_t *); +int sys_getpeername(struct lwp *, void *, register_t *); +int sys_getsockname(struct lwp *, void *, register_t *); +int aout_sys_access(struct lwp *, void *, register_t *); +int aout_sys_chflags(struct lwp *, void *, register_t *); +int sys_fchflags(struct lwp *, void *, register_t *); +int sys_sync(struct lwp *, void *, register_t *); +int sys_kill(struct lwp *, void *, register_t *); +int aout_compat_43_sys_stat(struct lwp *, void *, register_t *); +int sys_getppid(struct lwp *, void *, register_t *); +int aout_compat_43_sys_lstat(struct lwp *, void *, register_t *); +int sys_dup(struct lwp *, void *, register_t *); +int sys_pipe(struct lwp *, void *, register_t *); +int sys_getegid(struct lwp *, void *, register_t *); +int sys_profil(struct lwp *, void *, register_t *); #if defined(KTRACE) || !defined(_KERNEL) -int aout_sys_ktrace(struct proc *, void *, register_t *); +int aout_sys_ktrace(struct lwp *, void *, register_t *); #else #endif -int compat_13_sys_sigaction(struct proc *, void *, register_t *); -int sys_getgid(struct proc *, void *, register_t *); -int compat_13_sys_sigprocmask(struct proc *, void *, register_t *); -int sys___getlogin(struct proc *, void *, register_t *); -int sys_setlogin(struct proc *, void *, register_t *); -int aout_sys_acct(struct proc *, void *, register_t *); -int compat_13_sys_sigpending(struct proc *, void *, register_t *); -int compat_13_sys_sigaltstack(struct proc *, void *, register_t *); -int sys_ioctl(struct proc *, void *, register_t *); -int compat_12_sys_reboot(struct proc *, void *, register_t *); -int aout_sys_revoke(struct proc *, void *, register_t *); -int aout_sys_symlink(struct proc *, void *, register_t *); -int aout_sys_readlink(struct proc *, void *, register_t *); -int aout_sys_execve(struct proc *, void *, register_t *); -int sys_umask(struct proc *, void *, register_t *); -int aout_sys_chroot(struct proc *, void *, register_t *); -int compat_43_sys_fstat(struct proc *, void *, register_t *); -int compat_43_sys_getkerninfo(struct proc *, void *, register_t *); -int compat_43_sys_getpagesize(struct proc *, void *, register_t *); -int compat_12_sys_msync(struct proc *, void *, register_t *); -int sys_vfork(struct proc *, void *, register_t *); -int sys_sbrk(struct proc *, void *, register_t *); -int sys_sstk(struct proc *, void *, register_t *); -int compat_43_sys_mmap(struct proc *, void *, register_t *); -int sys_ovadvise(struct proc *, void *, register_t *); -int sys_munmap(struct proc *, void *, register_t *); -int sys_mprotect(struct proc *, void *, register_t *); -int sys_madvise(struct proc *, void *, register_t *); -int sys_mincore(struct proc *, void *, register_t *); -int sys_getgroups(struct proc *, void *, register_t *); -int sys_setgroups(struct proc *, void *, register_t *); -int sys_getpgrp(struct proc *, void *, register_t *); -int sys_setpgid(struct proc *, void *, register_t *); -int sys_setitimer(struct proc *, void *, register_t *); -int compat_43_sys_wait(struct proc *, void *, register_t *); -int compat_12_sys_swapon(struct proc *, void *, register_t *); -int sys_getitimer(struct proc *, void *, register_t *); -int compat_43_sys_gethostname(struct proc *, void *, register_t *); -int compat_43_sys_sethostname(struct proc *, void *, register_t *); -int compat_43_sys_getdtablesize(struct proc *, void *, register_t *); -int sys_dup2(struct proc *, void *, register_t *); -int sys_fcntl(struct proc *, void *, register_t *); -int sys_select(struct proc *, void *, register_t *); -int sys_fsync(struct proc *, void *, register_t *); -int sys_setpriority(struct proc *, void *, register_t *); -int sys_socket(struct proc *, void *, register_t *); -int sys_connect(struct proc *, void *, register_t *); -int compat_43_sys_accept(struct proc *, void *, register_t *); -int sys_getpriority(struct proc *, void *, register_t *); -int compat_43_sys_send(struct proc *, void *, register_t *); -int compat_43_sys_recv(struct proc *, void *, register_t *); -int compat_13_sys_sigreturn(struct proc *, void *, register_t *); -int sys_bind(struct proc *, void *, register_t *); -int sys_setsockopt(struct proc *, void *, register_t *); -int sys_listen(struct proc *, void *, register_t *); -int compat_43_sys_sigvec(struct proc *, void *, register_t *); -int compat_43_sys_sigblock(struct proc *, void *, register_t *); -int compat_43_sys_sigsetmask(struct proc *, void *, register_t *); -int compat_13_sys_sigsuspend(struct proc *, void *, register_t *); -int compat_43_sys_sigstack(struct proc *, void *, register_t *); -int compat_43_sys_recvmsg(struct proc *, void *, register_t *); -int compat_43_sys_sendmsg(struct proc *, void *, register_t *); -int sys_gettimeofday(struct proc *, void *, register_t *); -int sys_getrusage(struct proc *, void *, register_t *); -int sys_getsockopt(struct proc *, void *, register_t *); -int sys_readv(struct proc *, void *, register_t *); -int sys_writev(struct proc *, void *, register_t *); -int sys_settimeofday(struct proc *, void *, register_t *); -int sys_fchown(struct proc *, void *, register_t *); -int sys_fchmod(struct proc *, void *, register_t *); -int compat_43_sys_recvfrom(struct proc *, void *, register_t *); -int sys_setreuid(struct proc *, void *, register_t *); -int sys_setregid(struct proc *, void *, register_t *); -int aout_sys_rename(struct proc *, void *, register_t *); -int aout_compat_43_sys_truncate(struct proc *, void *, register_t *); -int compat_43_sys_ftruncate(struct proc *, void *, register_t *); -int sys_flock(struct proc *, void *, register_t *); -int aout_sys_mkfifo(struct proc *, void *, register_t *); -int sys_sendto(struct proc *, void *, register_t *); -int sys_shutdown(struct proc *, void *, register_t *); -int sys_socketpair(struct proc *, void *, register_t *); -int aout_sys_mkdir(struct proc *, void *, register_t *); -int aout_sys_rmdir(struct proc *, void *, register_t *); -int aout_sys_utimes(struct proc *, void *, register_t *); -int sys_adjtime(struct proc *, void *, register_t *); -int compat_43_sys_getpeername(struct proc *, void *, register_t *); -int compat_43_sys_gethostid(struct proc *, void *, register_t *); -int compat_43_sys_sethostid(struct proc *, void *, register_t *); -int compat_43_sys_getrlimit(struct proc *, void *, register_t *); -int compat_43_sys_setrlimit(struct proc *, void *, register_t *); -int compat_43_sys_killpg(struct proc *, void *, register_t *); -int sys_setsid(struct proc *, void *, register_t *); -int aout_sys_quotactl(struct proc *, void *, register_t *); -int compat_43_sys_quota(struct proc *, void *, register_t *); -int compat_43_sys_getsockname(struct proc *, void *, register_t *); +int compat_13_sys_sigaction(struct lwp *, void *, register_t *); +int sys_getgid(struct lwp *, void *, register_t *); +int compat_13_sys_sigprocmask(struct lwp *, void *, register_t *); +int sys___getlogin(struct lwp *, void *, register_t *); +int sys_setlogin(struct lwp *, void *, register_t *); +int aout_sys_acct(struct lwp *, void *, register_t *); +int compat_13_sys_sigpending(struct lwp *, void *, register_t *); +int compat_13_sys_sigaltstack(struct lwp *, void *, register_t *); +int sys_ioctl(struct lwp *, void *, register_t *); +int compat_12_sys_reboot(struct lwp *, void *, register_t *); +int aout_sys_revoke(struct lwp *, void *, register_t *); +int aout_sys_symlink(struct lwp *, void *, register_t *); +int aout_sys_readlink(struct lwp *, void *, register_t *); +int aout_sys_execve(struct lwp *, void *, register_t *); +int sys_umask(struct lwp *, void *, register_t *); +int aout_sys_chroot(struct lwp *, void *, register_t *); +int compat_43_sys_fstat(struct lwp *, void *, register_t *); +int compat_43_sys_getkerninfo(struct lwp *, void *, register_t *); +int compat_43_sys_getpagesize(struct lwp *, void *, register_t *); +int compat_12_sys_msync(struct lwp *, void *, register_t *); +int sys_vfork(struct lwp *, void *, register_t *); +int sys_sbrk(struct lwp *, void *, register_t *); +int sys_sstk(struct lwp *, void *, register_t *); +int compat_43_sys_mmap(struct lwp *, void *, register_t *); +int sys_ovadvise(struct lwp *, void *, register_t *); +int sys_munmap(struct lwp *, void *, register_t *); +int sys_mprotect(struct lwp *, void *, register_t *); +int sys_madvise(struct lwp *, void *, register_t *); +int sys_mincore(struct lwp *, void *, register_t *); +int sys_getgroups(struct lwp *, void *, register_t *); +int sys_setgroups(struct lwp *, void *, register_t *); +int sys_getpgrp(struct lwp *, void *, register_t *); +int sys_setpgid(struct lwp *, void *, register_t *); +int sys_setitimer(struct lwp *, void *, register_t *); +int compat_43_sys_wait(struct lwp *, void *, register_t *); +int compat_12_sys_swapon(struct lwp *, void *, register_t *); +int sys_getitimer(struct lwp *, void *, register_t *); +int compat_43_sys_gethostname(struct lwp *, void *, register_t *); +int compat_43_sys_sethostname(struct lwp *, void *, register_t *); +int compat_43_sys_getdtablesize(struct lwp *, void *, register_t *); +int sys_dup2(struct lwp *, void *, register_t *); +int sys_fcntl(struct lwp *, void *, register_t *); +int sys_select(struct lwp *, void *, register_t *); +int sys_fsync(struct lwp *, void *, register_t *); +int sys_setpriority(struct lwp *, void *, register_t *); +int sys_socket(struct lwp *, void *, register_t *); +int sys_connect(struct lwp *, void *, register_t *); +int compat_43_sys_accept(struct lwp *, void *, register_t *); +int sys_getpriority(struct lwp *, void *, register_t *); +int compat_43_sys_send(struct lwp *, void *, register_t *); +int compat_43_sys_recv(struct lwp *, void *, register_t *); +int compat_13_sys_sigreturn(struct lwp *, void *, register_t *); +int sys_bind(struct lwp *, void *, register_t *); +int sys_setsockopt(struct lwp *, void *, register_t *); +int sys_listen(struct lwp *, void *, register_t *); +int compat_43_sys_sigvec(struct lwp *, void *, register_t *); +int compat_43_sys_sigblock(struct lwp *, void *, register_t *); +int compat_43_sys_sigsetmask(struct lwp *, void *, register_t *); +int compat_13_sys_sigsuspend(struct lwp *, void *, register_t *); +int compat_43_sys_sigstack(struct lwp *, void *, register_t *); +int compat_43_sys_recvmsg(struct lwp *, void *, register_t *); +int compat_43_sys_sendmsg(struct lwp *, void *, register_t *); +int sys_gettimeofday(struct lwp *, void *, register_t *); +int sys_getrusage(struct lwp *, void *, register_t *); +int sys_getsockopt(struct lwp *, void *, register_t *); +int sys_readv(struct lwp *, void *, register_t *); +int sys_writev(struct lwp *, void *, register_t *); +int sys_settimeofday(struct lwp *, void *, register_t *); +int sys_fchown(struct lwp *, void *, register_t *); +int sys_fchmod(struct lwp *, void *, register_t *); +int compat_43_sys_recvfrom(struct lwp *, void *, register_t *); +int sys_setreuid(struct lwp *, void *, register_t *); +int sys_setregid(struct lwp *, void *, register_t *); +int aout_sys_rename(struct lwp *, void *, register_t *); +int aout_compat_43_sys_truncate(struct lwp *, void *, register_t *); +int compat_43_sys_ftruncate(struct lwp *, void *, register_t *); +int sys_flock(struct lwp *, void *, register_t *); +int aout_sys_mkfifo(struct lwp *, void *, register_t *); +int sys_sendto(struct lwp *, void *, register_t *); +int sys_shutdown(struct lwp *, void *, register_t *); +int sys_socketpair(struct lwp *, void *, register_t *); +int aout_sys_mkdir(struct lwp *, void *, register_t *); +int aout_sys_rmdir(struct lwp *, void *, register_t *); +int aout_sys_utimes(struct lwp *, void *, register_t *); +int sys_adjtime(struct lwp *, void *, register_t *); +int compat_43_sys_getpeername(struct lwp *, void *, register_t *); +int compat_43_sys_gethostid(struct lwp *, void *, register_t *); +int compat_43_sys_sethostid(struct lwp *, void *, register_t *); +int compat_43_sys_getrlimit(struct lwp *, void *, register_t *); +int compat_43_sys_setrlimit(struct lwp *, void *, register_t *); +int compat_43_sys_killpg(struct lwp *, void *, register_t *); +int sys_setsid(struct lwp *, void *, register_t *); +int aout_sys_quotactl(struct lwp *, void *, register_t *); +int compat_43_sys_quota(struct lwp *, void *, register_t *); +int compat_43_sys_getsockname(struct lwp *, void *, register_t *); #if defined(NFS) || defined(NFSSERVER) || !defined(_KERNEL) -int sys_nfssvc(struct proc *, void *, register_t *); +int sys_nfssvc(struct lwp *, void *, register_t *); #else #endif -int compat_43_sys_getdirentries(struct proc *, void *, register_t *); -int aout_sys_statfs(struct proc *, void *, register_t *); -int sys_fstatfs(struct proc *, void *, register_t *); +int compat_43_sys_getdirentries(struct lwp *, void *, register_t *); +int aout_sys_statfs(struct lwp *, void *, register_t *); +int sys_fstatfs(struct lwp *, void *, register_t *); #if defined(NFS) || defined(NFSSERVER) || !defined(_KERNEL) -int aout_sys_getfh(struct proc *, void *, register_t *); +int aout_sys_getfh(struct lwp *, void *, register_t *); #else #endif -int compat_09_sys_getdomainname(struct proc *, void *, register_t *); -int compat_09_sys_setdomainname(struct proc *, void *, register_t *); -int compat_09_sys_uname(struct proc *, void *, register_t *); -int sys_sysarch(struct proc *, void *, register_t *); +int compat_09_sys_getdomainname(struct lwp *, void *, register_t *); +int compat_09_sys_setdomainname(struct lwp *, void *, register_t *); +int compat_09_sys_uname(struct lwp *, void *, register_t *); +int sys_sysarch(struct lwp *, void *, register_t *); #if (defined(SYSVSEM) || !defined(_KERNEL)) && !defined(alpha) -int compat_10_sys_semsys(struct proc *, void *, register_t *); +int compat_10_sys_semsys(struct lwp *, void *, register_t *); #else #endif #if (defined(SYSVMSG) || !defined(_KERNEL)) && !defined(alpha) -int compat_10_sys_msgsys(struct proc *, void *, register_t *); +int compat_10_sys_msgsys(struct lwp *, void *, register_t *); #else #endif #if (defined(SYSVSHM) || !defined(_KERNEL)) && !defined(alpha) -int compat_10_sys_shmsys(struct proc *, void *, register_t *); +int compat_10_sys_shmsys(struct lwp *, void *, register_t *); #else #endif -int sys_pread(struct proc *, void *, register_t *); -int sys_pwrite(struct proc *, void *, register_t *); -int sys_ntp_gettime(struct proc *, void *, register_t *); +int sys_pread(struct lwp *, void *, register_t *); +int sys_pwrite(struct lwp *, void *, register_t *); +int sys_ntp_gettime(struct lwp *, void *, register_t *); #if defined(NTP) || !defined(_KERNEL) -int sys_ntp_adjtime(struct proc *, void *, register_t *); +int sys_ntp_adjtime(struct lwp *, void *, register_t *); #else #endif -int sys_setgid(struct proc *, void *, register_t *); -int sys_setegid(struct proc *, void *, register_t *); -int sys_seteuid(struct proc *, void *, register_t *); +int sys_setgid(struct lwp *, void *, register_t *); +int sys_setegid(struct lwp *, void *, register_t *); +int sys_seteuid(struct lwp *, void *, register_t *); #if defined(LFS) || !defined(_KERNEL) -int sys_lfs_bmapv(struct proc *, void *, register_t *); -int sys_lfs_markv(struct proc *, void *, register_t *); -int sys_lfs_segclean(struct proc *, void *, register_t *); -int sys_lfs_segwait(struct proc *, void *, register_t *); -#else -#endif -int aout_compat_12_sys_stat(struct proc *, void *, register_t *); -int compat_12_sys_fstat(struct proc *, void *, register_t *); -int aout_compat_12_sys_lstat(struct proc *, void *, register_t *); -int aout_sys_pathconf(struct proc *, void *, register_t *); -int sys_fpathconf(struct proc *, void *, register_t *); -int sys_getrlimit(struct proc *, void *, register_t *); -int sys_setrlimit(struct proc *, void *, register_t *); -int compat_12_sys_getdirentries(struct proc *, void *, register_t *); -int sys_mmap(struct proc *, void *, register_t *); -int sys_lseek(struct proc *, void *, register_t *); -int aout_sys_truncate(struct proc *, void *, register_t *); -int sys_ftruncate(struct proc *, void *, register_t *); -int sys___sysctl(struct proc *, void *, register_t *); -int sys_mlock(struct proc *, void *, register_t *); -int sys_munlock(struct proc *, void *, register_t *); -int aout_sys_undelete(struct proc *, void *, register_t *); -int sys_futimes(struct proc *, void *, register_t *); -int sys_getpgid(struct proc *, void *, register_t *); -int sys_reboot(struct proc *, void *, register_t *); -int sys_poll(struct proc *, void *, register_t *); +int sys_lfs_bmapv(struct lwp *, void *, register_t *); +int sys_lfs_markv(struct lwp *, void *, register_t *); +int sys_lfs_segclean(struct lwp *, void *, register_t *); +int sys_lfs_segwait(struct lwp *, void *, register_t *); +#else +#endif +int aout_compat_12_sys_stat(struct lwp *, void *, register_t *); +int compat_12_sys_fstat(struct lwp *, void *, register_t *); +int aout_compat_12_sys_lstat(struct lwp *, void *, register_t *); +int aout_sys_pathconf(struct lwp *, void *, register_t *); +int sys_fpathconf(struct lwp *, void *, register_t *); +int sys_getrlimit(struct lwp *, void *, register_t *); +int sys_setrlimit(struct lwp *, void *, register_t *); +int compat_12_sys_getdirentries(struct lwp *, void *, register_t *); +int sys_mmap(struct lwp *, void *, register_t *); +int sys_lseek(struct lwp *, void *, register_t *); +int aout_sys_truncate(struct lwp *, void *, register_t *); +int sys_ftruncate(struct lwp *, void *, register_t *); +int sys___sysctl(struct lwp *, void *, register_t *); +int sys_mlock(struct lwp *, void *, register_t *); +int sys_munlock(struct lwp *, void *, register_t *); +int aout_sys_undelete(struct lwp *, void *, register_t *); +int sys_futimes(struct lwp *, void *, register_t *); +int sys_getpgid(struct lwp *, void *, register_t *); +int sys_reboot(struct lwp *, void *, register_t *); +int sys_poll(struct lwp *, void *, register_t *); #if defined(LKM) || !defined(_KERNEL) -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); #else /* !LKM */ #endif /* !LKM */ #if defined(SYSVSEM) || !defined(_KERNEL) #ifdef COMPAT_14 -int compat_14_sys___semctl(struct proc *, void *, register_t *); +int compat_14_sys___semctl(struct lwp *, void *, register_t *); #else #endif -int sys_semget(struct proc *, void *, register_t *); -int sys_semop(struct proc *, void *, register_t *); -int sys_semconfig(struct proc *, void *, register_t *); +int sys_semget(struct lwp *, void *, register_t *); +int sys_semop(struct lwp *, void *, register_t *); +int sys_semconfig(struct lwp *, void *, register_t *); #else #endif #if defined(SYSVMSG) || !defined(_KERNEL) #ifdef COMPAT_14 -int compat_14_sys_msgctl(struct proc *, void *, register_t *); +int compat_14_sys_msgctl(struct lwp *, void *, register_t *); #else #endif -int sys_msgget(struct proc *, void *, register_t *); -int sys_msgsnd(struct proc *, void *, register_t *); -int sys_msgrcv(struct proc *, void *, register_t *); +int sys_msgget(struct lwp *, void *, register_t *); +int sys_msgsnd(struct lwp *, void *, register_t *); +int sys_msgrcv(struct lwp *, void *, register_t *); #else #endif #if defined(SYSVSHM) || !defined(_KERNEL) -int sys_shmat(struct proc *, void *, register_t *); +int sys_shmat(struct lwp *, void *, register_t *); #ifdef COMPAT_14 -int compat_14_sys_shmctl(struct proc *, void *, register_t *); +int compat_14_sys_shmctl(struct lwp *, void *, register_t *); #else #endif -int sys_shmdt(struct proc *, void *, register_t *); -int sys_shmget(struct proc *, void *, register_t *); +int sys_shmdt(struct lwp *, void *, register_t *); +int sys_shmget(struct lwp *, void *, register_t *); #else #endif -int sys_clock_gettime(struct proc *, void *, register_t *); -int sys_clock_settime(struct proc *, void *, register_t *); -int sys_clock_getres(struct proc *, void *, register_t *); -int sys_nanosleep(struct proc *, void *, register_t *); -int sys_fdatasync(struct proc *, void *, register_t *); -int sys_mlockall(struct proc *, void *, register_t *); -int sys_munlockall(struct proc *, void *, register_t *); -int aout_sys___posix_rename(struct proc *, void *, register_t *); -int sys_swapctl(struct proc *, void *, register_t *); -int sys_getdents(struct proc *, void *, register_t *); -int sys_minherit(struct proc *, void *, register_t *); -int aout_sys_lchmod(struct proc *, void *, register_t *); -int aout_sys_lchown(struct proc *, void *, register_t *); -int aout_sys_lutimes(struct proc *, void *, register_t *); -int sys___msync13(struct proc *, void *, register_t *); -int sys___stat13(struct proc *, void *, register_t *); -int sys___fstat13(struct proc *, void *, register_t *); -int sys___lstat13(struct proc *, void *, register_t *); -int sys___sigaltstack14(struct proc *, void *, register_t *); -int sys___vfork14(struct proc *, void *, register_t *); -int aout_sys___posix_chown(struct proc *, void *, register_t *); -int sys___posix_fchown(struct proc *, void *, register_t *); -int sys___posix_lchown(struct proc *, void *, register_t *); -int sys_getsid(struct proc *, void *, register_t *); +int sys_clock_gettime(struct lwp *, void *, register_t *); +int sys_clock_settime(struct lwp *, void *, register_t *); +int sys_clock_getres(struct lwp *, void *, register_t *); +int sys_nanosleep(struct lwp *, void *, register_t *); +int sys_fdatasync(struct lwp *, void *, register_t *); +int sys_mlockall(struct lwp *, void *, register_t *); +int sys_munlockall(struct lwp *, void *, register_t *); +int aout_sys___posix_rename(struct lwp *, void *, register_t *); +int sys_swapctl(struct lwp *, void *, register_t *); +int sys_getdents(struct lwp *, void *, register_t *); +int sys_minherit(struct lwp *, void *, register_t *); +int aout_sys_lchmod(struct lwp *, void *, register_t *); +int aout_sys_lchown(struct lwp *, void *, register_t *); +int aout_sys_lutimes(struct lwp *, void *, register_t *); +int sys___msync13(struct lwp *, void *, register_t *); +int sys___stat13(struct lwp *, void *, register_t *); +int sys___fstat13(struct lwp *, void *, register_t *); +int sys___lstat13(struct lwp *, void *, register_t *); +int sys___sigaltstack14(struct lwp *, void *, register_t *); +int sys___vfork14(struct lwp *, void *, register_t *); +int aout_sys___posix_chown(struct lwp *, void *, register_t *); +int sys___posix_fchown(struct lwp *, void *, register_t *); +int sys___posix_lchown(struct lwp *, void *, register_t *); +int sys_getsid(struct lwp *, void *, register_t *); #if defined(KTRACE) || !defined(_KERNEL) -int sys_fktrace(struct proc *, void *, register_t *); +int sys_fktrace(struct lwp *, void *, register_t *); #else #endif -int sys_preadv(struct proc *, void *, register_t *); -int sys_pwritev(struct proc *, void *, register_t *); -int sys___sigaction14(struct proc *, void *, register_t *); -int sys___sigpending14(struct proc *, void *, register_t *); -int sys___sigprocmask14(struct proc *, void *, register_t *); -int sys___sigsuspend14(struct proc *, void *, register_t *); -int sys___sigreturn14(struct proc *, void *, register_t *); -int sys___getcwd(struct proc *, void *, register_t *); -int sys_fchroot(struct proc *, void *, register_t *); -int sys_fhopen(struct proc *, void *, register_t *); -int sys_fhstat(struct proc *, void *, register_t *); -int sys_fhstatfs(struct proc *, void *, register_t *); +int sys_preadv(struct lwp *, void *, register_t *); +int sys_pwritev(struct lwp *, void *, register_t *); +int sys___sigaction14(struct lwp *, void *, register_t *); +int sys___sigpending14(struct lwp *, void *, register_t *); +int sys___sigprocmask14(struct lwp *, void *, register_t *); +int sys___sigsuspend14(struct lwp *, void *, register_t *); +int sys___sigreturn14(struct lwp *, void *, register_t *); +int sys___getcwd(struct lwp *, void *, register_t *); +int sys_fchroot(struct lwp *, void *, register_t *); +int sys_fhopen(struct lwp *, void *, register_t *); +int sys_fhstat(struct lwp *, void *, register_t *); +int sys_fhstatfs(struct lwp *, void *, register_t *); #if defined(SYSVSEM) || !defined(_KERNEL) -int sys_____semctl13(struct proc *, void *, register_t *); +int sys_____semctl13(struct lwp *, void *, register_t *); #else #endif #if defined(SYSVMSG) || !defined(_KERNEL) -int sys___msgctl13(struct proc *, void *, register_t *); +int sys___msgctl13(struct lwp *, void *, register_t *); #else #endif #if defined(SYSVSHM) || !defined(_KERNEL) -int sys___shmctl13(struct proc *, void *, register_t *); +int sys___shmctl13(struct lwp *, void *, register_t *); #else #endif -int sys_lchflags(struct proc *, void *, register_t *); -int sys_issetugid(struct proc *, void *, register_t *); +int sys_lchflags(struct lwp *, void *, register_t *); +int sys_issetugid(struct lwp *, void *, register_t *); #endif /* _AOUT_SYS__SYSCALLARGS_H_ */ Index: sys/compat/common/compat_util.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/compat_util.c,v retrieving revision 1.20 retrieving revision 1.20.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.20 -r1.20.2.1 --- sys/compat/common/compat_util.c 2001/02/02 21:17:45 1.20 +++ sys/compat/common/compat_util.c 2001/03/05 22:49:18 1.20.2.1 @@ -38,8 +38,9 @@ #include #include #include +#include #include #include #include #include @@ -237,9 +238,9 @@ caddr_t stackgap_init(e) const struct emul *e; { - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ #define szsigcode ((caddr_t)(e->e_esigcode - e->e_sigcode)) return (caddr_t)(((unsigned long)p->p_psstr - (unsigned long)szsigcode - STACKGAPLEN) & ~ALIGNBYTES); @@ -253,9 +254,9 @@ size_t sz; { void *n = (void *) *sgp; caddr_t nsgp; - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ const struct emul *e = p->p_emul; int sigsize = e->e_esigcode - e->e_sigcode; sz = ALIGN(sz); Index: sys/compat/common/kern_exit_43.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/kern_exit_43.c,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.6 -r1.6.2.1 --- sys/compat/common/kern_exit_43.c 2000/06/28 15:39:25 1.6 +++ sys/compat/common/kern_exit_43.c 2001/03/05 22:49:18 1.6.2.1 @@ -43,8 +43,9 @@ #include #include #include #include +#include #include #include #include #include @@ -75,14 +76,11 @@ #define GETPS(rp) (rp)[PS] #endif int -compat_43_sys_wait(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_wait(struct lwp *l, void *v, register_t *retval) { - caddr_t sg = stackgap_init(p->p_emul); + caddr_t sg = stackgap_init(l->l_proc->p_emul); int error; struct sys_wait4_args /* { syscallarg(int) pid; @@ -91,21 +89,21 @@ syscallarg(struct rusage *) rusage; } */ a; #ifdef PSL_ALLCC - if ((GETPS(p->p_md.md_regs) & PSL_ALLCC) != PSL_ALLCC) { + if ((GETPS(l->l_md.md_regs) & PSL_ALLCC) != PSL_ALLCC) { SCARG(&a, options) = 0; SCARG(&a, rusage) = NULL; } else { - SCARG(&a, options) = p->p_md.md_regs[R0]; - SCARG(&a, rusage) = (struct rusage *)p->p_md.md_regs[R1]; + SCARG(&a, options) = l->l_md.md_regs[R0]; + SCARG(&a, rusage) = (struct rusage *)l->l_md.md_regs[R1]; } #else SCARG(&a, options) = 0; SCARG(&a, rusage) = NULL; #endif SCARG(&a, pid) = WAIT_ANY; SCARG(&a, status) = stackgap_alloc(&sg, sizeof(SCARG(&a, status))); - if ((error = sys_wait4(p, &a, retval)) != 0) + if ((error = sys_wait4(l, &a, retval)) != 0) return error; return copyin(SCARG(&a, status), &retval[1], sizeof(retval[1])); } Index: sys/compat/common/kern_info_09.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/kern_info_09.c,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.8 -r1.8.2.1 --- sys/compat/common/kern_info_09.c 2000/07/14 07:12:47 1.8 +++ sys/compat/common/kern_info_09.c 2001/03/05 22:49:18 1.8.2.1 @@ -38,8 +38,9 @@ #include #include #include #include +#include #include #include #include #include @@ -49,17 +50,15 @@ #include /* ARGSUSED */ int -compat_09_sys_getdomainname(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_09_sys_getdomainname(struct lwp *l, void *v, register_t *retval) { struct compat_09_sys_getdomainname_args /* { syscallarg(char *) domainname; syscallarg(int) len; } */ *uap = v; + struct proc *p = l->l_proc; int name; size_t sz; name = KERN_DOMAINNAME; @@ -69,17 +68,15 @@ /* ARGSUSED */ int -compat_09_sys_setdomainname(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_09_sys_setdomainname(struct lwp *l, void *v, register_t *retval) { struct compat_09_sys_setdomainname_args /* { syscallarg(char *) domainname; syscallarg(int) len; } */ *uap = v; + struct proc *p = l->l_proc; int name; int error; if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) @@ -98,12 +95,9 @@ }; /* ARGSUSED */ int -compat_09_sys_uname(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_09_sys_uname(struct lwp *l, void *v, register_t *retval) { struct compat_09_sys_uname_args /* { syscallarg(struct outsname *) name; } */ *uap = v; Index: sys/compat/common/kern_info_43.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/kern_info_43.c,v retrieving revision 1.12 retrieving revision 1.12.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.12 -r1.12.2.1 --- sys/compat/common/kern_info_43.c 2000/06/28 15:39:25 1.12 +++ sys/compat/common/kern_info_43.c 2001/03/05 22:49:18 1.12.2.1 @@ -39,8 +39,9 @@ #include #include #include #include +#include #include #include #include #include @@ -58,25 +59,20 @@ #include #include int -compat_43_sys_getdtablesize(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_getdtablesize(struct lwp *l, void *v, register_t *retval) { + struct proc *p = l->l_proc; *retval = min((int)p->p_rlimit[RLIMIT_NOFILE].rlim_cur, maxfiles); return (0); } /* ARGSUSED */ int -compat_43_sys_gethostid(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_gethostid(struct lwp *l, void *v, register_t *retval) { *(int32_t *)retval = hostid; return (0); @@ -84,17 +80,15 @@ /*ARGSUSED*/ int -compat_43_sys_gethostname(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_gethostname(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_gethostname_args /* { syscallarg(char *) hostname; syscallarg(u_int) len; } */ *uap = v; + struct proc *p = l->l_proc; int name; size_t sz; name = KERN_HOSTNAME; @@ -144,19 +138,17 @@ char *hostname; }; int -compat_43_sys_getkerninfo(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_getkerninfo(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_getkerninfo_args /* { syscallarg(int) op; syscallarg(char *) where; syscallarg(int *) size; syscallarg(int) arg; } */ *uap = v; + struct proc *p = l->l_proc; int error, name[5]; size_t size; if (SCARG(uap, size) && (error = copyin((caddr_t)SCARG(uap, size), @@ -283,16 +275,14 @@ /* ARGSUSED */ int -compat_43_sys_sethostid(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_sethostid(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_sethostid_args /* { syscallarg(int32_t) hostid; } */ *uap = v; + struct proc *p = l->l_proc; int error; if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) return (error); @@ -302,14 +292,12 @@ /* ARGSUSED */ int -compat_43_sys_sethostname(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_sethostname(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_sethostname_args *uap = v; + struct proc *p = l->l_proc; int name; int error; if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) Index: sys/compat/common/kern_ipc_10.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/kern_ipc_10.c,v retrieving revision 1.12 retrieving revision 1.12.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.12 -r1.12.2.1 --- sys/compat/common/kern_ipc_10.c 2000/07/27 14:00:56 1.12 +++ sys/compat/common/kern_ipc_10.c 2001/03/05 22:49:19 1.12.2.1 @@ -34,8 +34,9 @@ #include #include #include +#include #include #include #include @@ -45,10 +46,10 @@ #include #ifdef SYSVSEM int -compat_10_sys_semsys(p, v, retval) - struct proc *p; +compat_10_sys_semsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct compat_10_sys_semsys_args /* { @@ -76,8 +77,9 @@ } */ semop_args; struct sys_semconfig_args /* { syscallarg(int) flag; } */ semconfig_args; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); switch (SCARG(uap, which)) { case 0: /* __semctl() */ @@ -87,26 +89,26 @@ SCARG(&__semctl_args, arg) = stackgap_alloc(&sg, sizeof(union semun *)); copyout(&SCARG(uap, a5), SCARG(&__semctl_args, arg), sizeof(union __semun)); - return (compat_14_sys___semctl(p, &__semctl_args, retval)); + return (compat_14_sys___semctl(l, &__semctl_args, retval)); case 1: /* semget() */ SCARG(&semget_args, key) = SCARG(uap, a2); SCARG(&semget_args, nsems) = SCARG(uap, a3); SCARG(&semget_args, semflg) = SCARG(uap, a4); - return (sys_semget(p, &semget_args, retval)); + return (sys_semget(l, &semget_args, retval)); case 2: /* semop() */ SCARG(&semop_args, semid) = SCARG(uap, a2); SCARG(&semop_args, sops) = (struct sembuf *)(u_long)SCARG(uap, a3); SCARG(&semop_args, nsops) = SCARG(uap, a4); - return (sys_semop(p, &semop_args, retval)); + return (sys_semop(l, &semop_args, retval)); case 3: /* semconfig() */ SCARG(&semconfig_args, flag) = SCARG(uap, a2); - return (sys_semconfig(p, &semconfig_args, retval)); + return (sys_semconfig(l, &semconfig_args, retval)); default: return (EINVAL); } @@ -114,10 +116,10 @@ #endif #ifdef SYSVSHM int -compat_10_sys_shmsys(p, v, retval) - struct proc *p; +compat_10_sys_shmsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct compat_10_sys_shmsys_args /* { @@ -150,27 +152,27 @@ SCARG(&shmat_args, shmid) = SCARG(uap, a2); SCARG(&shmat_args, shmaddr) = (void *)(u_long)SCARG(uap, a3); SCARG(&shmat_args, shmflg) = SCARG(uap, a4); - return (sys_shmat(p, &shmat_args, retval)); + return (sys_shmat(l, &shmat_args, retval)); case 1: /* shmctl() */ SCARG(&shmctl_args, shmid) = SCARG(uap, a2); SCARG(&shmctl_args, cmd) = SCARG(uap, a3); SCARG(&shmctl_args, buf) = (struct shmid_ds14 *)(u_long)SCARG(uap, a4); - return (compat_14_sys_shmctl(p, &shmctl_args, retval)); + return (compat_14_sys_shmctl(l, &shmctl_args, retval)); case 2: /* shmdt() */ SCARG(&shmdt_args, shmaddr) = (void *)(u_long)SCARG(uap, a2); - return (sys_shmdt(p, &shmdt_args, retval)); + return (sys_shmdt(l, &shmdt_args, retval)); case 3: /* shmget() */ SCARG(&shmget_args, key) = SCARG(uap, a2); SCARG(&shmget_args, size) = SCARG(uap, a3); SCARG(&shmget_args, shmflg) = SCARG(uap, a4); - return (sys_shmget(p, &shmget_args, retval)); + return (sys_shmget(l, &shmget_args, retval)); default: return (EINVAL); } @@ -178,10 +180,10 @@ #endif #ifdef SYSVMSG int -compat_10_sys_msgsys(p, v, retval) - struct proc *p; +compat_10_sys_msgsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct compat_10_sys_msgsys_args /* { @@ -220,31 +222,31 @@ SCARG(&msgctl_args, msqid) = SCARG(uap, a2); SCARG(&msgctl_args, cmd) = SCARG(uap, a3); SCARG(&msgctl_args, buf) = (struct msqid_ds14 *)(u_long)SCARG(uap, a4); - return (compat_14_sys_msgctl(p, &msgctl_args, retval)); + return (compat_14_sys_msgctl(l, &msgctl_args, retval)); case 1: /* msgget() */ SCARG(&msgget_args, key) = SCARG(uap, a2); SCARG(&msgget_args, msgflg) = SCARG(uap, a3); - return (sys_msgget(p, &msgget_args, retval)); + return (sys_msgget(l, &msgget_args, retval)); case 2: /* msgsnd() */ SCARG(&msgsnd_args, msqid) = SCARG(uap, a2); SCARG(&msgsnd_args, msgp) = (void *)(u_long)SCARG(uap, a3); SCARG(&msgsnd_args, msgsz) = SCARG(uap, a4); SCARG(&msgsnd_args, msgflg) = SCARG(uap, a5); - return (sys_msgsnd(p, &msgsnd_args, retval)); + return (sys_msgsnd(l, &msgsnd_args, retval)); case 3: /* msgrcv() */ SCARG(&msgrcv_args, msqid) = SCARG(uap, a2); SCARG(&msgrcv_args, msgp) = (void *)(u_long)SCARG(uap, a3); SCARG(&msgrcv_args, msgsz) = SCARG(uap, a4); SCARG(&msgrcv_args, msgtyp) = SCARG(uap, a5); SCARG(&msgrcv_args, msgflg) = SCARG(uap, a6); - return (sys_msgrcv(p, &msgrcv_args, retval)); + return (sys_msgrcv(l, &msgrcv_args, retval)); default: return (EINVAL); } Index: sys/compat/common/kern_resource_43.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/kern_resource_43.c,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.8 -r1.8.2.1 --- sys/compat/common/kern_resource_43.c 2000/06/28 15:39:25 1.8 +++ sys/compat/common/kern_resource_43.c 2001/03/05 22:49:19 1.8.2.1 @@ -45,24 +45,23 @@ #include #include #include #include +#include #include #include #include /* ARGSUSED */ int -compat_43_sys_getrlimit(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_getrlimit(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_getrlimit_args /* { syscallarg(int) which; syscallarg(struct orlimit *) rlp; } */ *uap = v; + struct proc *p = l->l_proc; int which = SCARG(uap, which); struct orlimit olim; if ((u_int)which >= RLIM_NLIMITS) @@ -78,17 +77,15 @@ } /* ARGSUSED */ int -compat_43_sys_setrlimit(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_setrlimit(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_setrlimit_args /* { syscallarg(int) which; syscallarg(const struct orlimit *) rlp; } */ *uap = v; + struct proc *p = l->l_proc; int which = SCARG(uap, which); struct orlimit olim; struct rlimit lim; int error; Index: sys/compat/common/kern_sig_13.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/kern_sig_13.c,v retrieving revision 1.5 retrieving revision 1.5.6.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.5 -r1.5.6.1 --- sys/compat/common/kern_sig_13.c 2000/03/30 11:27:14 1.5 +++ sys/compat/common/kern_sig_13.c 2001/03/05 22:49:19 1.5.6.1 @@ -36,8 +36,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +#include #include #include #include #include @@ -114,17 +115,15 @@ osa->ss_flags = sa->ss_flags; } int -compat_13_sys_sigaltstack(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_13_sys_sigaltstack(struct lwp *l, void *v, register_t *retval) { struct compat_13_sys_sigaltstack_args /* { syscallarg(const struct sigaltstack13 *) nss; syscallarg(struct sigaltstack13 *) oss; } */ *uap = v; + struct proc *p = l->l_proc; struct sigaltstack13 ness, oess; struct sigaltstack nbss, obss; int error; @@ -147,18 +146,16 @@ return (0); } int -compat_13_sys_sigaction(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_13_sys_sigaction(struct lwp *l, void *v, register_t *retval) { struct compat_13_sys_sigaction_args /* { syscallarg(int) signum; syscallarg(const struct sigaction13 *) nsa; syscallarg(struct sigaction13 *) osa; } */ *uap = v; + struct proc *p = l->l_proc; struct sigaction13 nesa, oesa; struct sigaction nbsa, obsa; int error; @@ -181,17 +178,15 @@ return (0); } int -compat_13_sys_sigprocmask(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_13_sys_sigprocmask(struct lwp *l, void *v, register_t *retval) { struct compat_13_sys_sigprocmask_args /* { syscallarg(int) how; syscallarg(int) mask; } */ *uap = v; + struct proc *p = l->l_proc; sigset13_t ness, oess; sigset_t nbss, obss; int error; @@ -205,13 +200,11 @@ return (0); } int -compat_13_sys_sigpending(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_13_sys_sigpending(struct lwp *l, void *v, register_t *retval) { + struct proc *p = l->l_proc; sigset13_t ess; sigset_t bss; sigpending1(p, &bss); @@ -220,16 +213,14 @@ return (0); } int -compat_13_sys_sigsuspend(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_13_sys_sigsuspend(struct lwp *l, void *v, register_t *retval) { struct compat_13_sys_sigsuspend_args /* { syscallarg(sigset13_t) mask; } */ *uap = v; + struct proc *p = l->l_proc; sigset13_t ess; sigset_t bss; ess = SCARG(uap, mask); Index: sys/compat/common/kern_sig_43.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/kern_sig_43.c,v retrieving revision 1.14 retrieving revision 1.14.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.14 -r1.14.2.1 --- sys/compat/common/kern_sig_43.c 2000/12/17 15:55:47 1.14 +++ sys/compat/common/kern_sig_43.c 2001/03/05 22:49:19 1.14.2.1 @@ -44,8 +44,9 @@ #include #include #include #include +#include #include #include #include #include @@ -138,16 +139,14 @@ ss->ss_onstack = 0; } int -compat_43_sys_sigblock(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_sigblock(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_sigblock_args /* { syscallarg(int) mask; } */ *uap = v; + struct proc *p = l->l_proc; int nsm, osm; sigset_t nss, oss; int error; @@ -161,16 +160,14 @@ return (0); } int -compat_43_sys_sigsetmask(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_sigsetmask(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_sigsetmask_args /* { syscallarg(int) mask; } */ *uap = v; + struct proc *p = l->l_proc; int nsm, osm; sigset_t nss, oss; int error; @@ -185,17 +182,15 @@ } /* ARGSUSED */ int -compat_43_sys_sigstack(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_sigstack(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_sigstack_args /* { syscallarg(struct sigstack *) nss; syscallarg(struct sigstack *) oss; } */ *uap = v; + struct proc *p = l->l_proc; struct sigstack nss, oss; struct sigaltstack nsa, osa; int error; @@ -222,18 +217,16 @@ * Generalized interface signal handler, 4.3-compatible. */ /* ARGSUSED */ int -compat_43_sys_sigvec(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_sigvec(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_sigvec_args /* { syscallarg(int) signum; syscallarg(const struct sigvec *) nsv; syscallarg(struct sigvec *) osv; } */ *uap = v; + struct proc *p = l->l_proc; struct sigvec nsv, osv; struct sigaction nsa, osa; int error; @@ -258,17 +251,15 @@ /* ARGSUSED */ int -compat_43_sys_killpg(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_killpg(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_killpg_args /* { syscallarg(int) pgid; syscallarg(int) signum; } */ *uap = v; + struct proc *p = l->l_proc; #ifdef COMPAT_09 SCARG(uap, pgid) = (short) SCARG(uap, pgid); #endif Index: sys/compat/common/kern_xxx_12.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/kern_xxx_12.c,v retrieving revision 1.2 retrieving revision 1.2.34.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.2 -r1.2.34.1 --- sys/compat/common/kern_xxx_12.c 1997/03/26 23:44:27 1.2 +++ sys/compat/common/kern_xxx_12.c 2001/03/05 22:49:19 1.2.34.1 @@ -39,23 +39,22 @@ /*#ifdef COMPAT_12*/ #include #include +#include #include #include #include #include /* ARGSUSED */ int -compat_12_sys_reboot(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_12_sys_reboot(struct lwp *l, void *v, register_t *retval) { struct compat_12_sys_reboot_args /* { syscallarg(int) opt; } */ *uap = v; + struct proc *p = l->l_proc; int error; if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) return (error); Index: sys/compat/common/sysv_msg_14.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/sysv_msg_14.c,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.3 -r1.3.2.1 --- sys/compat/common/sysv_msg_14.c 2000/12/21 19:30:26 1.3 +++ sys/compat/common/sysv_msg_14.c 2001/03/05 22:49:19 1.3.2.1 @@ -39,8 +39,9 @@ #include #include #include +#include #include #include #include @@ -96,18 +97,16 @@ omsqbuf->msg_cbytes = msqbuf->_msg_cbytes; } int -compat_14_sys_msgctl(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_14_sys_msgctl(struct lwp *l, void *v, register_t *retval) { struct compat_14_sys_msgctl_args /* { syscallarg(int) msqid; syscallarg(int) cmd; syscallarg(struct msqid_ds14 *) buf; } */ *uap = v; + struct proc *p = l->l_proc; struct msqid_ds msqbuf; struct msqid_ds14 omsqbuf; int cmd, error; Index: sys/compat/common/sysv_sem_14.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/sysv_sem_14.c,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.3 -r1.3.2.1 --- sys/compat/common/sysv_sem_14.c 2000/12/17 15:55:47 1.3 +++ sys/compat/common/sysv_sem_14.c 2001/03/05 22:49:19 1.3.2.1 @@ -39,8 +39,9 @@ #include #include #include +#include #include #include #include @@ -83,19 +84,17 @@ #undef CVT } int -compat_14_sys___semctl(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_14_sys___semctl(struct lwp *l, void *v, register_t *retval) { struct compat_14_sys___semctl_args /* { syscallarg(int) semid; syscallarg(int) semnum; syscallarg(int) cmd; syscallarg(union __semun *) arg; } */ *uap = v; + struct proc *p = l->l_proc; union __semun arg; struct semid_ds sembuf; struct semid_ds14 osembuf; int cmd, error; Index: sys/compat/common/sysv_shm_14.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/sysv_shm_14.c,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.3 -r1.3.2.1 --- sys/compat/common/sysv_shm_14.c 2000/12/17 15:55:47 1.3 +++ sys/compat/common/sysv_shm_14.c 2001/03/05 22:49:19 1.3.2.1 @@ -39,8 +39,9 @@ #include #include #include +#include #include #include #include @@ -91,18 +92,16 @@ #undef CVT } int -compat_14_sys_shmctl(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_14_sys_shmctl(struct lwp *l, void *v, register_t *retval) { struct compat_14_sys_shmctl_args /* { syscallarg(int) shmid; syscallarg(int) cmd; syscallarg(struct shmid_ds14 *) buf; } */ *uap = v; + struct proc *p = l->l_proc; struct shmid_ds shmbuf; struct shmid_ds14 oshmbuf; int cmd, error; Index: sys/compat/common/uipc_syscalls_43.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/uipc_syscalls_43.c,v retrieving revision 1.11 retrieving revision 1.11.6.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.11 -r1.11.6.1 --- sys/compat/common/uipc_syscalls_43.c 2000/03/30 11:27:15 1.11 +++ sys/compat/common/uipc_syscalls_43.c 2001/03/05 22:49:19 1.11.6.1 @@ -40,8 +40,9 @@ #include #include #include #include +#include #include #include #include #include @@ -56,21 +57,18 @@ #include #include int -compat_43_sys_accept(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_accept(struct lwp *l, void *v, register_t *retval) { struct sys_accept_args /* { syscallarg(int) s; syscallarg(caddr_t) name; syscallarg(int *) anamelen; } */ *uap = v; int error; - if ((error = sys_accept(p, uap, retval)) != 0) + if ((error = sys_accept(l, uap, retval)) != 0) return error; if (SCARG(uap, name)) { struct sockaddr sa; @@ -86,12 +84,9 @@ return 0; } int -compat_43_sys_getpeername(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_getpeername(struct lwp *l, void *v, register_t *retval) { struct sys_getpeername_args /* { syscallarg(int) fdes; syscallarg(caddr_t) asa; @@ -100,9 +95,9 @@ struct sockaddr sa; int error; - if ((error = sys_getpeername(p, uap, retval)) != 0) + if ((error = sys_getpeername(l, uap, retval)) != 0) return error; if ((error = copyin(SCARG(uap, asa), &sa, sizeof(sa))) != 0) return error; @@ -115,12 +110,9 @@ return 0; } int -compat_43_sys_getsockname(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_getsockname(struct lwp *l, void *v, register_t *retval) { struct sys_getsockname_args /* { syscallarg(int) fdes; syscallarg(caddr_t) asa; @@ -128,9 +120,9 @@ } */ *uap = v; struct sockaddr sa; int error; - if ((error = sys_getsockname(p, uap, retval)) != 0) + if ((error = sys_getsockname(l, uap, retval)) != 0) return error; if ((error = copyin(SCARG(uap, asa), &sa, sizeof(sa))) != 0) return error; @@ -143,19 +135,17 @@ return 0; } int -compat_43_sys_recv(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_recv(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_recv_args /* { syscallarg(int) s; syscallarg(caddr_t) buf; syscallarg(int) len; syscallarg(int) flags; } */ *uap = v; + struct proc *p = l->l_proc; struct msghdr msg; struct iovec aiov; msg.msg_name = 0; @@ -169,12 +159,9 @@ return (recvit(p, SCARG(uap, s), &msg, (caddr_t)0, retval)); } int -compat_43_sys_recvfrom(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_recvfrom(struct lwp *l, void *v, register_t *retval) { struct sys_recvfrom_args /* { syscallarg(int) s; syscallarg(caddr_t) buf; @@ -184,27 +171,25 @@ syscallarg(int *) fromlenaddr; } */ *uap = v; SCARG(uap, flags) |= MSG_COMPAT; - return (sys_recvfrom(p, uap, retval)); + return (sys_recvfrom(l, uap, retval)); } /* * Old recvmsg. This code takes advantage of the fact that the old msghdr * overlays the new one, missing only the flags, and with the (old) access * rights where the control fields are now. */ int -compat_43_sys_recvmsg(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_recvmsg(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_recvmsg_args /* { syscallarg(int) s; syscallarg(struct omsghdr *) msg; syscallarg(int) flags; } */ *uap = v; + struct proc *p = l->l_proc; struct msghdr msg; struct iovec aiov[UIO_SMALLIOV], *iov; int error; @@ -238,19 +223,17 @@ return (error); } int -compat_43_sys_send(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_send(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_send_args /* { syscallarg(int) s; syscallarg(caddr_t) buf; syscallarg(int) len; syscallarg(int) flags; } */ *uap = v; + struct proc *p = l->l_proc; struct msghdr msg; struct iovec aiov; msg.msg_name = 0; @@ -264,18 +247,16 @@ return (sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval)); } int -compat_43_sys_sendmsg(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_sendmsg(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_sendmsg_args /* { syscallarg(int) s; syscallarg(caddr_t) msg; syscallarg(int) flags; } */ *uap = v; + struct proc *p = l->l_proc; struct msghdr msg; struct iovec aiov[UIO_SMALLIOV], *iov; int error; Index: sys/compat/common/vfs_syscalls_12.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/vfs_syscalls_12.c,v retrieving revision 1.7 retrieving revision 1.6.6.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.7 -r1.6.6.2 --- sys/compat/common/vfs_syscalls_12.c 2001/04/07 09:00:57 1.7 +++ sys/compat/common/vfs_syscalls_12.c 2001/04/09 01:55:31 1.6.6.2 @@ -49,8 +49,9 @@ #include #include #include #include +#include #include #include #include #include @@ -91,19 +92,17 @@ /* * Read a block of directory entries in a file system independent format. */ int -compat_12_sys_getdirentries(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_12_sys_getdirentries(struct lwp *l, void *v, register_t *retval) { struct compat_12_sys_getdirentries_args /* { syscallarg(int) fd; syscallarg(char *) buf; syscallarg(u_int) count; syscallarg(long *) basep; } */ *uap = v; + struct proc *p = l->l_proc; struct file *fp; int error, done; long loff; @@ -131,17 +130,15 @@ * Get file status; this version follows links. */ /* ARGSUSED */ int -compat_12_sys_stat(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_12_sys_stat(struct lwp *l, void *v, register_t *retval) { struct compat_12_sys_stat_args /* { syscallarg(const char *) path; syscallarg(struct stat12 *) ub; } */ *uap = v; + struct proc *p = l->l_proc; struct stat sb; struct stat12 osb; int error; struct nameidata nd; @@ -164,17 +161,15 @@ * Get file status; this version does not follow links. */ /* ARGSUSED */ int -compat_12_sys_lstat(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_12_sys_lstat(struct lwp *l, void *v, register_t *retval) { struct compat_12_sys_lstat_args /* { syscallarg(const char *) path; syscallarg(struct stat12 *) ub; } */ *uap = v; + struct proc *p = l->l_proc; struct stat sb; struct stat12 osb; int error; struct nameidata nd; @@ -196,17 +191,15 @@ * Return status information about a file descriptor. */ /* ARGSUSED */ int -compat_12_sys_fstat(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_12_sys_fstat(struct lwp *l, void *v, register_t *retval) { struct compat_12_sys_fstat_args /* { syscallarg(int) fd; syscallarg(struct stat12 *) sb; } */ *uap = v; + struct proc *p = l->l_proc; int fd = SCARG(uap, fd); struct filedesc *fdp = p->p_fd; struct file *fp; struct stat ub; Index: sys/compat/common/vfs_syscalls_43.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/vfs_syscalls_43.c,v retrieving revision 1.16 retrieving revision 1.15.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.16 -r1.15.2.2 --- sys/compat/common/vfs_syscalls_43.c 2001/04/07 09:00:57 1.16 +++ sys/compat/common/vfs_syscalls_43.c 2001/04/09 01:55:31 1.15.2.2 @@ -47,8 +47,9 @@ #include #include #include #include +#include #include #include #include #include @@ -101,17 +102,15 @@ * Get file status; this version follows links. */ /* ARGSUSED */ int -compat_43_sys_stat(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_stat(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_stat_args /* { syscallarg(char *) path; syscallarg(struct stat43 *) ub; } */ *uap = v; + struct proc *p = l->l_proc; struct stat sb; struct stat43 osb; int error; struct nameidata nd; @@ -133,17 +132,15 @@ * Get file status; this version does not follow links. */ /* ARGSUSED */ int -compat_43_sys_lstat(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_lstat(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_lstat_args /* { syscallarg(char *) path; syscallarg(struct ostat *) ub; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp, *dvp; struct stat sb, sb1; struct stat43 osb; int error; @@ -207,17 +204,15 @@ * Return status information about a file descriptor. */ /* ARGSUSED */ int -compat_43_sys_fstat(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_fstat(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_fstat_args /* { syscallarg(int) fd; syscallarg(struct stat43 *) sb; } */ *uap = v; + struct proc *p = l->l_proc; int fd = SCARG(uap, fd); struct filedesc *fdp = p->p_fd; struct file *fp; struct stat ub; @@ -247,12 +242,9 @@ * Truncate a file given a file descriptor. */ /* ARGSUSED */ int -compat_43_sys_ftruncate(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_ftruncate(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_ftruncate_args /* { syscallarg(int) fd; syscallarg(long) length; @@ -264,20 +256,17 @@ } */ nuap; SCARG(&nuap, fd) = SCARG(uap, fd); SCARG(&nuap, length) = SCARG(uap, length); - return (sys_ftruncate(p, &nuap, retval)); + return (sys_ftruncate(l, &nuap, retval)); } /* * Truncate a file given its path name. */ /* ARGSUSED */ int -compat_43_sys_truncate(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_truncate(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_truncate_args /* { syscallarg(char *) path; syscallarg(long) length; @@ -289,20 +278,17 @@ } */ nuap; SCARG(&nuap, path) = SCARG(uap, path); SCARG(&nuap, length) = SCARG(uap, length); - return (sys_truncate(p, &nuap, retval)); + return (sys_truncate(l, &nuap, retval)); } /* * Reposition read/write file offset. */ int -compat_43_sys_lseek(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_lseek(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_lseek_args /* { syscallarg(int) fd; syscallarg(long) offset; @@ -319,9 +305,9 @@ SCARG(&nuap, fd) = SCARG(uap, fd); SCARG(&nuap, offset) = SCARG(uap, offset); SCARG(&nuap, whence) = SCARG(uap, whence); - error = sys_lseek(p, &nuap, (register_t *)&qret); + error = sys_lseek(l, &nuap, (register_t *)&qret); *(long *)retval = qret; return (error); } @@ -329,12 +315,9 @@ /* * Create a file. */ int -compat_43_sys_creat(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_creat(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_creat_args /* { syscallarg(char *) path; syscallarg(int) mode; @@ -347,17 +330,14 @@ SCARG(&nuap, path) = SCARG(uap, path); SCARG(&nuap, mode) = SCARG(uap, mode); SCARG(&nuap, flags) = O_WRONLY | O_CREAT | O_TRUNC; - return (sys_open(p, &nuap, retval)); + return (sys_open(l, &nuap, retval)); } /*ARGSUSED*/ int -compat_43_sys_quota(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_quota(struct lwp *l, void *v, register_t *retval) { return (ENOSYS); } @@ -366,19 +346,17 @@ /* * Read a block of directory entries in a file system independent format. */ int -compat_43_sys_getdirentries(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_getdirentries(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_getdirentries_args /* { syscallarg(int) fd; syscallarg(char *) buf; syscallarg(u_int) count; syscallarg(long *) basep; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; struct file *fp; struct uio auio, kuio; struct iovec aiov, kiov; Index: sys/compat/common/vm_12.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/vm_12.c,v retrieving revision 1.9 retrieving revision 1.9.24.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.9 -r1.9.24.1 --- sys/compat/common/vm_12.c 1998/08/29 17:01:15 1.9 +++ sys/compat/common/vm_12.c 2001/03/05 22:49:19 1.9.24.1 @@ -36,12 +36,9 @@ #include #include int -compat_12_sys_swapon(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_12_sys_swapon(struct lwp *l, void *v, register_t *retval) { struct sys_swapctl_args ua; struct compat_12_sys_swapon_args /* { syscallarg(const char *) name; @@ -49,16 +46,13 @@ SCARG(&ua, cmd) = SWAP_ON; SCARG(&ua, arg) = (void *)SCARG(uap, name); SCARG(&ua, misc) = 0; /* priority */ - return (sys_swapctl(p, &ua, retval)); + return (sys_swapctl(l, &ua, retval)); } int -compat_12_sys_msync(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_12_sys_msync(struct lwp *l, void *v, register_t *retval) { struct sys___msync13_args ua; struct compat_12_sys_msync_args /* { syscallarg(caddr_t) addr; @@ -67,6 +61,6 @@ SCARG(&ua, addr) = SCARG(uap, addr);; SCARG(&ua, len) = SCARG(uap, len);; SCARG(&ua, flags) = MS_SYNC | MS_INVALIDATE; - return (sys___msync13(p, &ua, retval)); + return (sys___msync13(l, &ua, retval)); } Index: sys/compat/common/vm_43.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/common/vm_43.c,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.6 -r1.6.2.1 --- sys/compat/common/vm_43.c 2000/06/28 15:39:25 1.6 +++ sys/compat/common/vm_43.c 2001/03/05 22:49:19 1.6.2.1 @@ -49,8 +49,9 @@ #include #include #include #include +#include #include #include #include #include @@ -61,23 +62,17 @@ #include /* ARGSUSED */ int -compat_43_sys_getpagesize(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_getpagesize(struct lwp *l, void *v, register_t *retval) { *retval = PAGE_SIZE; return (0); } int -compat_43_sys_mmap(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +compat_43_sys_mmap(struct lwp *l, void *v, register_t *retval) { struct compat_43_sys_mmap_args /* { syscallarg(caddr_t) addr; syscallarg(size_t) len; @@ -128,6 +123,6 @@ if (SCARG(uap, flags) & OMAP_INHERIT) SCARG(&nargs, flags) |= MAP_INHERIT; SCARG(&nargs, fd) = SCARG(uap, fd); SCARG(&nargs, pos) = SCARG(uap, pos); - return (sys_mmap(p, &nargs, retval)); + return (sys_mmap(l, &nargs, retval)); } Index: sys/compat/freebsd/freebsd_exec.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/freebsd/freebsd_exec.h,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.6 -r1.6.2.1 --- sys/compat/freebsd/freebsd_exec.h 2000/11/21 00:37:53 1.6 +++ sys/compat/freebsd/freebsd_exec.h 2001/03/05 22:49:20 1.6.2.1 @@ -108,9 +108,9 @@ int freebsd_elf32_probe __P((struct proc *, struct exec_package *, void *, char *, vaddr_t *)); #endif /* EXEC_ELF32 */ -void freebsd_setregs __P((struct proc *, struct exec_package *, u_long)); +void freebsd_setregs __P((struct lwp *, struct exec_package *, u_long)); extern char freebsd_sigcode[], freebsd_esigcode[]; extern const struct emul emul_freebsd; Index: sys/compat/freebsd/freebsd_file.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/freebsd/freebsd_file.c,v retrieving revision 1.13 retrieving revision 1.13.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.13 -r1.13.2.1 --- sys/compat/freebsd/freebsd_file.c 2001/01/22 20:08:04 1.13 +++ sys/compat/freebsd/freebsd_file.c 2001/03/05 22:49:20 1.13.2.1 @@ -39,8 +39,9 @@ #include #include #include +#include #include #include #include #include @@ -90,10 +91,10 @@ return (netbsd_mount_type[type]); } int -freebsd_sys_mount(p, v, retval) - struct proc *p; +freebsd_sys_mount(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_mount_args /* { @@ -101,8 +102,9 @@ syscallarg(char *) path; syscallarg(int) flags; syscallarg(caddr_t) data; } */ *uap = v; + struct proc *p = l->l_proc; int error; const char *type; char *s; caddr_t sg = stackgap_init(p->p_emul); @@ -117,9 +119,9 @@ CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); SCARG(&bma, path) = SCARG(uap, path); SCARG(&bma, flags) = SCARG(uap, flags); SCARG(&bma, data) = SCARG(uap, data); - return sys_mount(p, &bma, retval); + return sys_mount(l, &bma, retval); } /* * The following syscalls are only here because of the alternate path check. @@ -129,297 +131,315 @@ /* XXX - UNIX domain: int freebsd_sys_connect(int s, caddr_t name, int namelen); */ int -freebsd_sys_open(p, v, retval) - struct proc *p; +freebsd_sys_open(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_open_args /* { syscallarg(char *) path; syscallarg(int) flags; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); if (SCARG(uap, flags) & O_CREAT) CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); else CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_open(p, uap, retval); + return sys_open(l, uap, retval); } int -compat_43_freebsd_sys_creat(p, v, retval) - struct proc *p; +compat_43_freebsd_sys_creat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct compat_43_freebsd_sys_creat_args /* { syscallarg(char *) path; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); - return compat_43_sys_creat(p, uap, retval); + return compat_43_sys_creat(l, uap, retval); } int -freebsd_sys_link(p, v, retval) - struct proc *p; +freebsd_sys_link(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_link_args /* { syscallarg(char *) path; syscallarg(char *) link; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); CHECK_ALT_CREAT(p, &sg, SCARG(uap, link)); - return sys_link(p, uap, retval); + return sys_link(l, uap, retval); } int -freebsd_sys_unlink(p, v, retval) - struct proc *p; +freebsd_sys_unlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_unlink_args /* { syscallarg(char *) path; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_unlink(p, uap, retval); + return sys_unlink(l, uap, retval); } int -freebsd_sys_chdir(p, v, retval) - struct proc *p; +freebsd_sys_chdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_chdir_args /* { syscallarg(char *) path; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_chdir(p, uap, retval); + return sys_chdir(l, uap, retval); } int -freebsd_sys_mknod(p, v, retval) - struct proc *p; +freebsd_sys_mknod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_mknod_args /* { syscallarg(char *) path; syscallarg(int) mode; syscallarg(int) dev; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); - return sys_mknod(p, uap, retval); + return sys_mknod(l, uap, retval); } int -freebsd_sys_chmod(p, v, retval) - struct proc *p; +freebsd_sys_chmod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_chmod_args /* { syscallarg(char *) path; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_chmod(p, uap, retval); + return sys_chmod(l, uap, retval); } int -freebsd_sys_chown(p, v, retval) - struct proc *p; +freebsd_sys_chown(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_chown_args /* { syscallarg(char *) path; syscallarg(int) uid; syscallarg(int) gid; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_chown(p, uap, retval); + return sys_chown(l, uap, retval); } int -freebsd_sys_lchown(p, v, retval) - struct proc *p; +freebsd_sys_lchown(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_lchown_args /* { syscallarg(char *) path; syscallarg(int) uid; syscallarg(int) gid; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path)); - return sys_lchown(p, uap, retval); + return sys_lchown(l, uap, retval); } int -freebsd_sys_unmount(p, v, retval) - struct proc *p; +freebsd_sys_unmount(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_unmount_args /* { syscallarg(char *) path; syscallarg(int) flags; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_unmount(p, uap, retval); + return sys_unmount(l, uap, retval); } int -freebsd_sys_access(p, v, retval) - struct proc *p; +freebsd_sys_access(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_access_args /* { syscallarg(char *) path; syscallarg(int) flags; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_access(p, uap, retval); + return sys_access(l, uap, retval); } int -freebsd_sys_chflags(p, v, retval) - struct proc *p; +freebsd_sys_chflags(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_chflags_args /* { syscallarg(char *) path; syscallarg(int) flags; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_chflags(p, uap, retval); + return sys_chflags(l, uap, retval); } int -compat_43_freebsd_sys_stat(p, v, retval) - struct proc *p; +compat_43_freebsd_sys_stat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct compat_43_freebsd_sys_stat_args /* { syscallarg(char *) path; syscallarg(struct stat43 *) ub; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return compat_43_sys_stat(p, uap, retval); + return compat_43_sys_stat(l, uap, retval); } int -compat_43_freebsd_sys_lstat(p, v, retval) - struct proc *p; +compat_43_freebsd_sys_lstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct compat_43_freebsd_sys_lstat_args /* { syscallarg(char *) path; syscallarg(struct stat43 *) ub; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return compat_43_sys_lstat(p, uap, retval); + return compat_43_sys_lstat(l, uap, retval); } int -freebsd_sys_revoke(p, v, retval) - struct proc *p; +freebsd_sys_revoke(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_revoke_args /* { syscallarg(char *) path; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_revoke(p, uap, retval); + return sys_revoke(l, uap, retval); } int -freebsd_sys_symlink(p, v, retval) - struct proc *p; +freebsd_sys_symlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_symlink_args /* { syscallarg(char *) path; syscallarg(char *) link; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); CHECK_ALT_CREAT(p, &sg, SCARG(uap, link)); - return sys_symlink(p, uap, retval); + return sys_symlink(l, uap, retval); } int -freebsd_sys_readlink(p, v, retval) - struct proc *p; +freebsd_sys_readlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_readlink_args /* { syscallarg(char *) path; syscallarg(char *) buf; syscallarg(int) count; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path)); - return sys_readlink(p, uap, retval); + return sys_readlink(l, uap, retval); } int -freebsd_sys_execve(p, v, retval) - struct proc *p; +freebsd_sys_execve(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_execve_args /* { syscallarg(char *) path; syscallarg(char **) argp; syscallarg(char **) envp; } */ *uap = v; + struct proc *p = l->l_proc; struct sys_execve_args ap; caddr_t sg; sg = stackgap_init(p->p_emul); @@ -428,200 +448,212 @@ SCARG(&ap, path) = SCARG(uap, path); SCARG(&ap, argp) = SCARG(uap, argp); SCARG(&ap, envp) = SCARG(uap, envp); - return sys_execve(p, &ap, retval); + return sys_execve(l, &ap, retval); } int -freebsd_sys_chroot(p, v, retval) - struct proc *p; +freebsd_sys_chroot(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_chroot_args /* { syscallarg(char *) path; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_chroot(p, uap, retval); + return sys_chroot(l, uap, retval); } int -freebsd_sys_rename(p, v, retval) - struct proc *p; +freebsd_sys_rename(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_rename_args /* { syscallarg(char *) from; syscallarg(char *) to; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, from)); CHECK_ALT_CREAT(p, &sg, SCARG(uap, to)); - return sys_rename(p, uap, retval); + return sys_rename(l, uap, retval); } int -compat_43_freebsd_sys_truncate(p, v, retval) - struct proc *p; +compat_43_freebsd_sys_truncate(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct compat_43_freebsd_sys_truncate_args /* { syscallarg(char *) path; syscallarg(long) length; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return compat_43_sys_truncate(p, uap, retval); + return compat_43_sys_truncate(l, uap, retval); } int -freebsd_sys_mkfifo(p, v, retval) - struct proc *p; +freebsd_sys_mkfifo(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_mkfifo_args /* { syscallarg(char *) path; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); - return sys_mkfifo(p, uap, retval); + return sys_mkfifo(l, uap, retval); } int -freebsd_sys_mkdir(p, v, retval) - struct proc *p; +freebsd_sys_mkdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_mkdir_args /* { syscallarg(char *) path; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); - return sys_mkdir(p, uap, retval); + return sys_mkdir(l, uap, retval); } int -freebsd_sys_rmdir(p, v, retval) - struct proc *p; +freebsd_sys_rmdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_rmdir_args /* { syscallarg(char *) path; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_rmdir(p, uap, retval); + return sys_rmdir(l, uap, retval); } int -freebsd_sys_statfs(p, v, retval) - struct proc *p; +freebsd_sys_statfs(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_stat_args /* { syscallarg(char *) path; syscallarg(struct statfs *) buf; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_statfs(p, uap, retval); + return sys_statfs(l, uap, retval); } #ifdef NFS int -freebsd_sys_getfh(p, v, retval) - struct proc *p; +freebsd_sys_getfh(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_getfh_args /* { syscallarg(char *) fname; syscallarg(fhandle_t *) fhp; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, fname)); - return sys_getfh(p, uap, retval); + return sys_getfh(l, uap, retval); } #endif /* NFS */ int -freebsd_sys_stat(p, v, retval) - struct proc *p; +freebsd_sys_stat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_stat_args /* { syscallarg(char *) path; syscallarg(struct stat12 *) ub; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return compat_12_sys_stat(p, uap, retval); + return compat_12_sys_stat(l, uap, retval); } int -freebsd_sys_lstat(p, v, retval) - struct proc *p; +freebsd_sys_lstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_lstat_args /* { syscallarg(char *) path; syscallarg(struct stat12 *) ub; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return compat_12_sys_lstat(p, uap, retval); + return compat_12_sys_lstat(l, uap, retval); } int -freebsd_sys_pathconf(p, v, retval) - struct proc *p; +freebsd_sys_pathconf(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_pathconf_args /* { syscallarg(char *) path; syscallarg(int) name; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_pathconf(p, uap, retval); + return sys_pathconf(l, uap, retval); } int -freebsd_sys_truncate(p, v, retval) - struct proc *p; +freebsd_sys_truncate(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_truncate_args /* { syscallarg(char *) path; syscallarg(int) pad; syscallarg(off_t) length; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_truncate(p, uap, retval); + return sys_truncate(l, uap, retval); } Index: sys/compat/freebsd/freebsd_ioctl.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/freebsd/freebsd_ioctl.c,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.5 -r1.5.2.1 --- sys/compat/freebsd/freebsd_ioctl.c 2000/12/01 12:28:31 1.5 +++ sys/compat/freebsd/freebsd_ioctl.c 2001/03/05 22:49:20 1.5.2.1 @@ -32,8 +32,9 @@ */ #include #include +#include #include #include #include @@ -108,18 +109,19 @@ SCARG(nap, data) = SCARG(uap, data); } int -freebsd_sys_ioctl(p, v, retval) - struct proc *p; +freebsd_sys_ioctl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_ioctl_args /* { syscallarg(int) fd; syscallarg(u_long) com; syscallarg(caddr_t) data; } */ *uap = v; + struct proc *p = l->l_proc; struct oss_sys_ioctl_args ap; struct sys_ioctl_args nap; /* @@ -142,9 +144,9 @@ freebsd_to_oss(uap, &ap); return oss_ioctl_audio(p, &ap, retval); case 'i': freebsd_to_netbsd_ifioctl(uap, &nap); - return sys_ioctl(p, &nap, retval); + return sys_ioctl(l, &nap, retval); default: - return sys_ioctl(p, uap, retval); + return sys_ioctl(l, uap, retval); } } Index: sys/compat/freebsd/freebsd_ipc.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/freebsd/freebsd_ipc.c,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.8 -r1.8.2.1 --- sys/compat/freebsd/freebsd_ipc.c 2000/11/29 22:05:35 1.8 +++ sys/compat/freebsd/freebsd_ipc.c 2001/03/05 22:49:20 1.8.2.1 @@ -47,10 +47,10 @@ #include #ifdef SYSVSEM int -freebsd_sys_semsys(p, v, retval) - struct proc *p; +freebsd_sys_semsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_semsys_args /* { @@ -85,25 +85,25 @@ SCARG(&__semctl_args, semid) = SCARG(uap, a2); SCARG(&__semctl_args, semnum) = SCARG(uap, a3); SCARG(&__semctl_args, cmd) = SCARG(uap, a4); SCARG(&__semctl_args, arg) = (union __semun *)SCARG(uap, a5); - return (compat_14_sys___semctl(p, &__semctl_args, retval)); + return (compat_14_sys___semctl(l, &__semctl_args, retval)); case 1: /* semget() */ SCARG(&semget_args, key) = SCARG(uap, a2); SCARG(&semget_args, nsems) = SCARG(uap, a3); SCARG(&semget_args, semflg) = SCARG(uap, a4); - return (sys_semget(p, &semget_args, retval)); + return (sys_semget(l, &semget_args, retval)); case 2: /* semop() */ SCARG(&semop_args, semid) = SCARG(uap, a2); SCARG(&semop_args, sops) = (struct sembuf *)SCARG(uap, a3); SCARG(&semop_args, nsops) = SCARG(uap, a4); - return (sys_semop(p, &semop_args, retval)); + return (sys_semop(l, &semop_args, retval)); case 3: /* semconfig() */ SCARG(&semconfig_args, flag) = SCARG(uap, a2); - return (sys_semconfig(p, &semconfig_args, retval)); + return (sys_semconfig(l, &semconfig_args, retval)); default: return (EINVAL); } @@ -111,10 +111,10 @@ #endif #ifdef SYSVSHM int -freebsd_sys_shmsys(p, v, retval) - struct proc *p; +freebsd_sys_shmsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_shmsys_args /* { @@ -146,29 +146,29 @@ case 0: /* shmat() */ SCARG(&shmat_args, shmid) = SCARG(uap, a2); SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a3); SCARG(&shmat_args, shmflg) = SCARG(uap, a4); - return (sys_shmat(p, &shmat_args, retval)); + return (sys_shmat(l, &shmat_args, retval)); case 1: /* oshmctl() */ /* XXX Need to translate shmid_ds format. */ return (EINVAL); case 2: /* shmdt() */ SCARG(&shmdt_args, shmaddr) = (void *)SCARG(uap, a2); - return (sys_shmdt(p, &shmdt_args, retval)); + return (sys_shmdt(l, &shmdt_args, retval)); case 3: /* shmget() */ SCARG(&shmget_args, key) = SCARG(uap, a2); SCARG(&shmget_args, size) = SCARG(uap, a3); SCARG(&shmget_args, shmflg) = SCARG(uap, a4); - return (sys_shmget(p, &shmget_args, retval)); + return (sys_shmget(l, &shmget_args, retval)); case 4: /* shmctl() */ SCARG(&shmctl_args, shmid) = SCARG(uap, a2); SCARG(&shmctl_args, cmd) = SCARG(uap, a3); SCARG(&shmctl_args, buf) = (struct shmid_ds14 *)SCARG(uap, a4); - return (compat_14_sys_shmctl(p, &shmctl_args, retval)); + return (compat_14_sys_shmctl(l, &shmctl_args, retval)); default: return (EINVAL); } @@ -176,10 +176,10 @@ #endif #ifdef SYSVMSG int -freebsd_sys_msgsys(p, v, retval) - struct proc *p; +freebsd_sys_msgsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_msgsys_args /* { @@ -218,29 +218,29 @@ SCARG(&msgctl_args, msqid) = SCARG(uap, a2); SCARG(&msgctl_args, cmd) = SCARG(uap, a3); SCARG(&msgctl_args, buf) = (struct msqid_ds14 *)SCARG(uap, a4); - return (compat_14_sys_msgctl(p, &msgctl_args, retval)); + return (compat_14_sys_msgctl(l, &msgctl_args, retval)); case 1: /* msgget() */ SCARG(&msgget_args, key) = SCARG(uap, a2); SCARG(&msgget_args, msgflg) = SCARG(uap, a3); - return (sys_msgget(p, &msgget_args, retval)); + return (sys_msgget(l, &msgget_args, retval)); case 2: /* msgsnd() */ SCARG(&msgsnd_args, msqid) = SCARG(uap, a2); SCARG(&msgsnd_args, msgp) = (void *)SCARG(uap, a3); SCARG(&msgsnd_args, msgsz) = SCARG(uap, a4); SCARG(&msgsnd_args, msgflg) = SCARG(uap, a5); - return (sys_msgsnd(p, &msgsnd_args, retval)); + return (sys_msgsnd(l, &msgsnd_args, retval)); case 3: /* msgrcv() */ SCARG(&msgrcv_args, msqid) = SCARG(uap, a2); SCARG(&msgrcv_args, msgp) = (void *)SCARG(uap, a3); SCARG(&msgrcv_args, msgsz) = SCARG(uap, a4); SCARG(&msgrcv_args, msgtyp) = SCARG(uap, a5); SCARG(&msgrcv_args, msgflg) = SCARG(uap, a6); - return (sys_msgrcv(p, &msgrcv_args, retval)); + return (sys_msgrcv(l, &msgrcv_args, retval)); default: return (EINVAL); } Index: sys/compat/freebsd/freebsd_misc.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/freebsd/freebsd_misc.c,v retrieving revision 1.12 retrieving revision 1.12.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.12 -r1.12.2.1 --- sys/compat/freebsd/freebsd_misc.c 2000/12/28 11:18:01 1.12 +++ sys/compat/freebsd/freebsd_misc.c 2001/03/05 22:49:20 1.12.2.1 @@ -41,8 +41,9 @@ #endif #include #include +#include #include #include #include #include @@ -59,10 +60,10 @@ #include #include int -freebsd_sys_msync(p, v, retval) - struct proc *p; +freebsd_sys_msync(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_msync_args /* { @@ -79,16 +80,16 @@ */ SCARG(&bma, addr) = SCARG(uap, addr); SCARG(&bma, len) = SCARG(uap, len); SCARG(&bma, flags) = SCARG(uap, flags); - return sys___msync13(p, &bma, retval); + return sys___msync13(l, &bma, retval); } /* just a place holder */ int -freebsd_sys_rtprio(p, v, retval) - struct proc *p; +freebsd_sys_rtprio(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #ifdef notyet @@ -103,10 +104,10 @@ } #ifdef NTP int -freebsd_ntp_adjtime(p, v, retval) - struct proc *p; +freebsd_ntp_adjtime(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #ifdef notyet @@ -119,18 +120,19 @@ } #endif int -freebsd_sys_sigaction4(p, v, retval) - struct proc *p; +freebsd_sys_sigaction4(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_sigaction4_args /* { syscallarg(int) signum; syscallarg(const struct freebsd_sigaction4 *) nsa; syscallarg(struct freebsd_sigaction4 *) osa; } */ *uap = v; + struct proc *p = l->l_proc; struct freebsd_sigaction4 nesa, oesa; struct sigaction nbsa, obsa; int error; @@ -157,18 +159,19 @@ return (0); } int -freebsd_sys_utrace(p, v, retval) - struct proc *p; +freebsd_sys_utrace(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #ifdef KTRACE struct freebsd_sys_utrace_args /* { syscallarg(void *) addr; syscallarg(size_t) len; } */ *uap = v; + struct proc *p = l->l_proc; if (KTRPOINT(p, KTR_USER)) ktruser(p, "FreeBSD utrace", SCARG(uap, addr), SCARG(uap, len), 0); Index: sys/compat/freebsd/freebsd_ptrace.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/freebsd/freebsd_ptrace.c,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.3 -r1.3.2.1 --- sys/compat/freebsd/freebsd_ptrace.c 2000/12/01 12:28:31 1.3 +++ sys/compat/freebsd/freebsd_ptrace.c 2001/03/05 22:49:20 1.3.2.1 @@ -42,8 +42,9 @@ */ #include #include +#include #include #include #include #include @@ -61,10 +62,10 @@ /* * Process debugging system call. */ int -freebsd_sys_ptrace(p, v, retval) - struct proc *p; +freebsd_sys_ptrace(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct freebsd_sys_ptrace_args /* { @@ -72,8 +73,9 @@ syscallarg(pid_t) pid; syscallarg(caddr_t) addr; syscallarg(int) data; } */ *uap = v; + struct proc *p = l->l_proc; int error; caddr_t sg; struct { struct reg regs; @@ -88,9 +90,9 @@ SCARG(&npa, req) = PT_STEP; SCARG(&npa, pid) = SCARG(uap, pid); SCARG(&npa, addr) = SCARG(uap, addr); SCARG(&npa, data) = SCARG(uap, data); - return sys_ptrace(p, &npa, retval); + return sys_ptrace(l, &npa, retval); #endif case FREEBSD_PT_TRACE_ME: case FREEBSD_PT_READ_I: case FREEBSD_PT_READ_D: @@ -98,9 +100,9 @@ case FREEBSD_PT_WRITE_D: case FREEBSD_PT_CONTINUE: case FREEBSD_PT_KILL: /* These requests are compatible with NetBSD */ - return sys_ptrace(p, uap, retval); + return sys_ptrace(l, uap, retval); case FREEBSD_PT_READ_U: case FREEBSD_PT_WRITE_U: sg = stackgap_init(p->p_emul); @@ -108,16 +110,16 @@ #ifdef PT_GETREGS SCARG(&npa, req) = PT_GETREGS; SCARG(&npa, pid) = SCARG(uap, pid); SCARG(&npa, addr) = (caddr_t)&nrp->regs; - if ((error = sys_ptrace(p, &npa, retval)) != 0) + if ((error = sys_ptrace(l, &npa, retval)) != 0) return error; #endif #ifdef PT_GETFPREGS SCARG(&npa, req) = PT_GETFPREGS; SCARG(&npa, pid) = SCARG(uap, pid); SCARG(&npa, addr) = (caddr_t)&nrp->fpregs; - if ((error = sys_ptrace(p, &npa, retval)) != 0) + if ((error = sys_ptrace(l, &npa, retval)) != 0) return error; #endif netbsd_to_freebsd_ptrace_regs(&nrp->regs, &nrp->fpregs, &fr); switch (SCARG(uap, req)) { @@ -135,16 +137,16 @@ #ifdef PT_SETREGS SCARG(&npa, req) = PT_SETREGS; SCARG(&npa, pid) = SCARG(uap, pid); SCARG(&npa, addr) = (caddr_t)&nrp->regs; - if ((error = sys_ptrace(p, &npa, retval)) != 0) + if ((error = sys_ptrace(l, &npa, retval)) != 0) return error; #endif #ifdef PT_SETFPREGS SCARG(&npa, req) = PT_SETFPREGS; SCARG(&npa, pid) = SCARG(uap, pid); SCARG(&npa, addr) = (caddr_t)&nrp->fpregs; - if ((error = sys_ptrace(p, &npa, retval)) != 0) + if ((error = sys_ptrace(l, &npa, retval)) != 0) return error; #endif return 0; } Index: sys/compat/freebsd/freebsd_syscallargs.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/freebsd/freebsd_syscallargs.h,v retrieving revision 1.44 retrieving revision 1.44.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.44 -r1.44.2.1 --- sys/compat/freebsd/freebsd_syscallargs.h 2001/01/27 07:25:03 1.44 +++ sys/compat/freebsd/freebsd_syscallargs.h 2001/03/05 22:49:20 1.44.2.1 @@ -260,267 +260,267 @@ /* * System call prototypes. */ -int sys_nosys(struct proc *, void *, register_t *); -int sys_exit(struct proc *, void *, register_t *); -int sys_fork(struct proc *, void *, register_t *); -int sys_read(struct proc *, void *, register_t *); -int sys_write(struct proc *, void *, register_t *); -int freebsd_sys_open(struct proc *, void *, register_t *); -int sys_close(struct proc *, void *, register_t *); -int sys_wait4(struct proc *, void *, register_t *); -int compat_43_freebsd_sys_creat(struct proc *, void *, register_t *); -int freebsd_sys_link(struct proc *, void *, register_t *); -int freebsd_sys_unlink(struct proc *, void *, register_t *); -int freebsd_sys_chdir(struct proc *, void *, register_t *); -int sys_fchdir(struct proc *, void *, register_t *); -int freebsd_sys_mknod(struct proc *, void *, register_t *); -int freebsd_sys_chmod(struct proc *, void *, register_t *); -int freebsd_sys_chown(struct proc *, void *, register_t *); -int sys_obreak(struct proc *, void *, register_t *); -int sys_getfsstat(struct proc *, void *, register_t *); -int compat_43_sys_lseek(struct proc *, void *, register_t *); -int sys_getpid_with_ppid(struct proc *, void *, register_t *); -int freebsd_sys_mount(struct proc *, void *, register_t *); -int freebsd_sys_unmount(struct proc *, void *, register_t *); -int sys_setuid(struct proc *, void *, register_t *); -int sys_getuid_with_euid(struct proc *, void *, register_t *); -int sys_geteuid(struct proc *, void *, register_t *); -int freebsd_sys_ptrace(struct proc *, void *, register_t *); -int sys_recvmsg(struct proc *, void *, register_t *); -int sys_sendmsg(struct proc *, void *, register_t *); -int sys_recvfrom(struct proc *, void *, register_t *); -int sys_accept(struct proc *, void *, register_t *); -int sys_getpeername(struct proc *, void *, register_t *); -int sys_getsockname(struct proc *, void *, register_t *); -int freebsd_sys_access(struct proc *, void *, register_t *); -int freebsd_sys_chflags(struct proc *, void *, register_t *); -int sys_fchflags(struct proc *, void *, register_t *); -int sys_sync(struct proc *, void *, register_t *); -int sys_kill(struct proc *, void *, register_t *); -int compat_43_freebsd_sys_stat(struct proc *, void *, register_t *); -int sys_getppid(struct proc *, void *, register_t *); -int compat_43_freebsd_sys_lstat(struct proc *, void *, register_t *); -int sys_dup(struct proc *, void *, register_t *); -int sys_pipe(struct proc *, void *, register_t *); -int sys_getegid(struct proc *, void *, register_t *); -int sys_profil(struct proc *, void *, register_t *); +int sys_nosys(struct lwp *, void *, register_t *); +int sys_exit(struct lwp *, void *, register_t *); +int sys_fork(struct lwp *, void *, register_t *); +int sys_read(struct lwp *, void *, register_t *); +int sys_write(struct lwp *, void *, register_t *); +int freebsd_sys_open(struct lwp *, void *, register_t *); +int sys_close(struct lwp *, void *, register_t *); +int sys_wait4(struct lwp *, void *, register_t *); +int compat_43_freebsd_sys_creat(struct lwp *, void *, register_t *); +int freebsd_sys_link(struct lwp *, void *, register_t *); +int freebsd_sys_unlink(struct lwp *, void *, register_t *); +int freebsd_sys_chdir(struct lwp *, void *, register_t *); +int sys_fchdir(struct lwp *, void *, register_t *); +int freebsd_sys_mknod(struct lwp *, void *, register_t *); +int freebsd_sys_chmod(struct lwp *, void *, register_t *); +int freebsd_sys_chown(struct lwp *, void *, register_t *); +int sys_obreak(struct lwp *, void *, register_t *); +int sys_getfsstat(struct lwp *, void *, register_t *); +int compat_43_sys_lseek(struct lwp *, void *, register_t *); +int sys_getpid_with_ppid(struct lwp *, void *, register_t *); +int freebsd_sys_mount(struct lwp *, void *, register_t *); +int freebsd_sys_unmount(struct lwp *, void *, register_t *); +int sys_setuid(struct lwp *, void *, register_t *); +int sys_getuid_with_euid(struct lwp *, void *, register_t *); +int sys_geteuid(struct lwp *, void *, register_t *); +int freebsd_sys_ptrace(struct lwp *, void *, register_t *); +int sys_recvmsg(struct lwp *, void *, register_t *); +int sys_sendmsg(struct lwp *, void *, register_t *); +int sys_recvfrom(struct lwp *, void *, register_t *); +int sys_accept(struct lwp *, void *, register_t *); +int sys_getpeername(struct lwp *, void *, register_t *); +int sys_getsockname(struct lwp *, void *, register_t *); +int freebsd_sys_access(struct lwp *, void *, register_t *); +int freebsd_sys_chflags(struct lwp *, void *, register_t *); +int sys_fchflags(struct lwp *, void *, register_t *); +int sys_sync(struct lwp *, void *, register_t *); +int sys_kill(struct lwp *, void *, register_t *); +int compat_43_freebsd_sys_stat(struct lwp *, void *, register_t *); +int sys_getppid(struct lwp *, void *, register_t *); +int compat_43_freebsd_sys_lstat(struct lwp *, void *, register_t *); +int sys_dup(struct lwp *, void *, register_t *); +int sys_pipe(struct lwp *, void *, register_t *); +int sys_getegid(struct lwp *, void *, register_t *); +int sys_profil(struct lwp *, void *, register_t *); #ifdef KTRACE -int sys_ktrace(struct proc *, void *, register_t *); +int sys_ktrace(struct lwp *, void *, register_t *); #else #endif -int compat_13_sys_sigaction(struct proc *, void *, register_t *); -int sys_getgid_with_egid(struct proc *, void *, register_t *); -int compat_13_sys_sigprocmask(struct proc *, void *, register_t *); -int sys___getlogin(struct proc *, void *, register_t *); -int sys_setlogin(struct proc *, void *, register_t *); -int sys_acct(struct proc *, void *, register_t *); -int compat_13_sys_sigpending(struct proc *, void *, register_t *); -int compat_13_sys_sigaltstack(struct proc *, void *, register_t *); -int freebsd_sys_ioctl(struct proc *, void *, register_t *); -int sys_reboot(struct proc *, void *, register_t *); -int freebsd_sys_revoke(struct proc *, void *, register_t *); -int freebsd_sys_symlink(struct proc *, void *, register_t *); -int freebsd_sys_readlink(struct proc *, void *, register_t *); -int freebsd_sys_execve(struct proc *, void *, register_t *); -int sys_umask(struct proc *, void *, register_t *); -int freebsd_sys_chroot(struct proc *, void *, register_t *); -int compat_43_sys_fstat(struct proc *, void *, register_t *); -int compat_43_sys_getkerninfo(struct proc *, void *, register_t *); -int compat_43_sys_getpagesize(struct proc *, void *, register_t *); -int freebsd_sys_msync(struct proc *, void *, register_t *); -int sys_vfork(struct proc *, void *, register_t *); -int sys_sbrk(struct proc *, void *, register_t *); -int sys_sstk(struct proc *, void *, register_t *); -int compat_43_sys_mmap(struct proc *, void *, register_t *); -int sys_ovadvise(struct proc *, void *, register_t *); -int sys_munmap(struct proc *, void *, register_t *); -int sys_mprotect(struct proc *, void *, register_t *); -int sys_madvise(struct proc *, void *, register_t *); -int sys_mincore(struct proc *, void *, register_t *); -int sys_getgroups(struct proc *, void *, register_t *); -int sys_setgroups(struct proc *, void *, register_t *); -int sys_getpgrp(struct proc *, void *, register_t *); -int sys_setpgid(struct proc *, void *, register_t *); -int sys_setitimer(struct proc *, void *, register_t *); -int compat_43_sys_wait(struct proc *, void *, register_t *); -int compat_12_sys_swapon(struct proc *, void *, register_t *); -int sys_getitimer(struct proc *, void *, register_t *); -int compat_43_sys_gethostname(struct proc *, void *, register_t *); -int compat_43_sys_sethostname(struct proc *, void *, register_t *); -int compat_43_sys_getdtablesize(struct proc *, void *, register_t *); -int sys_dup2(struct proc *, void *, register_t *); -int sys_fcntl(struct proc *, void *, register_t *); -int sys_select(struct proc *, void *, register_t *); -int sys_fsync(struct proc *, void *, register_t *); -int sys_setpriority(struct proc *, void *, register_t *); -int sys_socket(struct proc *, void *, register_t *); -int sys_connect(struct proc *, void *, register_t *); -int compat_43_sys_accept(struct proc *, void *, register_t *); -int sys_getpriority(struct proc *, void *, register_t *); -int compat_43_sys_send(struct proc *, void *, register_t *); -int compat_43_sys_recv(struct proc *, void *, register_t *); -int freebsd_sys_sigreturn(struct proc *, void *, register_t *); -int sys_bind(struct proc *, void *, register_t *); -int sys_setsockopt(struct proc *, void *, register_t *); -int sys_listen(struct proc *, void *, register_t *); -int compat_43_sys_sigvec(struct proc *, void *, register_t *); -int compat_43_sys_sigblock(struct proc *, void *, register_t *); -int compat_43_sys_sigsetmask(struct proc *, void *, register_t *); -int compat_13_sys_sigsuspend(struct proc *, void *, register_t *); -int compat_43_sys_sigstack(struct proc *, void *, register_t *); -int compat_43_sys_recvmsg(struct proc *, void *, register_t *); -int compat_43_sys_sendmsg(struct proc *, void *, register_t *); +int compat_13_sys_sigaction(struct lwp *, void *, register_t *); +int sys_getgid_with_egid(struct lwp *, void *, register_t *); +int compat_13_sys_sigprocmask(struct lwp *, void *, register_t *); +int sys___getlogin(struct lwp *, void *, register_t *); +int sys_setlogin(struct lwp *, void *, register_t *); +int sys_acct(struct lwp *, void *, register_t *); +int compat_13_sys_sigpending(struct lwp *, void *, register_t *); +int compat_13_sys_sigaltstack(struct lwp *, void *, register_t *); +int freebsd_sys_ioctl(struct lwp *, void *, register_t *); +int sys_reboot(struct lwp *, void *, register_t *); +int freebsd_sys_revoke(struct lwp *, void *, register_t *); +int freebsd_sys_symlink(struct lwp *, void *, register_t *); +int freebsd_sys_readlink(struct lwp *, void *, register_t *); +int freebsd_sys_execve(struct lwp *, void *, register_t *); +int sys_umask(struct lwp *, void *, register_t *); +int freebsd_sys_chroot(struct lwp *, void *, register_t *); +int compat_43_sys_fstat(struct lwp *, void *, register_t *); +int compat_43_sys_getkerninfo(struct lwp *, void *, register_t *); +int compat_43_sys_getpagesize(struct lwp *, void *, register_t *); +int freebsd_sys_msync(struct lwp *, void *, register_t *); +int sys_vfork(struct lwp *, void *, register_t *); +int sys_sbrk(struct lwp *, void *, register_t *); +int sys_sstk(struct lwp *, void *, register_t *); +int compat_43_sys_mmap(struct lwp *, void *, register_t *); +int sys_ovadvise(struct lwp *, void *, register_t *); +int sys_munmap(struct lwp *, void *, register_t *); +int sys_mprotect(struct lwp *, void *, register_t *); +int sys_madvise(struct lwp *, void *, register_t *); +int sys_mincore(struct lwp *, void *, register_t *); +int sys_getgroups(struct lwp *, void *, register_t *); +int sys_setgroups(struct lwp *, void *, register_t *); +int sys_getpgrp(struct lwp *, void *, register_t *); +int sys_setpgid(struct lwp *, void *, register_t *); +int sys_setitimer(struct lwp *, void *, register_t *); +int compat_43_sys_wait(struct lwp *, void *, register_t *); +int compat_12_sys_swapon(struct lwp *, void *, register_t *); +int sys_getitimer(struct lwp *, void *, register_t *); +int compat_43_sys_gethostname(struct lwp *, void *, register_t *); +int compat_43_sys_sethostname(struct lwp *, void *, register_t *); +int compat_43_sys_getdtablesize(struct lwp *, void *, register_t *); +int sys_dup2(struct lwp *, void *, register_t *); +int sys_fcntl(struct lwp *, void *, register_t *); +int sys_select(struct lwp *, void *, register_t *); +int sys_fsync(struct lwp *, void *, register_t *); +int sys_setpriority(struct lwp *, void *, register_t *); +int sys_socket(struct lwp *, void *, register_t *); +int sys_connect(struct lwp *, void *, register_t *); +int compat_43_sys_accept(struct lwp *, void *, register_t *); +int sys_getpriority(struct lwp *, void *, register_t *); +int compat_43_sys_send(struct lwp *, void *, register_t *); +int compat_43_sys_recv(struct lwp *, void *, register_t *); +int freebsd_sys_sigreturn(struct lwp *, void *, register_t *); +int sys_bind(struct lwp *, void *, register_t *); +int sys_setsockopt(struct lwp *, void *, register_t *); +int sys_listen(struct lwp *, void *, register_t *); +int compat_43_sys_sigvec(struct lwp *, void *, register_t *); +int compat_43_sys_sigblock(struct lwp *, void *, register_t *); +int compat_43_sys_sigsetmask(struct lwp *, void *, register_t *); +int compat_13_sys_sigsuspend(struct lwp *, void *, register_t *); +int compat_43_sys_sigstack(struct lwp *, void *, register_t *); +int compat_43_sys_recvmsg(struct lwp *, void *, register_t *); +int compat_43_sys_sendmsg(struct lwp *, void *, register_t *); #ifdef TRACE -int sys_vtrace(struct proc *, void *, register_t *); +int sys_vtrace(struct lwp *, void *, register_t *); #else #endif -int sys_gettimeofday(struct proc *, void *, register_t *); -int sys_getrusage(struct proc *, void *, register_t *); -int sys_getsockopt(struct proc *, void *, register_t *); -int sys_readv(struct proc *, void *, register_t *); -int sys_writev(struct proc *, void *, register_t *); -int sys_settimeofday(struct proc *, void *, register_t *); -int sys_fchown(struct proc *, void *, register_t *); -int sys_fchmod(struct proc *, void *, register_t *); -int compat_43_sys_recvfrom(struct proc *, void *, register_t *); -int sys_setreuid(struct proc *, void *, register_t *); -int sys_setregid(struct proc *, void *, register_t *); -int freebsd_sys_rename(struct proc *, void *, register_t *); -int compat_43_freebsd_sys_truncate(struct proc *, void *, register_t *); -int compat_43_sys_ftruncate(struct proc *, void *, register_t *); -int sys_flock(struct proc *, void *, register_t *); -int freebsd_sys_mkfifo(struct proc *, void *, register_t *); -int sys_sendto(struct proc *, void *, register_t *); -int sys_shutdown(struct proc *, void *, register_t *); -int sys_socketpair(struct proc *, void *, register_t *); -int freebsd_sys_mkdir(struct proc *, void *, register_t *); -int freebsd_sys_rmdir(struct proc *, void *, register_t *); -int sys_utimes(struct proc *, void *, register_t *); -int sys_adjtime(struct proc *, void *, register_t *); -int compat_43_sys_getpeername(struct proc *, void *, register_t *); -int compat_43_sys_gethostid(struct proc *, void *, register_t *); -int compat_43_sys_sethostid(struct proc *, void *, register_t *); -int compat_43_sys_getrlimit(struct proc *, void *, register_t *); -int compat_43_sys_setrlimit(struct proc *, void *, register_t *); -int compat_43_sys_killpg(struct proc *, void *, register_t *); -int sys_setsid(struct proc *, void *, register_t *); -int sys_quotactl(struct proc *, void *, register_t *); -int compat_43_sys_quota(struct proc *, void *, register_t *); -int compat_43_sys_getsockname(struct proc *, void *, register_t *); +int sys_gettimeofday(struct lwp *, void *, register_t *); +int sys_getrusage(struct lwp *, void *, register_t *); +int sys_getsockopt(struct lwp *, void *, register_t *); +int sys_readv(struct lwp *, void *, register_t *); +int sys_writev(struct lwp *, void *, register_t *); +int sys_settimeofday(struct lwp *, void *, register_t *); +int sys_fchown(struct lwp *, void *, register_t *); +int sys_fchmod(struct lwp *, void *, register_t *); +int compat_43_sys_recvfrom(struct lwp *, void *, register_t *); +int sys_setreuid(struct lwp *, void *, register_t *); +int sys_setregid(struct lwp *, void *, register_t *); +int freebsd_sys_rename(struct lwp *, void *, register_t *); +int compat_43_freebsd_sys_truncate(struct lwp *, void *, register_t *); +int compat_43_sys_ftruncate(struct lwp *, void *, register_t *); +int sys_flock(struct lwp *, void *, register_t *); +int freebsd_sys_mkfifo(struct lwp *, void *, register_t *); +int sys_sendto(struct lwp *, void *, register_t *); +int sys_shutdown(struct lwp *, void *, register_t *); +int sys_socketpair(struct lwp *, void *, register_t *); +int freebsd_sys_mkdir(struct lwp *, void *, register_t *); +int freebsd_sys_rmdir(struct lwp *, void *, register_t *); +int sys_utimes(struct lwp *, void *, register_t *); +int sys_adjtime(struct lwp *, void *, register_t *); +int compat_43_sys_getpeername(struct lwp *, void *, register_t *); +int compat_43_sys_gethostid(struct lwp *, void *, register_t *); +int compat_43_sys_sethostid(struct lwp *, void *, register_t *); +int compat_43_sys_getrlimit(struct lwp *, void *, register_t *); +int compat_43_sys_setrlimit(struct lwp *, void *, register_t *); +int compat_43_sys_killpg(struct lwp *, void *, register_t *); +int sys_setsid(struct lwp *, void *, register_t *); +int sys_quotactl(struct lwp *, void *, register_t *); +int compat_43_sys_quota(struct lwp *, void *, register_t *); +int compat_43_sys_getsockname(struct lwp *, void *, register_t *); #if defined(NFS) || defined(NFSSERVER) -int sys_nfssvc(struct proc *, void *, register_t *); +int sys_nfssvc(struct lwp *, void *, register_t *); #else #endif -int compat_43_sys_getdirentries(struct proc *, void *, register_t *); -int freebsd_sys_statfs(struct proc *, void *, register_t *); -int sys_fstatfs(struct proc *, void *, register_t *); +int compat_43_sys_getdirentries(struct lwp *, void *, register_t *); +int freebsd_sys_statfs(struct lwp *, void *, register_t *); +int sys_fstatfs(struct lwp *, void *, register_t *); #ifdef NFS -int freebsd_sys_getfh(struct proc *, void *, register_t *); +int freebsd_sys_getfh(struct lwp *, void *, register_t *); #else #endif -int compat_09_sys_getdomainname(struct proc *, void *, register_t *); -int compat_09_sys_setdomainname(struct proc *, void *, register_t *); -int compat_09_sys_uname(struct proc *, void *, register_t *); -int sys_sysarch(struct proc *, void *, register_t *); -int freebsd_sys_rtprio(struct proc *, void *, register_t *); +int compat_09_sys_getdomainname(struct lwp *, void *, register_t *); +int compat_09_sys_setdomainname(struct lwp *, void *, register_t *); +int compat_09_sys_uname(struct lwp *, void *, register_t *); +int sys_sysarch(struct lwp *, void *, register_t *); +int freebsd_sys_rtprio(struct lwp *, void *, register_t *); #if defined(SYSVSEM) && !defined(alpha) -int freebsd_sys_semsys(struct proc *, void *, register_t *); +int freebsd_sys_semsys(struct lwp *, void *, register_t *); #else #endif #if defined(SYSVMSG) && !defined(alpha) -int freebsd_sys_msgsys(struct proc *, void *, register_t *); +int freebsd_sys_msgsys(struct lwp *, void *, register_t *); #else #endif #if defined(SYSVSHM) && !defined(alpha) -int freebsd_sys_shmsys(struct proc *, void *, register_t *); +int freebsd_sys_shmsys(struct lwp *, void *, register_t *); #else #endif -int sys_pread(struct proc *, void *, register_t *); -int sys_pwrite(struct proc *, void *, register_t *); +int sys_pread(struct lwp *, void *, register_t *); +int sys_pwrite(struct lwp *, void *, register_t *); #ifdef NTP -int freebsd_ntp_adjtime(struct proc *, void *, register_t *); +int freebsd_ntp_adjtime(struct lwp *, void *, register_t *); #else #endif -int sys_setgid(struct proc *, void *, register_t *); -int sys_setegid(struct proc *, void *, register_t *); -int sys_seteuid(struct proc *, void *, register_t *); +int sys_setgid(struct lwp *, void *, register_t *); +int sys_setegid(struct lwp *, void *, register_t *); +int sys_seteuid(struct lwp *, void *, register_t *); #ifdef LFS -int sys_lfs_bmapv(struct proc *, void *, register_t *); -int sys_lfs_markv(struct proc *, void *, register_t *); -int sys_lfs_segclean(struct proc *, void *, register_t *); -int sys_lfs_segwait(struct proc *, void *, register_t *); -#else -#endif -int freebsd_sys_stat(struct proc *, void *, register_t *); -int compat_12_sys_fstat(struct proc *, void *, register_t *); -int freebsd_sys_lstat(struct proc *, void *, register_t *); -int freebsd_sys_pathconf(struct proc *, void *, register_t *); -int sys_fpathconf(struct proc *, void *, register_t *); -int sys_getrlimit(struct proc *, void *, register_t *); -int sys_setrlimit(struct proc *, void *, register_t *); -int compat_12_sys_getdirentries(struct proc *, void *, register_t *); -int sys_mmap(struct proc *, void *, register_t *); -int sys_nosys(struct proc *, void *, register_t *); -int sys_lseek(struct proc *, void *, register_t *); -int freebsd_sys_truncate(struct proc *, void *, register_t *); -int sys_ftruncate(struct proc *, void *, register_t *); -int sys___sysctl(struct proc *, void *, register_t *); -int sys_mlock(struct proc *, void *, register_t *); -int sys_munlock(struct proc *, void *, register_t *); +int sys_lfs_bmapv(struct lwp *, void *, register_t *); +int sys_lfs_markv(struct lwp *, void *, register_t *); +int sys_lfs_segclean(struct lwp *, void *, register_t *); +int sys_lfs_segwait(struct lwp *, void *, register_t *); +#else +#endif +int freebsd_sys_stat(struct lwp *, void *, register_t *); +int compat_12_sys_fstat(struct lwp *, void *, register_t *); +int freebsd_sys_lstat(struct lwp *, void *, register_t *); +int freebsd_sys_pathconf(struct lwp *, void *, register_t *); +int sys_fpathconf(struct lwp *, void *, register_t *); +int sys_getrlimit(struct lwp *, void *, register_t *); +int sys_setrlimit(struct lwp *, void *, register_t *); +int compat_12_sys_getdirentries(struct lwp *, void *, register_t *); +int sys_mmap(struct lwp *, void *, register_t *); +int sys_nosys(struct lwp *, void *, register_t *); +int sys_lseek(struct lwp *, void *, register_t *); +int freebsd_sys_truncate(struct lwp *, void *, register_t *); +int sys_ftruncate(struct lwp *, void *, register_t *); +int sys___sysctl(struct lwp *, void *, register_t *); +int sys_mlock(struct lwp *, void *, register_t *); +int sys_munlock(struct lwp *, void *, register_t *); #ifdef FREEBSD_BASED_ON_44LITE_R2 -int freebsd_sys_undelete(struct proc *, void *, register_t *); +int freebsd_sys_undelete(struct lwp *, void *, register_t *); #else #endif -int sys_futimes(struct proc *, void *, register_t *); -int sys_getpgid(struct proc *, void *, register_t *); +int sys_futimes(struct lwp *, void *, register_t *); +int sys_getpgid(struct lwp *, void *, register_t *); #if 0 -int sys_reboot(struct proc *, void *, register_t *); +int sys_reboot(struct lwp *, void *, register_t *); #else #endif -int sys_poll(struct proc *, void *, register_t *); +int sys_poll(struct lwp *, void *, register_t *); #ifdef SYSVSEM -int compat_14_sys___semctl(struct proc *, void *, register_t *); -int sys_semget(struct proc *, void *, register_t *); -int sys_semop(struct proc *, void *, register_t *); -int sys_semconfig(struct proc *, void *, register_t *); +int compat_14_sys___semctl(struct lwp *, void *, register_t *); +int sys_semget(struct lwp *, void *, register_t *); +int sys_semop(struct lwp *, void *, register_t *); +int sys_semconfig(struct lwp *, void *, register_t *); #else #endif #ifdef SYSVMSG -int compat_14_sys_msgctl(struct proc *, void *, register_t *); -int sys_msgget(struct proc *, void *, register_t *); -int sys_msgsnd(struct proc *, void *, register_t *); -int sys_msgrcv(struct proc *, void *, register_t *); +int compat_14_sys_msgctl(struct lwp *, void *, register_t *); +int sys_msgget(struct lwp *, void *, register_t *); +int sys_msgsnd(struct lwp *, void *, register_t *); +int sys_msgrcv(struct lwp *, void *, register_t *); #else #endif #ifdef SYSVSHM -int sys_shmat(struct proc *, void *, register_t *); -int compat_14_sys_shmctl(struct proc *, void *, register_t *); -int sys_shmdt(struct proc *, void *, register_t *); -int sys_shmget(struct proc *, void *, register_t *); -#else -#endif -int sys_clock_gettime(struct proc *, void *, register_t *); -int sys_clock_settime(struct proc *, void *, register_t *); -int sys_clock_getres(struct proc *, void *, register_t *); -int sys_nanosleep(struct proc *, void *, register_t *); -int sys_issetugid(struct proc *, void *, register_t *); -int freebsd_sys_lchown(struct proc *, void *, register_t *); -int sys_getdents(struct proc *, void *, register_t *); -int sys_lchmod(struct proc *, void *, register_t *); -int sys_lchown(struct proc *, void *, register_t *); -int sys_lutimes(struct proc *, void *, register_t *); -int sys___msync13(struct proc *, void *, register_t *); -int sys___stat13(struct proc *, void *, register_t *); -int sys___fstat13(struct proc *, void *, register_t *); -int sys___lstat13(struct proc *, void *, register_t *); -int sys_getsid(struct proc *, void *, register_t *); -int sys_mlockall(struct proc *, void *, register_t *); -int sys_munlockall(struct proc *, void *, register_t *); -int sys___getcwd(struct proc *, void *, register_t *); -int freebsd_sys_utrace(struct proc *, void *, register_t *); -int sys___sigprocmask14(struct proc *, void *, register_t *); -int sys___sigsuspend14(struct proc *, void *, register_t *); -int freebsd_sys_sigaction4(struct proc *, void *, register_t *); -int sys___sigpending14(struct proc *, void *, register_t *); +int sys_shmat(struct lwp *, void *, register_t *); +int compat_14_sys_shmctl(struct lwp *, void *, register_t *); +int sys_shmdt(struct lwp *, void *, register_t *); +int sys_shmget(struct lwp *, void *, register_t *); +#else +#endif +int sys_clock_gettime(struct lwp *, void *, register_t *); +int sys_clock_settime(struct lwp *, void *, register_t *); +int sys_clock_getres(struct lwp *, void *, register_t *); +int sys_nanosleep(struct lwp *, void *, register_t *); +int sys_issetugid(struct lwp *, void *, register_t *); +int freebsd_sys_lchown(struct lwp *, void *, register_t *); +int sys_getdents(struct lwp *, void *, register_t *); +int sys_lchmod(struct lwp *, void *, register_t *); +int sys_lchown(struct lwp *, void *, register_t *); +int sys_lutimes(struct lwp *, void *, register_t *); +int sys___msync13(struct lwp *, void *, register_t *); +int sys___stat13(struct lwp *, void *, register_t *); +int sys___fstat13(struct lwp *, void *, register_t *); +int sys___lstat13(struct lwp *, void *, register_t *); +int sys_getsid(struct lwp *, void *, register_t *); +int sys_mlockall(struct lwp *, void *, register_t *); +int sys_munlockall(struct lwp *, void *, register_t *); +int sys___getcwd(struct lwp *, void *, register_t *); +int freebsd_sys_utrace(struct lwp *, void *, register_t *); +int sys___sigprocmask14(struct lwp *, void *, register_t *); +int sys___sigsuspend14(struct lwp *, void *, register_t *); +int freebsd_sys_sigaction4(struct lwp *, void *, register_t *); +int sys___sigpending14(struct lwp *, void *, register_t *); #endif /* _FREEBSD_SYS__SYSCALLARGS_H_ */ Index: sys/compat/ibcs2/ibcs2_fcntl.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/ibcs2/ibcs2_fcntl.c,v retrieving revision 1.10 retrieving revision 1.10.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.10 -r1.10.2.1 --- sys/compat/ibcs2/ibcs2_fcntl.c 2000/12/01 12:28:32 1.10 +++ sys/compat/ibcs2/ibcs2_fcntl.c 2001/03/05 22:49:21 1.10.2.1 @@ -159,18 +159,19 @@ return r; } int -ibcs2_sys_open(p, v, retval) - struct proc *p; +ibcs2_sys_open(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_open_args /* { syscallarg(char *) path; syscallarg(int) flags; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; int noctty = SCARG(uap, flags) & IBCS2_O_NOCTTY; int ret; caddr_t sg = stackgap_init(p->p_emul); @@ -178,9 +179,9 @@ if (SCARG(uap, flags) & O_CREAT) CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); else CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - ret = sys_open(p, uap, retval); + ret = sys_open(l, uap, retval); if (!ret && !noctty && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) { struct filedesc *fdp = p->p_fd; struct file *fp = fdp->fd_ofiles[*retval]; @@ -192,56 +193,59 @@ return ret; } int -ibcs2_sys_creat(p, v, retval) - struct proc *p; +ibcs2_sys_creat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_creat_args /* { syscallarg(char *) path; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; struct sys_open_args cup; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, mode) = SCARG(uap, mode); SCARG(&cup, flags) = O_WRONLY | O_CREAT | O_TRUNC; - return sys_open(p, &cup, retval); + return sys_open(l, &cup, retval); } int -ibcs2_sys_access(p, v, retval) - struct proc *p; +ibcs2_sys_access(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_access_args /* { syscallarg(char *) path; syscallarg(int) flags; } */ *uap = v; struct sys_access_args cup; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, flags) = SCARG(uap, flags); - return sys_access(p, &cup, retval); + return sys_access(l, &cup, retval); } int -ibcs2_sys_eaccess(p, v, retval) - struct proc *p; +ibcs2_sys_eaccess(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_eaccess_args /* { syscallarg(char *) path; syscallarg(int) flags; } */ *uap = v; + struct proc *p = l->l_proc; struct ucred *cred = p->p_ucred; struct vnode *vp; int error, flags; struct nameidata nd; @@ -271,18 +275,19 @@ return error; } int -ibcs2_sys_fcntl(p, v, retval) - struct proc *p; +ibcs2_sys_fcntl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_fcntl_args /* { syscallarg(int) fd; syscallarg(int) cmd; syscallarg(char *) arg; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct sys_fcntl_args fa; struct flock *flp; struct ibcs2_flock ifl; @@ -291,33 +296,33 @@ case IBCS2_F_DUPFD: SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = F_DUPFD; SCARG(&fa, arg) = SCARG(uap, arg); - return sys_fcntl(p, &fa, retval); + return sys_fcntl(l, &fa, retval); case IBCS2_F_GETFD: SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = F_GETFD; SCARG(&fa, arg) = SCARG(uap, arg); - return sys_fcntl(p, &fa, retval); + return sys_fcntl(l, &fa, retval); case IBCS2_F_SETFD: SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = F_SETFD; SCARG(&fa, arg) = SCARG(uap, arg); - return sys_fcntl(p, &fa, retval); + return sys_fcntl(l, &fa, retval); case IBCS2_F_GETFL: SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = F_GETFL; SCARG(&fa, arg) = SCARG(uap, arg); - error = sys_fcntl(p, &fa, retval); + error = sys_fcntl(l, &fa, retval); if (error) return error; *retval = oflags2ioflags(*retval); return error; case IBCS2_F_SETFL: SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = F_SETFL; SCARG(&fa, arg) = (void *)ioflags2oflags((int) SCARG(uap, arg)); - return sys_fcntl(p, &fa, retval); + return sys_fcntl(l, &fa, retval); case IBCS2_F_GETLK: { caddr_t sg = stackgap_init(p->p_emul); @@ -329,9 +334,9 @@ cvt_iflock2flock(&ifl, flp); SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = F_GETLK; SCARG(&fa, arg) = (void *)flp; - error = sys_fcntl(p, &fa, retval); + error = sys_fcntl(l, &fa, retval); if (error) return error; cvt_flock2iflock(flp, &ifl); return copyout((caddr_t)&ifl, (caddr_t)SCARG(uap, arg), @@ -349,9 +354,9 @@ cvt_iflock2flock(&ifl, flp); SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = F_SETLK; SCARG(&fa, arg) = (void *)flp; - return sys_fcntl(p, &fa, retval); + return sys_fcntl(l, &fa, retval); } case IBCS2_F_SETLKW: { @@ -364,9 +369,9 @@ cvt_iflock2flock(&ifl, flp); SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = F_SETLKW; SCARG(&fa, arg) = (void *)flp; - return sys_fcntl(p, &fa, retval); + return sys_fcntl(l, &fa, retval); } } return ENOSYS; } Index: sys/compat/ibcs2/ibcs2_ioctl.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/ibcs2/ibcs2_ioctl.c,v retrieving revision 1.21 retrieving revision 1.21.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.21 -r1.21.2.1 --- sys/compat/ibcs2/ibcs2_ioctl.c 2001/01/18 20:28:25 1.21 +++ sys/compat/ibcs2/ibcs2_ioctl.c 2001/03/05 22:49:21 1.21.2.1 @@ -327,18 +327,19 @@ memcpy(ts->c_cc, t->c_cc, IBCS2_NCC); } int -ibcs2_sys_ioctl(p, v, retval) - struct proc *p; +ibcs2_sys_ioctl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_ioctl_args /* { syscallarg(int) fd; syscallarg(int) cmd; syscallarg(caddr_t) data; } */ *uap = v; + struct proc *p = l->l_proc; struct filedesc *fdp = p->p_fd; struct file *fp; int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)); int error; @@ -505,13 +506,13 @@ } case IBCS2_TIOCGWINSZ: SCARG(uap, cmd) = TIOCGWINSZ; - return sys_ioctl(p, uap, retval); + return sys_ioctl(l, uap, retval); case IBCS2_TIOCSWINSZ: SCARG(uap, cmd) = TIOCSWINSZ; - return sys_ioctl(p, uap, retval); + return sys_ioctl(l, uap, retval); case IBCS2_TIOCGPGRP: return copyout((caddr_t)&p->p_pgrp->pg_id, SCARG(uap, data), sizeof(p->p_pgrp->pg_id)); @@ -521,9 +522,9 @@ struct sys_setpgid_args sa; SCARG(&sa, pid) = 0; SCARG(&sa, pgid) = (int)SCARG(uap, data); - if ((error = sys_setpgid(p, &sa, retval)) != 0) + if ((error = sys_setpgid(l, &sa, retval)) != 0) return error; return 0; } @@ -533,9 +534,9 @@ case IBCS2_TCSETSC: /* SCO console - set scancode flags */ return ENOSYS; case IBCS2_SIOCSOCKSYS: - return ibcs2_socksys(p, uap, retval); + return ibcs2_socksys(l, uap, retval); case IBCS2_FIONBIO: { int arg; @@ -548,9 +549,9 @@ } case IBCS2_I_NREAD: /* STREAMS */ SCARG(uap, cmd) = FIONREAD; - return sys_ioctl(p, uap, retval); + return sys_ioctl(l, uap, retval); default: DPRINTF(("ibcs2_ioctl(%d): unknown cmd 0x%x ", p->p_pid, SCARG(uap, cmd))); @@ -559,17 +560,18 @@ return ENOSYS; } int -ibcs2_sys_gtty(p, v, retval) - struct proc *p; +ibcs2_sys_gtty(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_gtty_args /* { syscallarg(int) fd; syscallarg(struct sgttyb *) tb; } */ *uap = v; + struct proc *p = l->l_proc; struct filedesc *fdp = p->p_fd; struct file *fp; struct sgttyb tb; struct ibcs2_sgttyb itb; Index: sys/compat/ibcs2/ibcs2_ipc.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/ibcs2/ibcs2_ipc.c,v retrieving revision 1.12 retrieving revision 1.12.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.12 -r1.12.2.1 --- sys/compat/ibcs2/ibcs2_ipc.c 2000/11/29 22:05:36 1.12 +++ sys/compat/ibcs2/ibcs2_ipc.c 2001/03/05 22:49:21 1.12.2.1 @@ -175,10 +175,10 @@ return; } int -ibcs2_sys_msgsys(p, v, retval) - struct proc *p; +ibcs2_sys_msgsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_msgsys_args /* { @@ -188,14 +188,15 @@ syscallarg(int) a4; syscallarg(int) a5; syscallarg(int) a6; } */ *uap = v; + struct proc *p = l->l_proc; switch (SCARG(uap, which)) { #ifdef SYSVMSG case 0: /* msgget */ SCARG(uap, which) = 1; - return compat_10_sys_msgsys(p, uap, retval); + return compat_10_sys_msgsys(l, uap, retval); case 1: { /* msgctl */ int error; struct compat_10_sys_msgsys_args margs; caddr_t sg = stackgap_init(p->p_emul); @@ -206,9 +207,9 @@ (int)stackgap_alloc(&sg, sizeof(struct msqid_ds14)); SCARG(&margs, a3) = SCARG(uap, a3); switch (SCARG(&margs, a3)) { case IBCS2_IPC_STAT: - error = compat_10_sys_msgsys(p, &margs, retval); + error = compat_10_sys_msgsys(l, &margs, retval); if (!error) cvt_msqid2imsqid((struct msqid_ds14 *) SCARG(&margs, a4), (struct ibcs2_msqid_ds *)SCARG(uap, a4)); @@ -217,20 +218,20 @@ cvt_imsqid2msqid((struct ibcs2_msqid_ds *)SCARG(uap, a4), (struct msqid_ds14 *) SCARG(&margs, a4)); - return compat_10_sys_msgsys(p, &margs, retval); + return compat_10_sys_msgsys(l, &margs, retval); case IBCS2_IPC_RMID: - return compat_10_sys_msgsys(p, &margs, retval); + return compat_10_sys_msgsys(l, &margs, retval); } return EINVAL; } case 2: /* msgrcv */ SCARG(uap, which) = 3; - return compat_10_sys_msgsys(p, uap, retval); + return compat_10_sys_msgsys(l, uap, retval); case 3: /* msgsnd */ SCARG(uap, which) = 2; - return compat_10_sys_msgsys(p, uap, retval); + return compat_10_sys_msgsys(l, uap, retval); #endif default: return EINVAL; } @@ -320,10 +321,10 @@ return; } int -ibcs2_sys_semsys(p, v, retval) - struct proc *p; +ibcs2_sys_semsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_semsys_args /* { @@ -332,8 +333,9 @@ syscallarg(int) a3; syscallarg(int) a4; syscallarg(int) a5; } */ *uap = v; + struct proc *p = l->l_proc; int error; #ifdef SYSVSEM switch (SCARG(uap, which)) { @@ -347,9 +349,9 @@ isp = (struct ibcs2_semid_ds *)SCARG(uap, a5); sp = stackgap_alloc(&sg, sizeof(struct semid_ds14)); SCARG(uap, a5) = (int)sp; - error = compat_10_sys_semsys(p, uap, retval); + error = compat_10_sys_semsys(l, uap, retval); if (error) return error; error = copyin((caddr_t)sp, (caddr_t)&s, sizeof(s)); @@ -375,18 +377,18 @@ sizeof(s)); if (error) return error; SCARG(uap, a5) = (int)sp; - return compat_10_sys_semsys(p, uap, retval); + return compat_10_sys_semsys(l, uap, retval); } } - return compat_10_sys_semsys(p, uap, retval); + return compat_10_sys_semsys(l, uap, retval); case 1: /* semget */ - return compat_10_sys_semsys(p, uap, retval); + return compat_10_sys_semsys(l, uap, retval); case 2: /* semop */ - return compat_10_sys_semsys(p, uap, retval); + return compat_10_sys_semsys(l, uap, retval); } #endif return EINVAL; } @@ -452,10 +454,10 @@ return; } int -ibcs2_sys_shmsys(p, v, retval) - struct proc *p; +ibcs2_sys_shmsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_shmsys_args /* { @@ -463,14 +465,15 @@ syscallarg(int) a2; syscallarg(int) a3; syscallarg(int) a4; } */ *uap = v; + struct proc *p = l->l_proc; int error; #ifdef SYSVSHM switch (SCARG(uap, which)) { case 0: /* shmat */ - return compat_10_sys_shmsys(p, uap, retval); + return compat_10_sys_shmsys(l, uap, retval); case 1: /* shmctl */ switch(SCARG(uap, a3)) { case IBCS2_IPC_STAT: @@ -481,9 +484,9 @@ isp = (struct ibcs2_shmid_ds *)SCARG(uap, a4); sp = stackgap_alloc(&sg, sizeof(*sp)); SCARG(uap, a4) = (int)sp; - error = compat_10_sys_shmsys(p, uap, retval); + error = compat_10_sys_shmsys(l, uap, retval); if (error) return error; error = copyin((caddr_t)sp, (caddr_t)&s, sizeof(s)); @@ -509,18 +512,18 @@ error = copyout((caddr_t)&s, (caddr_t)sp, sizeof(s)); if (error) return error; - return compat_10_sys_shmsys(p, uap, retval); + return compat_10_sys_shmsys(l, uap, retval); } } - return compat_10_sys_shmsys(p, uap, retval); + return compat_10_sys_shmsys(l, uap, retval); case 2: /* shmdt */ - return compat_10_sys_shmsys(p, uap, retval); + return compat_10_sys_shmsys(l, uap, retval); case 3: /* shmget */ - return compat_10_sys_shmsys(p, uap, retval); + return compat_10_sys_shmsys(l, uap, retval); } #endif return EINVAL; } Index: sys/compat/ibcs2/ibcs2_misc.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/ibcs2/ibcs2_misc.c,v retrieving revision 1.55 retrieving revision 1.55.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.55 -r1.55.2.1 --- sys/compat/ibcs2/ibcs2_misc.c 2001/01/22 20:08:04 1.55 +++ sys/compat/ibcs2/ibcs2_misc.c 2001/03/05 22:49:21 1.55.2.1 @@ -108,17 +108,18 @@ #include #include int -ibcs2_sys_ulimit(p, v, retval) - struct proc *p; +ibcs2_sys_ulimit(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_ulimit_args /* { syscallarg(int) cmd; syscallarg(int) newlimit; } */ *uap = v; + struct proc *p = l->l_proc; #ifdef notyet int error; struct rlimit rl; struct sys_setrlimit_args sra; @@ -151,17 +152,17 @@ *retval = p->p_rlimit[RLIMIT_RSS].rlim_cur; /* XXX */ return 0; case IBCS2_GETDTABLESIZE: SCARG(uap, cmd) = IBCS2_SC_OPEN_MAX; - return ibcs2_sys_sysconf(p, uap, retval); + return ibcs2_sys_sysconf(l, uap, retval); default: return ENOSYS; } } int -ibcs2_sys_waitsys(p, v, retval) - struct proc *p; +ibcs2_sys_waitsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #if defined(__i386__) @@ -170,8 +171,9 @@ syscallarg(int) a2; syscallarg(int) a3; } */ *uap = v; #endif + struct proc *p = l->l_proc; int error; struct sys_wait4_args w4; caddr_t sg; @@ -181,9 +183,9 @@ SCARG(&w4, status) = stackgap_alloc(&sg, sizeof(int)); #if defined(__i386__) #define WAITPID_EFLAGS 0x8c4 /* OF, SF, ZF, PF */ - if ((p->p_md.md_regs->tf_eflags & WAITPID_EFLAGS) == WAITPID_EFLAGS) { + if ((l->l_md.md_regs->tf_eflags & WAITPID_EFLAGS) == WAITPID_EFLAGS) { /* waitpid */ SCARG(&w4, pid) = SCARG(uap, a1); SCARG(&w4, options) = SCARG(uap, a3); } else { @@ -194,25 +196,26 @@ #if defined(__i386__) } #endif - if ((error = sys_wait4(p, &w4, retval)) != 0) + if ((error = sys_wait4(l, &w4, retval)) != 0) return error; return copyin((caddr_t)SCARG(&w4, status), (caddr_t)&retval[1], sizeof(int)); } int -ibcs2_sys_execv(p, v, retval) - struct proc *p; +ibcs2_sys_execv(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_execv_args /* { syscallarg(const char *) path; syscallarg(char **) argp; } */ *uap = v; + struct proc *p = l->l_proc; struct sys_execve_args ap; caddr_t sg; sg = stackgap_init(p->p_emul); @@ -221,22 +224,23 @@ SCARG(&ap, path) = SCARG(uap, path); SCARG(&ap, argp) = SCARG(uap, argp); SCARG(&ap, envp) = NULL; - return sys_execve(p, &ap, retval); + return sys_execve(l, &ap, retval); } int -ibcs2_sys_execve(p, v, retval) - struct proc *p; +ibcs2_sys_execve(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_execve_args /* { syscallarg(const char *) path; syscallarg(char **) argp; syscallarg(char **) envp; } */ *uap = v; + struct proc *p = l->l_proc; struct sys_execve_args ap; caddr_t sg; sg = stackgap_init(p->p_emul); @@ -245,14 +249,14 @@ SCARG(&ap, path) = SCARG(uap, path); SCARG(&ap, argp) = SCARG(uap, argp); SCARG(&ap, envp) = SCARG(uap, envp); - return sys_execve(p, &ap, retval); + return sys_execve(l, &ap, retval); } int -ibcs2_sys_umount(p, v, retval) - struct proc *p; +ibcs2_sys_umount(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_umount_args /* { @@ -261,14 +265,14 @@ struct sys_unmount_args um; SCARG(&um, path) = SCARG(uap, name); SCARG(&um, flags) = 0; - return sys_unmount(p, &um, retval); + return sys_unmount(l, &um, retval); } int -ibcs2_sys_mount(p, v, retval) - struct proc *p; +ibcs2_sys_mount(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #ifdef notyet @@ -347,18 +351,19 @@ * This is quite ugly, but what do you expect from compatibility code? */ int -ibcs2_sys_getdents(p, v, retval) - struct proc *p; +ibcs2_sys_getdents(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_getdents_args /* { syscallarg(int) fd; syscallarg(char *) buf; syscallarg(int) nbytes; } */ *uap = v; + struct proc *p = l->l_proc; struct dirent *bdp; struct vnode *vp; caddr_t inp, buf; /* BSD-format */ int len, reclen; /* BSD-format */ @@ -470,18 +475,19 @@ return (error); } int -ibcs2_sys_read(p, v, retval) - struct proc *p; +ibcs2_sys_read(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_read_args /* { syscallarg(int) fd; syscallarg(char *) buf; syscallarg(u_int) nbytes; } */ *uap = v; + struct proc *p = l->l_proc; struct dirent *bdp; struct vnode *vp; caddr_t inp, buf; /* BSD-format */ int len, reclen; /* BSD-format */ @@ -502,9 +508,9 @@ /* getvnode() will use the descriptor for us */ if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) { if (error == EINVAL) - return sys_read(p, uap, retval); + return sys_read(l, uap, retval); else return error; } if ((fp->f_flag & FREAD) == 0) { @@ -513,9 +519,9 @@ } vp = (struct vnode *)fp->f_data; if (vp->v_type != VDIR) { FILE_UNUSE(fp, p); - return sys_read(p, uap, retval); + return sys_read(l, uap, retval); } buflen = min(MAXBSIZE, max(DEV_BSIZE, SCARG(uap, nbytes))); buf = malloc(buflen, M_TEMP, M_WAITOK); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); @@ -599,45 +605,47 @@ return (error); } int -ibcs2_sys_mknod(p, v, retval) - struct proc *p; +ibcs2_sys_mknod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_mknod_args /* { syscallarg(const char *) path; syscallarg(int) mode; syscallarg(int) dev; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); if (S_ISFIFO(SCARG(uap, mode))) { struct sys_mkfifo_args ap; SCARG(&ap, path) = SCARG(uap, path); SCARG(&ap, mode) = SCARG(uap, mode); - return sys_mkfifo(p, uap, retval); + return sys_mkfifo(l, uap, retval); } else { struct sys_mknod_args ap; SCARG(&ap, path) = SCARG(uap, path); SCARG(&ap, mode) = SCARG(uap, mode); SCARG(&ap, dev) = SCARG(uap, dev); - return sys_mknod(p, &ap, retval); + return sys_mknod(l, &ap, retval); } } int -ibcs2_sys_getgroups(p, v, retval) - struct proc *p; +ibcs2_sys_getgroups(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_getgroups_args /* { syscallarg(int) gidsetsize; syscallarg(ibcs2_gid_t *) gidset; } */ *uap = v; + struct proc *p = l->l_proc; int error, i; ibcs2_gid_t iset[NGROUPS_MAX]; gid_t nset[NGROUPS_MAX]; struct sys_getgroups_args sa; @@ -653,9 +661,9 @@ if (gidsetsize) { SCARG(&sa, gidset) = stackgap_alloc(&sg, NGROUPS_MAX * sizeof(gid_t *)); } - if ((error = sys_getgroups(p, &sa, retval)) != 0) + if ((error = sys_getgroups(l, &sa, retval)) != 0) return error; if (gidsetsize) { gidsetsize = retval[0]; if (gidsetsize < 0) @@ -673,17 +681,18 @@ return error; } int -ibcs2_sys_setgroups(p, v, retval) - struct proc *p; +ibcs2_sys_setgroups(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_setgroups_args /* { syscallarg(int) gidsetsize; syscallarg(ibcs2_gid_t *) gidset; } */ *uap = v; + struct proc *p = l->l_proc; int error, i; ibcs2_gid_t iset[NGROUPS_MAX]; struct sys_setgroups_args sa; gid_t gp[NGROUPS_MAX], *ngid; @@ -705,14 +714,14 @@ error = copyout(gp, ngid, SCARG(&sa, gidsetsize) * sizeof(gid_t)); if (error) return error; SCARG(&sa, gidset) = ngid; - return sys_setgroups(p, &sa, retval); + return sys_setgroups(l, &sa, retval); } int -ibcs2_sys_setuid(p, v, retval) - struct proc *p; +ibcs2_sys_setuid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_setuid_args /* { @@ -720,14 +729,14 @@ } */ *uap = v; struct sys_setuid_args sa; SCARG(&sa, uid) = (uid_t)SCARG(uap, uid); - return sys_setuid(p, &sa, retval); + return sys_setuid(l, &sa, retval); } int -ibcs2_sys_setgid(p, v, retval) - struct proc *p; +ibcs2_sys_setgid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_setgid_args /* { @@ -735,14 +744,14 @@ } */ *uap = v; struct sys_setgid_args sa; SCARG(&sa, gid) = (gid_t)SCARG(uap, gid); - return sys_setgid(p, &sa, retval); + return sys_setgid(l, &sa, retval); } int -xenix_sys_ftime(p, v, retval) - struct proc *p; +xenix_sys_ftime(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct xenix_sys_ftime_args /* { @@ -760,16 +769,17 @@ return copyout((caddr_t)&itb, (caddr_t)SCARG(uap, tp), xenix_timeb_len); } int -ibcs2_sys_time(p, v, retval) - struct proc *p; +ibcs2_sys_time(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_time_args /* { syscallarg(ibcs2_time_t *) tp; } */ *uap = v; + struct proc *p = l->l_proc; struct timeval tv; microtime(&tv); *retval = tv.tv_sec; @@ -780,44 +790,45 @@ return 0; } int -ibcs2_sys_pathconf(p, v, retval) - struct proc *p; +ibcs2_sys_pathconf(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_pathconf_args /* { syscallarg(char *) path; syscallarg(int) name; } */ *uap = v; SCARG(uap, name)++; /* iBCS2 _PC_* defines are offset by one */ - return sys_pathconf(p, uap, retval); + return sys_pathconf(l, uap, retval); } int -ibcs2_sys_fpathconf(p, v, retval) - struct proc *p; +ibcs2_sys_fpathconf(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_fpathconf_args /* { syscallarg(int) fd; syscallarg(int) name; } */ *uap = v; SCARG(uap, name)++; /* iBCS2 _PC_* defines are offset by one */ - return sys_fpathconf(p, uap, retval); + return sys_fpathconf(l, uap, retval); } int -ibcs2_sys_sysconf(p, v, retval) - struct proc *p; +ibcs2_sys_sysconf(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_sysconf_args /* { syscallarg(int) name; } */ *uap = v; + struct proc *p = l->l_proc; int mib[2], value, error; size_t len; struct sys___sysctl_args sa; struct sys_getrlimit_args ga; @@ -832,9 +843,9 @@ caddr_t sg = stackgap_init(p->p_emul); SCARG(&ga, which) = RLIMIT_NPROC; SCARG(&ga, rlp) = stackgap_alloc(&sg, sizeof(struct rlimit *)); - if ((error = sys_getrlimit(p, &ga, retval)) != 0) + if ((error = sys_getrlimit(l, &ga, retval)) != 0) return error; *retval = SCARG(&ga, rlp)->rlim_cur; return 0; } @@ -852,9 +863,9 @@ caddr_t sg = stackgap_init(p->p_emul); SCARG(&ga, which) = RLIMIT_NOFILE; SCARG(&ga, rlp) = stackgap_alloc(&sg, sizeof(struct rlimit *)); - if ((error = sys_getrlimit(p, &ga, retval)) != 0) + if ((error = sys_getrlimit(l, &ga, retval)) != 0) return error; *retval = SCARG(&ga, rlp)->rlim_cur; return 0; } @@ -890,23 +901,24 @@ SCARG(&sa, old) = &value; SCARG(&sa, oldlenp) = &len; SCARG(&sa, new) = NULL; SCARG(&sa, newlen) = 0; - if ((error = sys___sysctl(p, &sa, retval)) != 0) + if ((error = sys___sysctl(l, &sa, retval)) != 0) return error; *retval = value; return 0; } int -ibcs2_sys_alarm(p, v, retval) - struct proc *p; +ibcs2_sys_alarm(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_alarm_args /* { syscallarg(unsigned) sec; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct itimerval *itp, *oitp; struct sys_setitimer_args sa; caddr_t sg = stackgap_init(p->p_emul); @@ -919,9 +931,9 @@ SCARG(&sa, which) = ITIMER_REAL; SCARG(&sa, itv) = itp; SCARG(&sa, oitv) = oitp; - error = sys_setitimer(p, &sa, retval); + error = sys_setitimer(l, &sa, retval); if (error) return error; if (oitp->it_value.tv_usec) oitp->it_value.tv_sec++; @@ -929,10 +941,10 @@ return 0; } int -ibcs2_sys_getmsg(p, v, retval) - struct proc *p; +ibcs2_sys_getmsg(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #ifdef notyet @@ -947,10 +959,10 @@ return 0; } int -ibcs2_sys_putmsg(p, v, retval) - struct proc *p; +ibcs2_sys_putmsg(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #ifdef notyet @@ -965,16 +977,17 @@ return 0; } int -ibcs2_sys_times(p, v, retval) - struct proc *p; +ibcs2_sys_times(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_times_args /* { syscallarg(struct tms *) tp; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct sys_getrusage_args ga; struct tms tms; struct timeval t; @@ -983,16 +996,16 @@ #define CONVTCK(r) (r.tv_sec * hz + r.tv_usec / (1000000 / hz)) SCARG(&ga, who) = RUSAGE_SELF; SCARG(&ga, rusage) = ru; - error = sys_getrusage(p, &ga, retval); + error = sys_getrusage(l, &ga, retval); if (error) return error; tms.tms_utime = CONVTCK(ru->ru_utime); tms.tms_stime = CONVTCK(ru->ru_stime); SCARG(&ga, who) = RUSAGE_CHILDREN; - error = sys_getrusage(p, &ga, retval); + error = sys_getrusage(l, &ga, retval); if (error) return error; tms.tms_cutime = CONVTCK(ru->ru_utime); tms.tms_cstime = CONVTCK(ru->ru_stime); @@ -1004,16 +1017,17 @@ sizeof(struct tms)); } int -ibcs2_sys_stime(p, v, retval) - struct proc *p; +ibcs2_sys_stime(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_stime_args /* { syscallarg(long *) timep; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct sys_settimeofday_args sa; caddr_t sg = stackgap_init(p->p_emul); struct timeval *tvp; @@ -1025,23 +1039,24 @@ if (error) return error; tvp->tv_usec = 0; SCARG(&sa, tv) = tvp; - if ((error = sys_settimeofday(p, &sa, retval)) != 0) + if ((error = sys_settimeofday(l, &sa, retval)) != 0) return EPERM; return 0; } int -ibcs2_sys_utime(p, v, retval) - struct proc *p; +ibcs2_sys_utime(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_utime_args /* { syscallarg(const char *) path; syscallarg(struct ibcs2_utimbuf *) buf; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct sys_utimes_args sa; struct timeval *tp; @@ -1062,27 +1077,28 @@ tp[1].tv_usec = 0; SCARG(&sa, tptr) = tp; } else SCARG(&sa, tptr) = NULL; - return sys_utimes(p, &sa, retval); + return sys_utimes(l, &sa, retval); } int -ibcs2_sys_nice(p, v, retval) - struct proc *p; +ibcs2_sys_nice(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_nice_args /* { syscallarg(int) incr; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct sys_setpriority_args sa; SCARG(&sa, which) = PRIO_PROCESS; SCARG(&sa, who) = 0; SCARG(&sa, prio) = p->p_nice - NZERO + SCARG(uap, incr); - if ((error = sys_setpriority(p, &sa, retval)) != 0) + if ((error = sys_setpriority(l, &sa, retval)) != 0) return EPERM; *retval = p->p_nice - NZERO; return 0; } @@ -1091,10 +1107,10 @@ * iBCS2 getpgrp, setpgrp, setsid, and setpgid */ int -ibcs2_sys_pgrpsys(p, v, retval) - struct proc *p; +ibcs2_sys_pgrpsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_pgrpsys_args /* { @@ -1102,8 +1118,10 @@ syscallarg(caddr_t) dummy; syscallarg(int) pid; syscallarg(int) pgid; } */ *uap = v; + struct proc *p = l->l_proc; + switch (SCARG(uap, type)) { case 0: /* getpgrp */ *retval = p->p_pgrp->pg_id; return 0; @@ -1113,9 +1131,9 @@ struct sys_setpgid_args sa; SCARG(&sa, pid) = 0; SCARG(&sa, pgid) = 0; - sys_setpgid(p, &sa, retval); + sys_setpgid(l, &sa, retval); *retval = p->p_pgrp->pg_id; return 0; } @@ -1124,13 +1142,13 @@ struct sys_setpgid_args sa; SCARG(&sa, pid) = SCARG(uap, pid); SCARG(&sa, pgid) = SCARG(uap, pgid); - return sys_setpgid(p, &sa, retval); + return sys_setpgid(l, &sa, retval); } case 3: /* setsid */ - return sys_setsid(p, NULL, retval); + return sys_setsid(l, NULL, retval); default: return EINVAL; } @@ -1140,16 +1158,17 @@ * XXX - need to check for nested calls */ int -ibcs2_sys_plock(p, v, retval) - struct proc *p; +ibcs2_sys_plock(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_plock_args /* { syscallarg(int) cmd; } */ *uap = v; + struct proc *p = l->l_proc; int error; #define IBCS2_UNLOCK 0 #define IBCS2_PROCLOCK 1 #define IBCS2_TEXTLOCK 2 @@ -1168,18 +1187,19 @@ return EINVAL; } int -ibcs2_sys_uadmin(p, v, retval) - struct proc *p; +ibcs2_sys_uadmin(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_uadmin_args /* { syscallarg(int) cmd; syscallarg(int) func; syscallarg(caddr_t) data; } */ *uap = v; + struct proc *p = l->l_proc; int error; #define SCO_A_REBOOT 1 #define SCO_A_SHUTDOWN 2 @@ -1226,10 +1246,10 @@ return EINVAL; } int -ibcs2_sys_sysfs(p, v, retval) - struct proc *p; +ibcs2_sys_sysfs(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_sysfs_args /* { @@ -1250,32 +1270,33 @@ return EINVAL; /* XXX - TODO */ } int -xenix_sys_rdchk(p, v, retval) - struct proc *p; +xenix_sys_rdchk(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct xenix_sys_rdchk_args /* { syscallarg(int) fd; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct sys_ioctl_args sa; caddr_t sg = stackgap_init(p->p_emul); SCARG(&sa, fd) = SCARG(uap, fd); SCARG(&sa, com) = FIONREAD; SCARG(&sa, data) = stackgap_alloc(&sg, sizeof(int)); - if ((error = sys_ioctl(p, &sa, retval)) != 0) + if ((error = sys_ioctl(l, &sa, retval)) != 0) return error; *retval = (*((int*)SCARG(&sa, data))) ? 1 : 0; return 0; } int -xenix_sys_chsize(p, v, retval) - struct proc *p; +xenix_sys_chsize(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct xenix_sys_chsize_args /* { @@ -1286,20 +1307,21 @@ SCARG(&sa, fd) = SCARG(uap, fd); SCARG(&sa, pad) = 0; SCARG(&sa, length) = SCARG(uap, size); - return sys_ftruncate(p, &sa, retval); + return sys_ftruncate(l, &sa, retval); } int -xenix_sys_nap(p, v, retval) - struct proc *p; +xenix_sys_nap(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct xenix_sys_nap_args /* { syscallarg(long) millisec; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct sys_nanosleep_args na; struct timespec *rqtp; struct timespec *rmtp; @@ -1310,167 +1332,176 @@ rqtp->tv_sec = 0; rqtp->tv_nsec = SCARG(uap, millisec) * 1000; SCARG(&na, rqtp) = rqtp; SCARG(&na, rmtp) = rmtp; - if ((error = sys_nanosleep(p, &na, retval)) != 0) + if ((error = sys_nanosleep(l, &na, retval)) != 0) return error; *retval = rmtp->tv_nsec / 1000; return 0; } int -ibcs2_sys_unlink(p, v, retval) - struct proc *p; +ibcs2_sys_unlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_unlink_args /* { syscallarg(const char *) path; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_unlink(p, uap, retval); + return sys_unlink(l, uap, retval); } int -ibcs2_sys_chdir(p, v, retval) - struct proc *p; +ibcs2_sys_chdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_chdir_args /* { syscallarg(const char *) path; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_chdir(p, uap, retval); + return sys_chdir(l, uap, retval); } int -ibcs2_sys_chmod(p, v, retval) - struct proc *p; +ibcs2_sys_chmod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_chmod_args /* { syscallarg(const char *) path; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_chmod(p, uap, retval); + return sys_chmod(l, uap, retval); } int -ibcs2_sys_chown(p, v, retval) - struct proc *p; +ibcs2_sys_chown(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_chown_args /* { syscallarg(const char *) path; syscallarg(int) uid; syscallarg(int) gid; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys___posix_chown(p, uap, retval); + return sys___posix_chown(l, uap, retval); } int -ibcs2_sys_rmdir(p, v, retval) - struct proc *p; +ibcs2_sys_rmdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_rmdir_args /* { syscallarg(const char *) path; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_rmdir(p, uap, retval); + return sys_rmdir(l, uap, retval); } int -ibcs2_sys_mkdir(p, v, retval) - struct proc *p; +ibcs2_sys_mkdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_mkdir_args /* { syscallarg(const char *) path; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); - return sys_mkdir(p, uap, retval); + return sys_mkdir(l, uap, retval); } int -ibcs2_sys_symlink(p, v, retval) - struct proc *p; +ibcs2_sys_symlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_symlink_args /* { syscallarg(const char *) path; syscallarg(const char *) link; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); CHECK_ALT_CREAT(p, &sg, SCARG(uap, link)); - return sys_symlink(p, uap, retval); + return sys_symlink(l, uap, retval); } int -ibcs2_sys_rename(p, v, retval) - struct proc *p; +ibcs2_sys_rename(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_rename_args /* { syscallarg(const char *) from; syscallarg(const char *) to; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, from)); CHECK_ALT_CREAT(p, &sg, SCARG(uap, to)); - return sys___posix_rename(p, uap, retval); + return sys___posix_rename(l, uap, retval); } int -ibcs2_sys_readlink(p, v, retval) - struct proc *p; +ibcs2_sys_readlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_readlink_args /* { syscallarg(const char *) path; syscallarg(char *) buf; syscallarg(int) count; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path)); - return sys_readlink(p, uap, retval); + return sys_readlink(l, uap, retval); } /* * mmap compat code borrowed from svr4/svr4_misc.c */ int -ibcs2_sys_mmap(p, v, retval) - struct proc *p; +ibcs2_sys_mmap(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_mmap_args /* { @@ -1480,8 +1511,9 @@ syscallarg(int) flags; syscallarg(int) fd; syscallarg(ibcs2_off_t) off; } */ *uap = v; + struct proc *p = l->l_proc; struct sys_mmap_args mm; void *rp; #define _MAP_NEW 0x80000000 /* XXX why? */ @@ -1502,14 +1534,14 @@ if ((SCARG(&mm, flags) & MAP_FIXED) == 0 && SCARG(&mm, addr) != 0 && SCARG(&mm, addr) < rp) SCARG(&mm, addr) = rp; - return sys_mmap(p, &mm, retval); + return sys_mmap(l, &mm, retval); } int -ibcs2_sys_memcntl(p, v, retval) - struct proc *p; +ibcs2_sys_memcntl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_memcntl_args /* { @@ -1529,9 +1561,9 @@ SCARG(&msa, addr) = SCARG(uap, addr); SCARG(&msa, len) = SCARG(uap, len); SCARG(&msa, flags) = (int)SCARG(uap, arg); - return sys___msync13(p, &msa, retval); + return sys___msync13(l, &msa, retval); } #ifdef IBCS2_MC_ADVISE /* supported? */ case IBCS2_MC_ADVISE: { @@ -1540,9 +1572,9 @@ SCARG(&maa, addr) = SCARG(uap, addr); SCARG(&maa, len) = SCARG(uap, len); SCARG(&maa, behav) = (int)SCARG(uap, arg); - return sys_madvise(p, &maa, retval); + return sys_madvise(l, &maa, retval); } #endif case IBCS2_MC_LOCK: case IBCS2_MC_UNLOCK: @@ -1554,10 +1586,10 @@ } } int -ibcs2_sys_gettimeofday(p, v, retval) - struct proc *p; +ibcs2_sys_gettimeofday(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_gettimeofday_args /* { @@ -1574,10 +1606,10 @@ return 0; } int -ibcs2_sys_settimeofday(p, v, retval) - struct proc *p; +ibcs2_sys_settimeofday(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_settimeofday_args /* { @@ -1586,21 +1618,22 @@ struct sys_settimeofday_args ap; SCARG(&ap, tv) = SCARG(uap, tp); SCARG(&ap, tzp) = NULL; - return sys_settimeofday(p, &ap, retval); + return sys_settimeofday(l, &ap, retval); } int -ibcs2_sys_scoinfo(p, v, retval) - struct proc *p; +ibcs2_sys_scoinfo(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_scoinfo_args /* { syscallarg(struct scoutsname *) bp; syscallarg(int) len; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); struct scoutsname *utsp = stackgap_alloc(&sg, sizeof(struct scoutsname)); @@ -1631,18 +1664,19 @@ #define X_LK_SETLKW 7 #define X_LK_TESTLK 8 int -xenix_sys_locking(p, v, retval) - struct proc *p; +xenix_sys_locking(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct xenix_sys_locking_args /* { syscallarg(int) fd; syscallarg(int) blk; syscallarg(int) size; } */ *uap = v; + struct proc *p = l->l_proc; struct sys_fcntl_args fa; struct flock *flp; struct filedesc *fdp = p->p_fd; struct file *fp; @@ -1653,9 +1687,9 @@ switch SCARG(uap, blk) { case X_LK_GETLK: case X_LK_SETLK: case X_LK_SETLKW: - return ibcs2_sys_fcntl(p, v, retval); + return ibcs2_sys_fcntl(l, v, retval); } if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) @@ -1690,6 +1724,6 @@ SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = cmd; SCARG(&fa, arg) = (void *)flp; - return sys_fcntl(p, &fa, retval); + return sys_fcntl(l, &fa, retval); } Index: sys/compat/ibcs2/ibcs2_signal.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/ibcs2/ibcs2_signal.c,v retrieving revision 1.13 retrieving revision 1.13.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.13 -r1.13.2.1 --- sys/compat/ibcs2/ibcs2_signal.c 2001/01/18 20:28:25 1.13 +++ sys/compat/ibcs2/ibcs2_signal.c 2001/03/05 22:49:22 1.13.2.1 @@ -29,8 +29,9 @@ #include #include #include +#include #include #include #include #include @@ -241,18 +242,19 @@ sss->ss_flags |= IBCS2_SS_ONSTACK; } int -ibcs2_sys_sigaction(p, v, retval) - struct proc *p; +ibcs2_sys_sigaction(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_sigaction_args /* { syscallarg(int) signum; syscallarg(const struct ibcs2_sigaction *) nsa; syscallarg(struct ibcs2_sigaction *) osa; } */ *uap = v; + struct proc *p = l->l_proc; struct ibcs2_sigaction nisa, oisa; struct sigaction nbsa, obsa; int error; @@ -275,17 +277,18 @@ return (0); } int -ibcs2_sys_sigaltstack(p, v, retval) - struct proc *p; +ibcs2_sys_sigaltstack(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_sigaltstack_args /* { syscallarg(const struct ibcs2_sigaltstack *) nss; syscallarg(struct ibcs2_sigaltstack *) oss; } */ *uap = v; + struct proc *p = l->l_proc; struct ibcs2_sigaltstack nsss, osss; struct sigaltstack nbss, obss; int error; @@ -308,17 +311,18 @@ return (0); } int -ibcs2_sys_sigsys(p, v, retval) - struct proc *p; +ibcs2_sys_sigsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_sigsys_args /* { syscallarg(int) sig; syscallarg(ibcs2_sig_t) fp; } */ *uap = v; + struct proc *p = l->l_proc; int signum = ibcs2_to_native_sig[IBCS2_SIGNO(SCARG(uap, sig))]; struct sigaction nbsa, obsa; sigset_t ss; int error; @@ -369,18 +373,19 @@ } } int -ibcs2_sys_sigprocmask(p, v, retval) - struct proc *p; +ibcs2_sys_sigprocmask(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_sigprocmask_args /* { syscallarg(int) how; syscallarg(const ibcs2_sigset_t *) set; syscallarg(ibcs2_sigset_t *) oset; } */ *uap = v; + struct proc *p = l->l_proc; ibcs2_sigset_t niss, oiss; sigset_t nbss, obss; int how; int error; @@ -418,16 +423,17 @@ return (0); } int -ibcs2_sys_sigpending(p, v, retval) - struct proc *p; +ibcs2_sys_sigpending(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_sigpending_args /* { syscallarg(ibcs2_sigset_t *) set; } */ *uap = v; + struct proc *p = l->l_proc; sigset_t bss; ibcs2_sigset_t iss; sigpending1(p, &bss); @@ -435,16 +441,17 @@ return (copyout(&iss, SCARG(uap, set), sizeof(iss))); } int -ibcs2_sys_sigsuspend(p, v, retval) - struct proc *p; +ibcs2_sys_sigsuspend(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_sigsuspend_args /* { syscallarg(const ibcs2_sigset_t *) set; } */ *uap = v; + struct proc *p = l->l_proc; ibcs2_sigset_t sss; sigset_t bss; int error; @@ -458,20 +465,20 @@ return (sigsuspend1(p, SCARG(uap, set) ? &bss : 0)); } int -ibcs2_sys_pause(p, v, retval) - struct proc *p; +ibcs2_sys_pause(l, v, retval) + struct lwp *l; void *v; register_t *retval; { - return (sigsuspend1(p, 0)); + return (sigsuspend1(l->l_proc, 0)); } int -ibcs2_sys_kill(p, v, retval) - struct proc *p; +ibcs2_sys_kill(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_kill_args /* { @@ -481,6 +488,6 @@ struct sys_kill_args ka; SCARG(&ka, pid) = SCARG(uap, pid); SCARG(&ka, signum) = ibcs2_to_native_sig[SCARG(uap, signo)]; - return sys_kill(p, &ka, retval); + return sys_kill(l, &ka, retval); } Index: sys/compat/ibcs2/ibcs2_socksys.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/ibcs2/ibcs2_socksys.c,v retrieving revision 1.8 retrieving revision 1.8.6.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.8 -r1.8.6.1 --- sys/compat/ibcs2/ibcs2_socksys.c 2000/03/30 11:27:16 1.8 +++ sys/compat/ibcs2/ibcs2_socksys.c 2001/03/05 22:49:22 1.8.6.1 @@ -26,8 +26,9 @@ */ #include #include +#include #include #include #include #include @@ -54,10 +55,10 @@ caddr_t argsp; }; int -ibcs2_socksys(p, v, retval) - struct proc *p; +ibcs2_socksys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_socksys_args *uap = v; @@ -77,57 +78,57 @@ realargs[0], realargs[1], realargs[2], realargs[3], realargs[4], realargs[5], realargs[6])); switch (realargs[0]) { case SOCKSYS_ACCEPT: - return sys_accept(p, realargs + 1, retval); + return sys_accept(l, realargs + 1, retval); case SOCKSYS_BIND: - return sys_bind(p, realargs + 1, retval); + return sys_bind(l, realargs + 1, retval); case SOCKSYS_CONNECT: - return sys_connect(p, realargs + 1, retval); + return sys_connect(l, realargs + 1, retval); case SOCKSYS_GETPEERNAME: - return sys_getpeername(p, realargs + 1, retval); + return sys_getpeername(l, realargs + 1, retval); case SOCKSYS_GETSOCKNAME: - return sys_getsockname(p, realargs + 1, retval); + return sys_getsockname(l, realargs + 1, retval); case SOCKSYS_GETSOCKOPT: - return sys_getsockopt(p, realargs + 1, retval); + return sys_getsockopt(l, realargs + 1, retval); case SOCKSYS_LISTEN: - return sys_listen(p, realargs + 1, retval); + return sys_listen(l, realargs + 1, retval); case SOCKSYS_RECV: realargs[5] = realargs[6] = 0; /* FALLTHROUGH */ case SOCKSYS_RECVFROM: - return sys_recvfrom(p, realargs + 1, retval); + return sys_recvfrom(l, realargs + 1, retval); case SOCKSYS_SEND: realargs[5] = realargs[6] = 0; /* FALLTHROUGH */ case SOCKSYS_SENDTO: - return sys_sendto(p, realargs + 1, retval); + return sys_sendto(l, realargs + 1, retval); case SOCKSYS_SETSOCKOPT: - return sys_setsockopt(p, realargs + 1, retval); + return sys_setsockopt(l, realargs + 1, retval); case SOCKSYS_SHUTDOWN: - return sys_shutdown(p, realargs + 1, retval); + return sys_shutdown(l, realargs + 1, retval); case SOCKSYS_SOCKET: - return sys_socket(p, realargs + 1, retval); + return sys_socket(l, realargs + 1, retval); case SOCKSYS_SELECT: - return sys_select(p, realargs + 1, retval); + return sys_select(l, realargs + 1, retval); case SOCKSYS_GETIPDOMAIN: - return compat_09_sys_getdomainname(p, realargs + 1, retval); + return compat_09_sys_getdomainname(l, realargs + 1, retval); case SOCKSYS_SETIPDOMAIN: - return compat_09_sys_setdomainname(p, realargs + 1, retval); + return compat_09_sys_setdomainname(l, realargs + 1, retval); case SOCKSYS_ADJTIME: - return sys_adjtime(p, realargs + 1, retval); + return sys_adjtime(l, realargs + 1, retval); case SOCKSYS_SETREUID: - return sys_setreuid(p, realargs + 1, retval); + return sys_setreuid(l, realargs + 1, retval); case SOCKSYS_SETREGID: - return sys_setregid(p, realargs + 1, retval); + return sys_setregid(l, realargs + 1, retval); case SOCKSYS_GETTIME: - return sys_gettimeofday(p, realargs + 1, retval); + return sys_gettimeofday(l, realargs + 1, retval); case SOCKSYS_SETTIME: - return sys_settimeofday(p, realargs + 1, retval); + return sys_settimeofday(l, realargs + 1, retval); case SOCKSYS_GETITIMER: - return sys_getitimer(p, realargs + 1, retval); + return sys_getitimer(l, realargs + 1, retval); case SOCKSYS_SETITIMER: - return sys_setitimer(p, realargs + 1, retval); + return sys_setitimer(l, realargs + 1, retval); default: printf("socksys unknown %08x %08x %08x %08x %08x %08x %08x\n", realargs[0], realargs[1], realargs[2], realargs[3], Index: sys/compat/ibcs2/ibcs2_socksys.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/ibcs2/ibcs2_socksys.h,v retrieving revision 1.2 retrieving revision 1.2.42.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.2 -r1.2.42.1 --- sys/compat/ibcs2/ibcs2_socksys.h 1996/05/03 17:05:30 1.2 +++ sys/compat/ibcs2/ibcs2_socksys.h 2001/03/05 22:49:22 1.2.42.1 @@ -116,7 +116,7 @@ ibcs2_dev_t dev; int flags; }; -int ibcs2_socksys __P((struct proc *, void *, register_t *)); +int ibcs2_socksys __P((struct lwp *, void *, register_t *)); #endif /* _IBCS2_SOCKSYS_H */ Index: sys/compat/ibcs2/ibcs2_stat.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/ibcs2/ibcs2_stat.c,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.17 -r1.17.2.1 --- sys/compat/ibcs2/ibcs2_stat.c 2000/12/01 12:28:32 1.17 +++ sys/compat/ibcs2/ibcs2_stat.c 2001/03/05 22:49:22 1.17.2.1 @@ -121,10 +121,10 @@ return copyout((caddr_t)&ssvfs, buf, len); } int -ibcs2_sys_statfs(p, v, retval) - struct proc *p; +ibcs2_sys_statfs(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_statfs_args /* { @@ -132,8 +132,9 @@ syscallarg(struct ibcs2_statfs *) buf; syscallarg(int) len; syscallarg(int) fstype; } */ *uap = v; + struct proc *p = l->l_proc; struct mount *mp; struct statfs *sp; int error; struct nameidata nd; @@ -152,10 +153,10 @@ return cvt_statfs(sp, (caddr_t)SCARG(uap, buf), SCARG(uap, len)); } int -ibcs2_sys_fstatfs(p, v, retval) - struct proc *p; +ibcs2_sys_fstatfs(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_fstatfs_args /* { @@ -163,8 +164,9 @@ syscallarg(struct ibcs2_statfs *) buf; syscallarg(int) len; syscallarg(int) fstype; } */ *uap = v; + struct proc *p = l->l_proc; struct file *fp; struct mount *mp; struct statfs *sp; int error; @@ -183,17 +185,18 @@ return (error); } int -ibcs2_sys_statvfs(p, v, retval) - struct proc *p; +ibcs2_sys_statvfs(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_statvfs_args /* { syscallarg(const char *) path; syscallarg(struct ibcs2_statvfs *) buf; } */ *uap = v; + struct proc *p = l->l_proc; struct mount *mp; struct statfs *sp; int error; struct nameidata nd; @@ -213,17 +216,18 @@ sizeof(struct ibcs2_statvfs)); } int -ibcs2_sys_fstatvfs(p, v, retval) - struct proc *p; +ibcs2_sys_fstatvfs(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_fstatvfs_args /* { syscallarg(int) fd; syscallarg(struct ibcs2_statvfs *) buf; } */ *uap = v; + struct proc *p = l->l_proc; struct file *fp; struct mount *mp; struct statfs *sp; int error; @@ -243,17 +247,18 @@ return (error); } int -ibcs2_sys_stat(p, v, retval) - struct proc *p; +ibcs2_sys_stat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_stat_args /* { syscallarg(const char *) path; syscallarg(struct ibcs2_stat *) st; } */ *uap = v; + struct proc *p = l->l_proc; struct stat st; struct ibcs2_stat ibcs2_st; struct sys___stat13_args cup; int error; @@ -261,9 +266,9 @@ SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(st)); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); - if ((error = sys___stat13(p, &cup, retval)) != 0) + if ((error = sys___stat13(l, &cup, retval)) != 0) return error; if ((error = copyin(SCARG(&cup, ub), &st, sizeof(st))) != 0) return error; bsd_stat2ibcs_stat(&st, &ibcs2_st); @@ -271,17 +276,18 @@ ibcs2_stat_len); } int -ibcs2_sys_lstat(p, v, retval) - struct proc *p; +ibcs2_sys_lstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_lstat_args /* { syscallarg(const char *) path; syscallarg(struct ibcs2_stat *) st; } */ *uap = v; + struct proc *p = l->l_proc; struct stat st; struct ibcs2_stat ibcs2_st; struct sys___lstat13_args cup; int error; @@ -290,9 +296,9 @@ SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(st)); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); - if ((error = sys___lstat13(p, &cup, retval)) != 0) + if ((error = sys___lstat13(l, &cup, retval)) != 0) return error; if ((error = copyin(SCARG(&cup, ub), &st, sizeof(st))) != 0) return error; bsd_stat2ibcs_stat(&st, &ibcs2_st); @@ -300,26 +306,27 @@ ibcs2_stat_len); } int -ibcs2_sys_fstat(p, v, retval) - struct proc *p; +ibcs2_sys_fstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_fstat_args /* { syscallarg(int) fd; syscallarg(struct ibcs2_stat *) st; } */ *uap = v; + struct proc *p = l->l_proc; struct stat st; struct ibcs2_stat ibcs2_st; struct sys___fstat13_args cup; int error; caddr_t sg = stackgap_init(p->p_emul); SCARG(&cup, fd) = SCARG(uap, fd); SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(st)); - if ((error = sys___fstat13(p, &cup, retval)) != 0) + if ((error = sys___fstat13(l, &cup, retval)) != 0) return error; if ((error = copyin(SCARG(&cup, sb), &st, sizeof(st))) != 0) return error; bsd_stat2ibcs_stat(&st, &ibcs2_st); @@ -327,10 +334,10 @@ ibcs2_stat_len); } int -ibcs2_sys_utssys(p, v, retval) - struct proc *p; +ibcs2_sys_utssys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct ibcs2_sys_utssys_args /* { Index: sys/compat/ibcs2/ibcs2_syscallargs.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/ibcs2/ibcs2_syscallargs.h,v retrieving revision 1.32 retrieving revision 1.32.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.32 -r1.32.2.1 --- sys/compat/ibcs2/ibcs2_syscallargs.h 2001/01/27 07:25:50 1.32 +++ sys/compat/ibcs2/ibcs2_syscallargs.h 2001/03/05 22:49:22 1.32.2.1 @@ -421,117 +421,117 @@ /* * System call prototypes. */ -int sys_nosys(struct proc *, void *, register_t *); -int sys_exit(struct proc *, void *, register_t *); -int sys_fork(struct proc *, void *, register_t *); -int ibcs2_sys_read(struct proc *, void *, register_t *); -int sys_write(struct proc *, void *, register_t *); -int ibcs2_sys_open(struct proc *, void *, register_t *); -int sys_close(struct proc *, void *, register_t *); -int ibcs2_sys_waitsys(struct proc *, void *, register_t *); -int ibcs2_sys_creat(struct proc *, void *, register_t *); -int sys_link(struct proc *, void *, register_t *); -int ibcs2_sys_unlink(struct proc *, void *, register_t *); -int ibcs2_sys_execv(struct proc *, void *, register_t *); -int ibcs2_sys_chdir(struct proc *, void *, register_t *); -int ibcs2_sys_time(struct proc *, void *, register_t *); -int ibcs2_sys_mknod(struct proc *, void *, register_t *); -int ibcs2_sys_chmod(struct proc *, void *, register_t *); -int ibcs2_sys_chown(struct proc *, void *, register_t *); -int sys_obreak(struct proc *, void *, register_t *); -int ibcs2_sys_stat(struct proc *, void *, register_t *); -int compat_43_sys_lseek(struct proc *, void *, register_t *); -int sys_getpid_with_ppid(struct proc *, void *, register_t *); -int ibcs2_sys_mount(struct proc *, void *, register_t *); -int ibcs2_sys_umount(struct proc *, void *, register_t *); -int ibcs2_sys_setuid(struct proc *, void *, register_t *); -int sys_getuid_with_euid(struct proc *, void *, register_t *); -int ibcs2_sys_stime(struct proc *, void *, register_t *); -int ibcs2_sys_alarm(struct proc *, void *, register_t *); -int ibcs2_sys_fstat(struct proc *, void *, register_t *); -int ibcs2_sys_pause(struct proc *, void *, register_t *); -int ibcs2_sys_utime(struct proc *, void *, register_t *); -int ibcs2_sys_gtty(struct proc *, void *, register_t *); -int ibcs2_sys_access(struct proc *, void *, register_t *); -int ibcs2_sys_nice(struct proc *, void *, register_t *); -int ibcs2_sys_statfs(struct proc *, void *, register_t *); -int sys_sync(struct proc *, void *, register_t *); -int ibcs2_sys_kill(struct proc *, void *, register_t *); -int ibcs2_sys_fstatfs(struct proc *, void *, register_t *); -int ibcs2_sys_pgrpsys(struct proc *, void *, register_t *); -int sys_dup(struct proc *, void *, register_t *); -int sys_pipe(struct proc *, void *, register_t *); -int ibcs2_sys_times(struct proc *, void *, register_t *); -int ibcs2_sys_plock(struct proc *, void *, register_t *); -int ibcs2_sys_setgid(struct proc *, void *, register_t *); -int sys_getgid_with_egid(struct proc *, void *, register_t *); -int ibcs2_sys_sigsys(struct proc *, void *, register_t *); +int sys_nosys(struct lwp *, void *, register_t *); +int sys_exit(struct lwp *, void *, register_t *); +int sys_fork(struct lwp *, void *, register_t *); +int ibcs2_sys_read(struct lwp *, void *, register_t *); +int sys_write(struct lwp *, void *, register_t *); +int ibcs2_sys_open(struct lwp *, void *, register_t *); +int sys_close(struct lwp *, void *, register_t *); +int ibcs2_sys_waitsys(struct lwp *, void *, register_t *); +int ibcs2_sys_creat(struct lwp *, void *, register_t *); +int sys_link(struct lwp *, void *, register_t *); +int ibcs2_sys_unlink(struct lwp *, void *, register_t *); +int ibcs2_sys_execv(struct lwp *, void *, register_t *); +int ibcs2_sys_chdir(struct lwp *, void *, register_t *); +int ibcs2_sys_time(struct lwp *, void *, register_t *); +int ibcs2_sys_mknod(struct lwp *, void *, register_t *); +int ibcs2_sys_chmod(struct lwp *, void *, register_t *); +int ibcs2_sys_chown(struct lwp *, void *, register_t *); +int sys_obreak(struct lwp *, void *, register_t *); +int ibcs2_sys_stat(struct lwp *, void *, register_t *); +int compat_43_sys_lseek(struct lwp *, void *, register_t *); +int sys_getpid_with_ppid(struct lwp *, void *, register_t *); +int ibcs2_sys_mount(struct lwp *, void *, register_t *); +int ibcs2_sys_umount(struct lwp *, void *, register_t *); +int ibcs2_sys_setuid(struct lwp *, void *, register_t *); +int sys_getuid_with_euid(struct lwp *, void *, register_t *); +int ibcs2_sys_stime(struct lwp *, void *, register_t *); +int ibcs2_sys_alarm(struct lwp *, void *, register_t *); +int ibcs2_sys_fstat(struct lwp *, void *, register_t *); +int ibcs2_sys_pause(struct lwp *, void *, register_t *); +int ibcs2_sys_utime(struct lwp *, void *, register_t *); +int ibcs2_sys_gtty(struct lwp *, void *, register_t *); +int ibcs2_sys_access(struct lwp *, void *, register_t *); +int ibcs2_sys_nice(struct lwp *, void *, register_t *); +int ibcs2_sys_statfs(struct lwp *, void *, register_t *); +int sys_sync(struct lwp *, void *, register_t *); +int ibcs2_sys_kill(struct lwp *, void *, register_t *); +int ibcs2_sys_fstatfs(struct lwp *, void *, register_t *); +int ibcs2_sys_pgrpsys(struct lwp *, void *, register_t *); +int sys_dup(struct lwp *, void *, register_t *); +int sys_pipe(struct lwp *, void *, register_t *); +int ibcs2_sys_times(struct lwp *, void *, register_t *); +int ibcs2_sys_plock(struct lwp *, void *, register_t *); +int ibcs2_sys_setgid(struct lwp *, void *, register_t *); +int sys_getgid_with_egid(struct lwp *, void *, register_t *); +int ibcs2_sys_sigsys(struct lwp *, void *, register_t *); #ifdef SYSVMSG -int ibcs2_sys_msgsys(struct proc *, void *, register_t *); +int ibcs2_sys_msgsys(struct lwp *, void *, register_t *); #else #endif -int ibcs2_sys_sysmachine(struct proc *, void *, register_t *); +int ibcs2_sys_sysmachine(struct lwp *, void *, register_t *); #ifdef SYSVSHM -int ibcs2_sys_shmsys(struct proc *, void *, register_t *); +int ibcs2_sys_shmsys(struct lwp *, void *, register_t *); #else #endif #ifdef SYSVSEM -int ibcs2_sys_semsys(struct proc *, void *, register_t *); +int ibcs2_sys_semsys(struct lwp *, void *, register_t *); #else #endif -int ibcs2_sys_ioctl(struct proc *, void *, register_t *); -int ibcs2_sys_uadmin(struct proc *, void *, register_t *); -int ibcs2_sys_utssys(struct proc *, void *, register_t *); -int sys_fsync(struct proc *, void *, register_t *); -int ibcs2_sys_execve(struct proc *, void *, register_t *); -int sys_umask(struct proc *, void *, register_t *); -int sys_chroot(struct proc *, void *, register_t *); -int ibcs2_sys_fcntl(struct proc *, void *, register_t *); -int ibcs2_sys_ulimit(struct proc *, void *, register_t *); -int ibcs2_sys_rmdir(struct proc *, void *, register_t *); -int ibcs2_sys_mkdir(struct proc *, void *, register_t *); -int ibcs2_sys_getdents(struct proc *, void *, register_t *); -int ibcs2_sys_sysfs(struct proc *, void *, register_t *); -int ibcs2_sys_getmsg(struct proc *, void *, register_t *); -int ibcs2_sys_putmsg(struct proc *, void *, register_t *); -int sys_poll(struct proc *, void *, register_t *); -int ibcs2_sys_symlink(struct proc *, void *, register_t *); -int ibcs2_sys_lstat(struct proc *, void *, register_t *); -int ibcs2_sys_readlink(struct proc *, void *, register_t *); -int sys_fchmod(struct proc *, void *, register_t *); -int sys___posix_fchown(struct proc *, void *, register_t *); -int sys___sigreturn14(struct proc *, void *, register_t *); -int ibcs2_sys_sigaltstack(struct proc *, void *, register_t *); -int ibcs2_sys_statvfs(struct proc *, void *, register_t *); -int ibcs2_sys_fstatvfs(struct proc *, void *, register_t *); -int ibcs2_sys_mmap(struct proc *, void *, register_t *); -int sys_mprotect(struct proc *, void *, register_t *); -int sys_munmap(struct proc *, void *, register_t *); -int sys_fchdir(struct proc *, void *, register_t *); -int sys_readv(struct proc *, void *, register_t *); -int sys_writev(struct proc *, void *, register_t *); -int ibcs2_sys_memcntl(struct proc *, void *, register_t *); -int ibcs2_sys_gettimeofday(struct proc *, void *, register_t *); -int ibcs2_sys_settimeofday(struct proc *, void *, register_t *); -int compat_43_sys_truncate(struct proc *, void *, register_t *); -int compat_43_sys_ftruncate(struct proc *, void *, register_t *); -int xenix_sys_locking(struct proc *, void *, register_t *); -int xenix_sys_rdchk(struct proc *, void *, register_t *); -int xenix_sys_chsize(struct proc *, void *, register_t *); -int xenix_sys_ftime(struct proc *, void *, register_t *); -int xenix_sys_nap(struct proc *, void *, register_t *); -int sys_select(struct proc *, void *, register_t *); -int ibcs2_sys_eaccess(struct proc *, void *, register_t *); -int ibcs2_sys_sigaction(struct proc *, void *, register_t *); -int ibcs2_sys_sigprocmask(struct proc *, void *, register_t *); -int ibcs2_sys_sigpending(struct proc *, void *, register_t *); -int ibcs2_sys_sigsuspend(struct proc *, void *, register_t *); -int ibcs2_sys_getgroups(struct proc *, void *, register_t *); -int ibcs2_sys_setgroups(struct proc *, void *, register_t *); -int ibcs2_sys_sysconf(struct proc *, void *, register_t *); -int ibcs2_sys_pathconf(struct proc *, void *, register_t *); -int ibcs2_sys_fpathconf(struct proc *, void *, register_t *); -int ibcs2_sys_rename(struct proc *, void *, register_t *); -int ibcs2_sys_scoinfo(struct proc *, void *, register_t *); +int ibcs2_sys_ioctl(struct lwp *, void *, register_t *); +int ibcs2_sys_uadmin(struct lwp *, void *, register_t *); +int ibcs2_sys_utssys(struct lwp *, void *, register_t *); +int sys_fsync(struct lwp *, void *, register_t *); +int ibcs2_sys_execve(struct lwp *, void *, register_t *); +int sys_umask(struct lwp *, void *, register_t *); +int sys_chroot(struct lwp *, void *, register_t *); +int ibcs2_sys_fcntl(struct lwp *, void *, register_t *); +int ibcs2_sys_ulimit(struct lwp *, void *, register_t *); +int ibcs2_sys_rmdir(struct lwp *, void *, register_t *); +int ibcs2_sys_mkdir(struct lwp *, void *, register_t *); +int ibcs2_sys_getdents(struct lwp *, void *, register_t *); +int ibcs2_sys_sysfs(struct lwp *, void *, register_t *); +int ibcs2_sys_getmsg(struct lwp *, void *, register_t *); +int ibcs2_sys_putmsg(struct lwp *, void *, register_t *); +int sys_poll(struct lwp *, void *, register_t *); +int ibcs2_sys_symlink(struct lwp *, void *, register_t *); +int ibcs2_sys_lstat(struct lwp *, void *, register_t *); +int ibcs2_sys_readlink(struct lwp *, void *, register_t *); +int sys_fchmod(struct lwp *, void *, register_t *); +int sys___posix_fchown(struct lwp *, void *, register_t *); +int sys___sigreturn14(struct lwp *, void *, register_t *); +int ibcs2_sys_sigaltstack(struct lwp *, void *, register_t *); +int ibcs2_sys_statvfs(struct lwp *, void *, register_t *); +int ibcs2_sys_fstatvfs(struct lwp *, void *, register_t *); +int ibcs2_sys_mmap(struct lwp *, void *, register_t *); +int sys_mprotect(struct lwp *, void *, register_t *); +int sys_munmap(struct lwp *, void *, register_t *); +int sys_fchdir(struct lwp *, void *, register_t *); +int sys_readv(struct lwp *, void *, register_t *); +int sys_writev(struct lwp *, void *, register_t *); +int ibcs2_sys_memcntl(struct lwp *, void *, register_t *); +int ibcs2_sys_gettimeofday(struct lwp *, void *, register_t *); +int ibcs2_sys_settimeofday(struct lwp *, void *, register_t *); +int compat_43_sys_truncate(struct lwp *, void *, register_t *); +int compat_43_sys_ftruncate(struct lwp *, void *, register_t *); +int xenix_sys_locking(struct lwp *, void *, register_t *); +int xenix_sys_rdchk(struct lwp *, void *, register_t *); +int xenix_sys_chsize(struct lwp *, void *, register_t *); +int xenix_sys_ftime(struct lwp *, void *, register_t *); +int xenix_sys_nap(struct lwp *, void *, register_t *); +int sys_select(struct lwp *, void *, register_t *); +int ibcs2_sys_eaccess(struct lwp *, void *, register_t *); +int ibcs2_sys_sigaction(struct lwp *, void *, register_t *); +int ibcs2_sys_sigprocmask(struct lwp *, void *, register_t *); +int ibcs2_sys_sigpending(struct lwp *, void *, register_t *); +int ibcs2_sys_sigsuspend(struct lwp *, void *, register_t *); +int ibcs2_sys_getgroups(struct lwp *, void *, register_t *); +int ibcs2_sys_setgroups(struct lwp *, void *, register_t *); +int ibcs2_sys_sysconf(struct lwp *, void *, register_t *); +int ibcs2_sys_pathconf(struct lwp *, void *, register_t *); +int ibcs2_sys_fpathconf(struct lwp *, void *, register_t *); +int ibcs2_sys_rename(struct lwp *, void *, register_t *); +int ibcs2_sys_scoinfo(struct lwp *, void *, register_t *); #endif /* _IBCS2_SYS__SYSCALLARGS_H_ */ Index: sys/compat/linux/arch/i386/linux_machdep.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/arch/i386/linux_machdep.c,v retrieving revision 1.62 retrieving revision 1.62.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.62 -r1.62.2.1 --- sys/compat/linux/arch/i386/linux_machdep.c 2001/01/26 19:41:52 1.62 +++ sys/compat/linux/arch/i386/linux_machdep.c 2001/03/05 22:49:23 1.62.2.1 @@ -45,8 +45,9 @@ #include #include #include #include +#include #include #include #include #include @@ -102,11 +103,11 @@ #endif #ifdef USER_LDT #include -int linux_read_ldt __P((struct proc *, struct linux_sys_modify_ldt_args *, +int linux_read_ldt __P((struct lwp *, struct linux_sys_modify_ldt_args *, register_t *)); -int linux_write_ldt __P((struct proc *, struct linux_sys_modify_ldt_args *, +int linux_write_ldt __P((struct lwp *, struct linux_sys_modify_ldt_args *, register_t *)); #endif static struct biosdisk_info *fd2biosinfo __P((struct proc *, struct file *)); @@ -117,16 +118,16 @@ * Deal with some i386-specific things in the Linux emulation code. */ void -linux_setregs(p, epp, stack) - struct proc *p; +linux_setregs(l, epp, stack) + struct lwp *l; struct exec_package *epp; u_long stack; { - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = &l->l_addr->u_pcb; - setregs(p, epp, stack); + setregs(l, epp, stack); pcb->pcb_savefpu.sv_env.en_cw = __Linux_NPXCW__; } /* @@ -146,13 +147,14 @@ int sig; sigset_t *mask; u_long code; { - struct proc *p = curproc; + struct lwp *l = curproc; + struct proc *p = l->l_proc; struct trapframe *tf; struct linux_sigframe *fp, frame; - tf = p->p_md.md_regs; + tf = l->l_md.md_regs; /* Allocate space for the signal handler context. */ /* XXX Linux doesn't support the signal stack. */ fp = (struct linux_sigframe *)tf->tf_esp; @@ -168,9 +170,9 @@ frame.sf_sc.sc_gs = tf->tf_vm86_gs; frame.sf_sc.sc_fs = tf->tf_vm86_fs; frame.sf_sc.sc_es = tf->tf_vm86_es; frame.sf_sc.sc_ds = tf->tf_vm86_ds; - frame.sf_sc.sc_eflags = get_vflags(p); + frame.sf_sc.sc_eflags = get_vflags(l); } else #endif { __asm("movl %%gs,%w0" : "=r" (frame.sf_sc.sc_gs)); @@ -203,9 +205,9 @@ /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ - sigexit(p, SIGILL); + sigexit(l, SIGILL); /* NOTREACHED */ } /* @@ -233,26 +235,27 @@ * psl to gain improper privileges or to cause * a machine fault. */ int -linux_sys_rt_sigreturn(p, v, retval) - struct proc *p; +linux_sys_rt_sigreturn(l, v, retval) + struct lwp *l; void *v; register_t *retval; { /* XXX XAX write me */ return(ENOSYS); } int -linux_sys_sigreturn(p, v, retval) - struct proc *p; +linux_sys_sigreturn(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_sigreturn_args /* { syscallarg(struct linux_sigcontext *) scp; } */ *uap = v; + struct proc *p = l->l_proc; struct linux_sigcontext *scp, context; struct trapframe *tf; sigset_t mask; @@ -265,16 +268,16 @@ if (copyin((caddr_t)scp, &context, sizeof(*scp)) != 0) return (EFAULT); /* Restore register context. */ - tf = p->p_md.md_regs; + tf = l->l_md.md_regs; #ifdef VM86 if (context.sc_eflags & PSL_VM) { tf->tf_vm86_gs = context.sc_gs; tf->tf_vm86_fs = context.sc_fs; tf->tf_vm86_es = context.sc_es; tf->tf_vm86_ds = context.sc_ds; - set_vflags(p, context.sc_eflags); + set_vflags(l, context.sc_eflags); } else #endif { /* @@ -316,17 +319,18 @@ #ifdef USER_LDT int -linux_read_ldt(p, uap, retval) - struct proc *p; +linux_read_ldt(l, uap, retval) + struct lwp *l; struct linux_sys_modify_ldt_args /* { syscallarg(int) func; syscallarg(void *) ptr; syscallarg(size_t) bytecount; } */ *uap; register_t *retval; { + struct proc *p = l->l_proc; struct i386_get_ldt_args gl; int error; caddr_t sg; char *parms; @@ -341,9 +345,9 @@ if ((error = copyout(&gl, parms, sizeof(gl))) != 0) return (error); - if ((error = i386_get_ldt(p, parms, retval)) != 0) + if ((error = i386_get_ldt(l, parms, retval)) != 0) return (error); *retval *= sizeof(union descriptor); return (0); @@ -360,17 +364,18 @@ u_int seg_not_present:1; }; int -linux_write_ldt(p, uap, retval) - struct proc *p; +linux_write_ldt(l, uap, retval) + struct lwp *l; struct linux_sys_modify_ldt_args /* { syscallarg(int) func; syscallarg(void *) ptr; syscallarg(size_t) bytecount; } */ *uap; register_t *retval; { + struct proc *p = l->l_proc; struct linux_ldt_info ldt_info; struct segment_descriptor sd; struct i386_set_ldt_args sl; int error; @@ -412,9 +417,9 @@ return (error); if ((error = copyout(&sl, parms, sizeof(sl))) != 0) return (error); - if ((error = i386_set_ldt(p, parms, retval)) != 0) + if ((error = i386_set_ldt(l, parms, retval)) != 0) return (error); *retval = 0; return (0); @@ -422,10 +427,10 @@ #endif /* USER_LDT */ int -linux_sys_modify_ldt(p, v, retval) - struct proc *p; +linux_sys_modify_ldt(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_modify_ldt_args /* { @@ -436,12 +441,12 @@ switch (SCARG(uap, func)) { #ifdef USER_LDT case 0: - return (linux_read_ldt(p, uap, retval)); + return (linux_read_ldt(l, uap, retval)); case 1: - return (linux_write_ldt(p, uap, retval)); + return (linux_write_ldt(l, uap, retval)); #endif /* USER_LDT */ default: return (ENOSYS); @@ -668,9 +673,10 @@ com = VT_OPENQRY; break; case LINUX_VT_GETMODE: SCARG(&bia, com) = VT_GETMODE; - if ((error = sys_ioctl(p, &bia, retval))) + /* XXX NJWLWP */ + if ((error = sys_ioctl(curproc, &bia, retval))) return error; if ((error = copyin(SCARG(uap, data), (caddr_t)&lvt, sizeof (struct vt_mode)))) return error; @@ -802,28 +808,30 @@ com); return error; } SCARG(&bia, com) = com; - return sys_ioctl(p, &bia, retval); + /* XXX NJWLWP */ + return sys_ioctl(curproc, &bia, retval); } /* * Set I/O permissions for a process. Just set the maximum level * right away (ignoring the argument), otherwise we would have * to rely on I/O permission maps, which are not implemented. */ int -linux_sys_iopl(p, v, retval) - struct proc *p; +linux_sys_iopl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #if 0 struct linux_sys_iopl_args /* { syscallarg(int) level; } */ *uap = v; #endif - struct trapframe *fp = p->p_md.md_regs; + struct proc *p = l->l_proc; + struct trapframe *fp = l->l_md.md_regs; if (suser(p->p_ucred, &p->p_acflag) != 0) return EPERM; fp->tf_eflags |= PSL_IOPL; @@ -835,19 +843,20 @@ * See above. If a root process tries to set access to an I/O port, * just let it have the whole range. */ int -linux_sys_ioperm(p, v, retval) - struct proc *p; +linux_sys_ioperm(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_ioperm_args /* { syscallarg(unsigned int) lo; syscallarg(unsigned int) hi; syscallarg(int) val; } */ *uap = v; - struct trapframe *fp = p->p_md.md_regs; + struct proc *p = l->l_proc; + struct trapframe *fp = l->l_md.md_regs; if (suser(p->p_ucred, &p->p_acflag) != 0) return EPERM; if (SCARG(uap, val)) Index: sys/compat/linux/arch/i386/linux_ptrace.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/arch/i386/linux_ptrace.c,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.5 -r1.5.2.1 --- sys/compat/linux/arch/i386/linux_ptrace.c 2000/11/21 12:28:15 1.5 +++ sys/compat/linux/arch/i386/linux_ptrace.c 2001/03/05 22:49:23 1.5.2.1 @@ -121,10 +121,10 @@ #define LUSR_OFF(member) offsetof(struct linux_user, member) #define ISSET(t, f) ((t) & (f)) int -linux_sys_ptrace_arch(p, v, retval) - struct proc *p; +linux_sys_ptrace_arch(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_ptrace_args /* { @@ -132,10 +132,12 @@ syscallarg(int) pid; syscallarg(int) addr; syscallarg(int) data; } */ *uap = v; + struct proc *p = l->l_proc; int request, error; struct proc *t; /* target process */ + struct lwp *lt; struct reg *regs = NULL; struct fpreg *fpregs = NULL; struct linux_reg *linux_regs = NULL; struct linux_fpreg *linux_fpregs = NULL; @@ -180,17 +182,28 @@ */ if (t->p_stat != SSTOP || !ISSET(t->p_flag, P_WAITED)) return EBUSY; + /* XXX NJWLWP + * The entire ptrace interface needs work to be useful to + * a process with multiple LWPs. For the moment, we'll + * just kluge this and fail on others. + */ + + if (p->p_nlwps > 1) + return (ENOSYS); + + lt = LIST_FIRST(&t->p_lwps); + *retval = 0; switch (request) { case LINUX_PTRACE_GETREGS: MALLOC(regs, struct reg*, sizeof(struct reg), M_TEMP, M_WAITOK); MALLOC(linux_regs, struct linux_reg*, sizeof(struct linux_reg), M_TEMP, M_WAITOK); - error = process_read_regs(t, regs); + error = process_read_regs(lt, regs); if (error != 0) goto out; linux_regs->ebx = regs->r_ebx; @@ -237,18 +250,18 @@ regs->r_eflags = linux_regs->eflags; regs->r_esp = linux_regs->esp; regs->r_ss = linux_regs->xss; - error = process_write_regs(t, regs); + error = process_write_regs(lt, regs); goto out; case LINUX_PTRACE_GETFPREGS: MALLOC(fpregs, struct fpreg *, sizeof(struct fpreg), M_TEMP, M_WAITOK); MALLOC(linux_fpregs, struct linux_fpreg *, sizeof(struct linux_fpreg), M_TEMP, M_WAITOK); - error = process_read_fpregs(t, fpregs); + error = process_read_fpregs(lt, fpregs); if (error != 0) goto out; /* zero the contents if NetBSD fpreg structure is smaller */ @@ -274,15 +287,15 @@ memset(fpregs, '\0', sizeof(struct fpreg)); memcpy(fpregs, linux_fpregs, min(sizeof(struct linux_fpreg), sizeof(struct fpreg))); - error = process_write_regs(t, regs); + error = process_write_regs(lt, regs); goto out; case LINUX_PTRACE_PEEKUSR: addr = SCARG(uap, addr); - PHOLD(t); /* need full process info */ + PHOLD(lt); /* need full process info */ error = 0; if (addr < LUSR_OFF(lusr_startgdb)) { /* XXX should provide appropriate register */ error = 1; @@ -325,9 +338,9 @@ #endif error = 1; } - PRELE(t); + PRELE(lt); if (!error) return 0; @@ -342,11 +355,11 @@ /* only do this for Linux processes */ if (t->p_emul != &emul_linux) return EINVAL; - PHOLD(t); + PHOLD(lt); ((struct linux_emuldata *)t->p_emuldata)->debugreg[off] = data; - PRELE(t); + PRELE(lt); return (0); } break; Index: sys/compat/linux/arch/i386/linux_syscallargs.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/arch/i386/linux_syscallargs.h,v retrieving revision 1.36 retrieving revision 1.34.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.36 -r1.34.2.2 --- sys/compat/linux/arch/i386/linux_syscallargs.h 2001/03/30 18:02:28 1.36 +++ sys/compat/linux/arch/i386/linux_syscallargs.h 2001/04/09 01:55:33 1.34.2.2 @@ -569,183 +569,183 @@ /* * System call prototypes. */ -int linux_sys_nosys(struct proc *, void *, register_t *); -int sys_exit(struct proc *, void *, register_t *); -int sys_fork(struct proc *, void *, register_t *); -int sys_read(struct proc *, void *, register_t *); -int sys_write(struct proc *, void *, register_t *); -int linux_sys_open(struct proc *, void *, register_t *); -int sys_close(struct proc *, void *, register_t *); -int linux_sys_waitpid(struct proc *, void *, register_t *); -int linux_sys_creat(struct proc *, void *, register_t *); -int linux_sys_link(struct proc *, void *, register_t *); -int linux_sys_unlink(struct proc *, void *, register_t *); -int linux_sys_execve(struct proc *, void *, register_t *); -int linux_sys_chdir(struct proc *, void *, register_t *); -int linux_sys_time(struct proc *, void *, register_t *); -int linux_sys_mknod(struct proc *, void *, register_t *); -int linux_sys_chmod(struct proc *, void *, register_t *); -int linux_sys_lchown16(struct proc *, void *, register_t *); -int linux_sys_break(struct proc *, void *, register_t *); -int compat_43_sys_lseek(struct proc *, void *, register_t *); -int sys_getpid(struct proc *, void *, register_t *); -int sys_setuid(struct proc *, void *, register_t *); -int sys_getuid(struct proc *, void *, register_t *); -int linux_sys_stime(struct proc *, void *, register_t *); -int linux_sys_ptrace(struct proc *, void *, register_t *); -int linux_sys_alarm(struct proc *, void *, register_t *); -int linux_sys_pause(struct proc *, void *, register_t *); -int linux_sys_utime(struct proc *, void *, register_t *); -int linux_sys_access(struct proc *, void *, register_t *); -int linux_sys_nice(struct proc *, void *, register_t *); -int sys_sync(struct proc *, void *, register_t *); -int linux_sys_kill(struct proc *, void *, register_t *); -int linux_sys_rename(struct proc *, void *, register_t *); -int linux_sys_mkdir(struct proc *, void *, register_t *); -int linux_sys_rmdir(struct proc *, void *, register_t *); -int sys_dup(struct proc *, void *, register_t *); -int linux_sys_pipe(struct proc *, void *, register_t *); -int linux_sys_times(struct proc *, void *, register_t *); -int linux_sys_brk(struct proc *, void *, register_t *); -int sys_setgid(struct proc *, void *, register_t *); -int sys_getgid(struct proc *, void *, register_t *); -int linux_sys_signal(struct proc *, void *, register_t *); -int sys_geteuid(struct proc *, void *, register_t *); -int sys_getegid(struct proc *, void *, register_t *); -int sys_acct(struct proc *, void *, register_t *); -int linux_sys_ioctl(struct proc *, void *, register_t *); -int linux_sys_fcntl(struct proc *, void *, register_t *); -int sys_setpgid(struct proc *, void *, register_t *); -int linux_sys_oldolduname(struct proc *, void *, register_t *); -int sys_umask(struct proc *, void *, register_t *); -int sys_chroot(struct proc *, void *, register_t *); -int sys_dup2(struct proc *, void *, register_t *); -int sys_getppid(struct proc *, void *, register_t *); -int sys_getpgrp(struct proc *, void *, register_t *); -int sys_setsid(struct proc *, void *, register_t *); -int linux_sys_sigaction(struct proc *, void *, register_t *); -int linux_sys_siggetmask(struct proc *, void *, register_t *); -int linux_sys_sigsetmask(struct proc *, void *, register_t *); -int linux_sys_setreuid16(struct proc *, void *, register_t *); -int linux_sys_setregid16(struct proc *, void *, register_t *); -int linux_sys_sigsuspend(struct proc *, void *, register_t *); -int linux_sys_sigpending(struct proc *, void *, register_t *); -int compat_43_sys_sethostname(struct proc *, void *, register_t *); -int compat_43_sys_setrlimit(struct proc *, void *, register_t *); -int compat_43_sys_getrlimit(struct proc *, void *, register_t *); -int sys_getrusage(struct proc *, void *, register_t *); -int sys_gettimeofday(struct proc *, void *, register_t *); -int sys_settimeofday(struct proc *, void *, register_t *); -int linux_sys_getgroups16(struct proc *, void *, register_t *); -int linux_sys_setgroups16(struct proc *, void *, register_t *); -int linux_sys_oldselect(struct proc *, void *, register_t *); -int linux_sys_symlink(struct proc *, void *, register_t *); -int compat_43_sys_lstat(struct proc *, void *, register_t *); -int linux_sys_readlink(struct proc *, void *, register_t *); -int linux_sys_uselib(struct proc *, void *, register_t *); -int linux_sys_swapon(struct proc *, void *, register_t *); -int linux_sys_reboot(struct proc *, void *, register_t *); -int linux_sys_readdir(struct proc *, void *, register_t *); -int linux_sys_old_mmap(struct proc *, void *, register_t *); -int sys_munmap(struct proc *, void *, register_t *); -int linux_sys_truncate(struct proc *, void *, register_t *); -int compat_43_sys_ftruncate(struct proc *, void *, register_t *); -int sys_fchmod(struct proc *, void *, register_t *); -int linux_sys_fchown16(struct proc *, void *, register_t *); -int sys_getpriority(struct proc *, void *, register_t *); -int sys_setpriority(struct proc *, void *, register_t *); -int sys_profil(struct proc *, void *, register_t *); -int linux_sys_statfs(struct proc *, void *, register_t *); -int linux_sys_fstatfs(struct proc *, void *, register_t *); -int linux_sys_ioperm(struct proc *, void *, register_t *); -int linux_sys_socketcall(struct proc *, void *, register_t *); -int sys_setitimer(struct proc *, void *, register_t *); -int sys_getitimer(struct proc *, void *, register_t *); -int linux_sys_stat(struct proc *, void *, register_t *); -int linux_sys_lstat(struct proc *, void *, register_t *); -int linux_sys_fstat(struct proc *, void *, register_t *); -int linux_sys_olduname(struct proc *, void *, register_t *); -int linux_sys_iopl(struct proc *, void *, register_t *); -int linux_sys_wait4(struct proc *, void *, register_t *); -int linux_sys_swapoff(struct proc *, void *, register_t *); -int linux_sys_sysinfo(struct proc *, void *, register_t *); -int linux_sys_ipc(struct proc *, void *, register_t *); -int sys_fsync(struct proc *, void *, register_t *); -int linux_sys_sigreturn(struct proc *, void *, register_t *); -int linux_sys_clone(struct proc *, void *, register_t *); -int linux_sys_setdomainname(struct proc *, void *, register_t *); -int linux_sys_uname(struct proc *, void *, register_t *); -int linux_sys_modify_ldt(struct proc *, void *, register_t *); -int sys_mprotect(struct proc *, void *, register_t *); -int linux_sys_sigprocmask(struct proc *, void *, register_t *); -int linux_sys_getpgid(struct proc *, void *, register_t *); -int sys_fchdir(struct proc *, void *, register_t *); -int linux_sys_personality(struct proc *, void *, register_t *); -int linux_sys_setfsuid(struct proc *, void *, register_t *); -int linux_sys_getfsuid(struct proc *, void *, register_t *); -int linux_sys_llseek(struct proc *, void *, register_t *); -int linux_sys_getdents(struct proc *, void *, register_t *); -int linux_sys_select(struct proc *, void *, register_t *); -int sys_flock(struct proc *, void *, register_t *); -int linux_sys_msync(struct proc *, void *, register_t *); -int sys_readv(struct proc *, void *, register_t *); -int sys_writev(struct proc *, void *, register_t *); -int sys_getsid(struct proc *, void *, register_t *); -int linux_sys_fdatasync(struct proc *, void *, register_t *); -int linux_sys___sysctl(struct proc *, void *, register_t *); -int sys_mlock(struct proc *, void *, register_t *); -int sys_munlock(struct proc *, void *, register_t *); -int sys_mlockall(struct proc *, void *, register_t *); -int sys_munlockall(struct proc *, void *, register_t *); -int linux_sys_sched_setparam(struct proc *, void *, register_t *); -int linux_sys_sched_getparam(struct proc *, void *, register_t *); -int linux_sys_sched_setscheduler(struct proc *, void *, register_t *); -int linux_sys_sched_getscheduler(struct proc *, void *, register_t *); -int linux_sys_sched_yield(struct proc *, void *, register_t *); -int linux_sys_sched_get_priority_max(struct proc *, void *, register_t *); -int linux_sys_sched_get_priority_min(struct proc *, void *, register_t *); -int sys_nanosleep(struct proc *, void *, register_t *); -int linux_sys_mremap(struct proc *, void *, register_t *); -int linux_sys_setresuid16(struct proc *, void *, register_t *); -int linux_sys_getresuid(struct proc *, void *, register_t *); -int sys_poll(struct proc *, void *, register_t *); -int linux_sys_setresgid16(struct proc *, void *, register_t *); -int linux_sys_getresgid(struct proc *, void *, register_t *); -int linux_sys_rt_sigreturn(struct proc *, void *, register_t *); -int linux_sys_rt_sigaction(struct proc *, void *, register_t *); -int linux_sys_rt_sigprocmask(struct proc *, void *, register_t *); -int linux_sys_rt_sigpending(struct proc *, void *, register_t *); -int linux_sys_rt_queueinfo(struct proc *, void *, register_t *); -int linux_sys_rt_sigsuspend(struct proc *, void *, register_t *); -int linux_sys_pread(struct proc *, void *, register_t *); -int linux_sys_pwrite(struct proc *, void *, register_t *); -int linux_sys_chown16(struct proc *, void *, register_t *); -int sys___getcwd(struct proc *, void *, register_t *); -int linux_sys_sigaltstack(struct proc *, void *, register_t *); -int sys___vfork14(struct proc *, void *, register_t *); -int linux_sys_truncate64(struct proc *, void *, register_t *); -int sys_ftruncate(struct proc *, void *, register_t *); -int linux_sys_stat64(struct proc *, void *, register_t *); -int linux_sys_lstat64(struct proc *, void *, register_t *); -int linux_sys_fstat64(struct proc *, void *, register_t *); -int linux_sys_lchown(struct proc *, void *, register_t *); -int sys_getuid(struct proc *, void *, register_t *); -int sys_getgid(struct proc *, void *, register_t *); -int sys_geteuid(struct proc *, void *, register_t *); -int sys_getegid(struct proc *, void *, register_t *); -int sys_setreuid(struct proc *, void *, register_t *); -int sys_setregid(struct proc *, void *, register_t *); -int sys_getgroups(struct proc *, void *, register_t *); -int sys_setgroups(struct proc *, void *, register_t *); -int sys___posix_fchown(struct proc *, void *, register_t *); -int linux_sys_setresuid(struct proc *, void *, register_t *); -int linux_sys_getresuid(struct proc *, void *, register_t *); -int linux_sys_setresgid(struct proc *, void *, register_t *); -int linux_sys_getresgid(struct proc *, void *, register_t *); -int linux_sys_chown(struct proc *, void *, register_t *); -int sys_setuid(struct proc *, void *, register_t *); -int sys_setgid(struct proc *, void *, register_t *); -int linux_sys_setfsuid(struct proc *, void *, register_t *); -int linux_sys_getfsuid(struct proc *, void *, register_t *); +int linux_sys_nosys(struct lwp *, void *, register_t *); +int sys_exit(struct lwp *, void *, register_t *); +int sys_fork(struct lwp *, void *, register_t *); +int sys_read(struct lwp *, void *, register_t *); +int sys_write(struct lwp *, void *, register_t *); +int linux_sys_open(struct lwp *, void *, register_t *); +int sys_close(struct lwp *, void *, register_t *); +int linux_sys_waitpid(struct lwp *, void *, register_t *); +int linux_sys_creat(struct lwp *, void *, register_t *); +int linux_sys_link(struct lwp *, void *, register_t *); +int linux_sys_unlink(struct lwp *, void *, register_t *); +int linux_sys_execve(struct lwp *, void *, register_t *); +int linux_sys_chdir(struct lwp *, void *, register_t *); +int linux_sys_time(struct lwp *, void *, register_t *); +int linux_sys_mknod(struct lwp *, void *, register_t *); +int linux_sys_chmod(struct lwp *, void *, register_t *); +int linux_sys_lchown16(struct lwp *, void *, register_t *); +int linux_sys_break(struct lwp *, void *, register_t *); +int compat_43_sys_lseek(struct lwp *, void *, register_t *); +int sys_getpid(struct lwp *, void *, register_t *); +int sys_setuid(struct lwp *, void *, register_t *); +int sys_getuid(struct lwp *, void *, register_t *); +int linux_sys_stime(struct lwp *, void *, register_t *); +int linux_sys_ptrace(struct lwp *, void *, register_t *); +int linux_sys_alarm(struct lwp *, void *, register_t *); +int linux_sys_pause(struct lwp *, void *, register_t *); +int linux_sys_utime(struct lwp *, void *, register_t *); +int linux_sys_access(struct lwp *, void *, register_t *); +int linux_sys_nice(struct lwp *, void *, register_t *); +int sys_sync(struct lwp *, void *, register_t *); +int linux_sys_kill(struct lwp *, void *, register_t *); +int linux_sys_rename(struct lwp *, void *, register_t *); +int linux_sys_mkdir(struct lwp *, void *, register_t *); +int linux_sys_rmdir(struct lwp *, void *, register_t *); +int sys_dup(struct lwp *, void *, register_t *); +int linux_sys_pipe(struct lwp *, void *, register_t *); +int linux_sys_times(struct lwp *, void *, register_t *); +int linux_sys_brk(struct lwp *, void *, register_t *); +int sys_setgid(struct lwp *, void *, register_t *); +int sys_getgid(struct lwp *, void *, register_t *); +int linux_sys_signal(struct lwp *, void *, register_t *); +int sys_geteuid(struct lwp *, void *, register_t *); +int sys_getegid(struct lwp *, void *, register_t *); +int sys_acct(struct lwp *, void *, register_t *); +int linux_sys_ioctl(struct lwp *, void *, register_t *); +int linux_sys_fcntl(struct lwp *, void *, register_t *); +int sys_setpgid(struct lwp *, void *, register_t *); +int linux_sys_oldolduname(struct lwp *, void *, register_t *); +int sys_umask(struct lwp *, void *, register_t *); +int sys_chroot(struct lwp *, void *, register_t *); +int sys_dup2(struct lwp *, void *, register_t *); +int sys_getppid(struct lwp *, void *, register_t *); +int sys_getpgrp(struct lwp *, void *, register_t *); +int sys_setsid(struct lwp *, void *, register_t *); +int linux_sys_sigaction(struct lwp *, void *, register_t *); +int linux_sys_siggetmask(struct lwp *, void *, register_t *); +int linux_sys_sigsetmask(struct lwp *, void *, register_t *); +int linux_sys_setreuid16(struct lwp *, void *, register_t *); +int linux_sys_setregid16(struct lwp *, void *, register_t *); +int linux_sys_sigsuspend(struct lwp *, void *, register_t *); +int linux_sys_sigpending(struct lwp *, void *, register_t *); +int compat_43_sys_sethostname(struct lwp *, void *, register_t *); +int compat_43_sys_setrlimit(struct lwp *, void *, register_t *); +int compat_43_sys_getrlimit(struct lwp *, void *, register_t *); +int sys_getrusage(struct lwp *, void *, register_t *); +int sys_gettimeofday(struct lwp *, void *, register_t *); +int sys_settimeofday(struct lwp *, void *, register_t *); +int linux_sys_getgroups16(struct lwp *, void *, register_t *); +int linux_sys_setgroups16(struct lwp *, void *, register_t *); +int linux_sys_oldselect(struct lwp *, void *, register_t *); +int linux_sys_symlink(struct lwp *, void *, register_t *); +int compat_43_sys_lstat(struct lwp *, void *, register_t *); +int linux_sys_readlink(struct lwp *, void *, register_t *); +int linux_sys_uselib(struct lwp *, void *, register_t *); +int linux_sys_swapon(struct lwp *, void *, register_t *); +int linux_sys_reboot(struct lwp *, void *, register_t *); +int linux_sys_readdir(struct lwp *, void *, register_t *); +int linux_sys_old_mmap(struct lwp *, void *, register_t *); +int sys_munmap(struct lwp *, void *, register_t *); +int linux_sys_truncate(struct lwp *, void *, register_t *); +int compat_43_sys_ftruncate(struct lwp *, void *, register_t *); +int sys_fchmod(struct lwp *, void *, register_t *); +int linux_sys_fchown16(struct lwp *, void *, register_t *); +int sys_getpriority(struct lwp *, void *, register_t *); +int sys_setpriority(struct lwp *, void *, register_t *); +int sys_profil(struct lwp *, void *, register_t *); +int linux_sys_statfs(struct lwp *, void *, register_t *); +int linux_sys_fstatfs(struct lwp *, void *, register_t *); +int linux_sys_ioperm(struct lwp *, void *, register_t *); +int linux_sys_socketcall(struct lwp *, void *, register_t *); +int sys_setitimer(struct lwp *, void *, register_t *); +int sys_getitimer(struct lwp *, void *, register_t *); +int linux_sys_stat(struct lwp *, void *, register_t *); +int linux_sys_lstat(struct lwp *, void *, register_t *); +int linux_sys_fstat(struct lwp *, void *, register_t *); +int linux_sys_olduname(struct lwp *, void *, register_t *); +int linux_sys_iopl(struct lwp *, void *, register_t *); +int linux_sys_wait4(struct lwp *, void *, register_t *); +int linux_sys_swapoff(struct lwp *, void *, register_t *); +int linux_sys_sysinfo(struct lwp *, void *, register_t *); +int linux_sys_ipc(struct lwp *, void *, register_t *); +int sys_fsync(struct lwp *, void *, register_t *); +int linux_sys_sigreturn(struct lwp *, void *, register_t *); +int linux_sys_clone(struct lwp *, void *, register_t *); +int linux_sys_setdomainname(struct lwp *, void *, register_t *); +int linux_sys_uname(struct lwp *, void *, register_t *); +int linux_sys_modify_ldt(struct lwp *, void *, register_t *); +int sys_mprotect(struct lwp *, void *, register_t *); +int linux_sys_sigprocmask(struct lwp *, void *, register_t *); +int linux_sys_getpgid(struct lwp *, void *, register_t *); +int sys_fchdir(struct lwp *, void *, register_t *); +int linux_sys_personality(struct lwp *, void *, register_t *); +int linux_sys_setfsuid(struct lwp *, void *, register_t *); +int linux_sys_getfsuid(struct lwp *, void *, register_t *); +int linux_sys_llseek(struct lwp *, void *, register_t *); +int linux_sys_getdents(struct lwp *, void *, register_t *); +int linux_sys_select(struct lwp *, void *, register_t *); +int sys_flock(struct lwp *, void *, register_t *); +int linux_sys_msync(struct lwp *, void *, register_t *); +int sys_readv(struct lwp *, void *, register_t *); +int sys_writev(struct lwp *, void *, register_t *); +int sys_getsid(struct lwp *, void *, register_t *); +int linux_sys_fdatasync(struct lwp *, void *, register_t *); +int linux_sys___sysctl(struct lwp *, void *, register_t *); +int sys_mlock(struct lwp *, void *, register_t *); +int sys_munlock(struct lwp *, void *, register_t *); +int sys_mlockall(struct lwp *, void *, register_t *); +int sys_munlockall(struct lwp *, void *, register_t *); +int linux_sys_sched_setparam(struct lwp *, void *, register_t *); +int linux_sys_sched_getparam(struct lwp *, void *, register_t *); +int linux_sys_sched_setscheduler(struct lwp *, void *, register_t *); +int linux_sys_sched_getscheduler(struct lwp *, void *, register_t *); +int linux_sys_sched_yield(struct lwp *, void *, register_t *); +int linux_sys_sched_get_priority_max(struct lwp *, void *, register_t *); +int linux_sys_sched_get_priority_min(struct lwp *, void *, register_t *); +int sys_nanosleep(struct lwp *, void *, register_t *); +int linux_sys_mremap(struct lwp *, void *, register_t *); +int linux_sys_setresuid16(struct lwp *, void *, register_t *); +int linux_sys_getresuid(struct lwp *, void *, register_t *); +int sys_poll(struct lwp *, void *, register_t *); +int linux_sys_setresgid16(struct lwp *, void *, register_t *); +int linux_sys_getresgid(struct lwp *, void *, register_t *); +int linux_sys_rt_sigreturn(struct lwp *, void *, register_t *); +int linux_sys_rt_sigaction(struct lwp *, void *, register_t *); +int linux_sys_rt_sigprocmask(struct lwp *, void *, register_t *); +int linux_sys_rt_sigpending(struct lwp *, void *, register_t *); +int linux_sys_rt_queueinfo(struct lwp *, void *, register_t *); +int linux_sys_rt_sigsuspend(struct lwp *, void *, register_t *); +int linux_sys_pread(struct lwp *, void *, register_t *); +int linux_sys_pwrite(struct lwp *, void *, register_t *); +int linux_sys_chown16(struct lwp *, void *, register_t *); +int sys___getcwd(struct lwp *, void *, register_t *); +int linux_sys_sigaltstack(struct lwp *, void *, register_t *); +int sys___vfork14(struct lwp *, void *, register_t *); +int linux_sys_truncate64(struct lwp *, void *, register_t *); +int sys_ftruncate(struct lwp *, void *, register_t *); +int linux_sys_stat64(struct lwp *, void *, register_t *); +int linux_sys_lstat64(struct lwp *, void *, register_t *); +int linux_sys_fstat64(struct lwp *, void *, register_t *); +int linux_sys_lchown(struct lwp *, void *, register_t *); +int sys_getuid(struct lwp *, void *, register_t *); +int sys_getgid(struct lwp *, void *, register_t *); +int sys_geteuid(struct lwp *, void *, register_t *); +int sys_getegid(struct lwp *, void *, register_t *); +int sys_setreuid(struct lwp *, void *, register_t *); +int sys_setregid(struct lwp *, void *, register_t *); +int sys_getgroups(struct lwp *, void *, register_t *); +int sys_setgroups(struct lwp *, void *, register_t *); +int sys___posix_fchown(struct lwp *, void *, register_t *); +int linux_sys_setresuid(struct lwp *, void *, register_t *); +int linux_sys_getresuid(struct lwp *, void *, register_t *); +int linux_sys_setresgid(struct lwp *, void *, register_t *); +int linux_sys_getresgid(struct lwp *, void *, register_t *); +int linux_sys_chown(struct lwp *, void *, register_t *); +int sys_setuid(struct lwp *, void *, register_t *); +int sys_setgid(struct lwp *, void *, register_t *); +int linux_sys_setfsuid(struct lwp *, void *, register_t *); +int linux_sys_getfsuid(struct lwp *, void *, register_t *); #endif /* _LINUX_SYS__SYSCALLARGS_H_ */ Index: sys/compat/linux/common/linux_break.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_break.c,v retrieving revision 1.49 retrieving revision 1.49.24.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.49 -r1.49.24.1 --- sys/compat/linux/common/linux_break.c 1998/10/04 00:02:30 1.49 +++ sys/compat/linux/common/linux_break.c 2001/03/05 22:49:24 1.49.24.1 @@ -58,10 +58,10 @@ * This is the old brk(2) call. I don't think anything in the Linux * world uses this anymore */ int -linux_sys_break(p, v, retval) - struct proc *p; +linux_sys_break(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #if 0 Index: sys/compat/linux/common/linux_exec.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_exec.c,v retrieving revision 1.48 retrieving revision 1.45.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.48 -r1.45.2.2 --- sys/compat/linux/common/linux_exec.c 2001/03/24 11:13:04 1.48 +++ sys/compat/linux/common/linux_exec.c 2001/04/09 01:55:41 1.45.2.2 @@ -82,18 +82,19 @@ * Execve(2). Just check the alternate emulation path, and pass it on * to the NetBSD execve(). */ int -linux_sys_execve(p, v, retval) - struct proc *p; +linux_sys_execve(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_execve_args /* { syscallarg(const char *) path; syscallarg(char **) argv; syscallarg(char **) envp; } */ *uap = v; + struct proc *p = l->l_proc; struct sys_execve_args ap; caddr_t sg; sg = stackgap_init(p->p_emul); @@ -102,9 +103,9 @@ SCARG(&ap, path) = SCARG(uap, path); SCARG(&ap, argp) = SCARG(uap, argp); SCARG(&ap, envp) = SCARG(uap, envp); - return sys_execve(p, &ap, retval); + return sys_execve(l, &ap, retval); } /* * Emulation switch. Index: sys/compat/linux/common/linux_exec.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_exec.h,v retrieving revision 1.14 retrieving revision 1.14.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.14 -r1.14.2.1 --- sys/compat/linux/common/linux_exec.h 2001/01/19 01:40:38 1.14 +++ sys/compat/linux/common/linux_exec.h 2001/03/05 22:49:24 1.14.2.1 @@ -90,9 +90,9 @@ #ifdef _KERNEL __BEGIN_DECLS extern const struct emul emul_linux; -void linux_setregs __P((struct proc *, struct exec_package *, u_long)); +void linux_setregs __P((struct lwp *, struct exec_package *, u_long)); int exec_linux_aout_makecmds __P((struct proc *, struct exec_package *)); void *linux_aout_copyargs __P((struct exec_package *, struct ps_strings *, void *, void *)); Index: sys/compat/linux/common/linux_file.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_file.c,v retrieving revision 1.37 retrieving revision 1.37.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.37 -r1.37.2.1 --- sys/compat/linux/common/linux_file.c 2001/01/22 21:31:37 1.37 +++ sys/compat/linux/common/linux_file.c 2001/03/05 22:49:24 1.37.2.1 @@ -70,9 +70,9 @@ static int bsd_to_linux_ioflags __P((int)); static void bsd_to_linux_flock __P((struct flock *, struct linux_flock *)); static void linux_to_bsd_flock __P((struct linux_flock *, struct flock *)); static void bsd_to_linux_stat __P((struct stat *, struct linux_stat *)); -static int linux_stat1 __P((struct proc *, void *, register_t *, int)); +static int linux_stat1 __P((struct lwp *, void *, register_t *, int)); /* * Some file-related calls are handled here. The usual flag conversion * an structure conversion is done, and alternate emul path searching. @@ -133,17 +133,18 @@ * * Just call open(2) with the TRUNC, CREAT and WRONLY flags. */ int -linux_sys_creat(p, v, retval) - struct proc *p; +linux_sys_creat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_creat_args /* { syscallarg(const char *) path; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; struct sys_open_args oa; caddr_t sg; sg = stackgap_init(p->p_emul); @@ -152,9 +153,9 @@ SCARG(&oa, path) = SCARG(uap, path); SCARG(&oa, flags) = O_CREAT | O_TRUNC | O_WRONLY; SCARG(&oa, mode) = SCARG(uap, mode); - return sys_open(p, &oa, retval); + return sys_open(l, &oa, retval); } /* * open(2). Take care of the different flag values, and let the @@ -162,18 +163,19 @@ * gives the current process a controlling terminal. * (XXX is this necessary?) */ int -linux_sys_open(p, v, retval) - struct proc *p; +linux_sys_open(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_open_args /* { syscallarg(const char *) path; syscallarg(int) flags; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; int error, fl; struct sys_open_args boa; caddr_t sg; @@ -189,9 +191,9 @@ SCARG(&boa, path) = SCARG(uap, path); SCARG(&boa, flags) = fl; SCARG(&boa, mode) = SCARG(uap, mode); - if ((error = sys_open(p, &boa, retval))) + if ((error = sys_open(l, &boa, retval))) return error; /* * this bit from sunos_misc.c (and svr4_fcntl.c). @@ -268,18 +270,19 @@ * conversions after the actual system call has done its work, * because the flag values and lock structure are different. */ int -linux_sys_fcntl(p, v, retval) - struct proc *p; +linux_sys_fcntl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_fcntl_args /* { syscallarg(int) fd; syscallarg(int) cmd; syscallarg(void *) arg; } */ *uap = v; + struct proc *p = l->l_proc; int fd, cmd, error; u_long val; caddr_t arg, sg; struct linux_flock lfl; @@ -310,18 +313,18 @@ case LINUX_F_GETFL: SCARG(&fca, fd) = fd; SCARG(&fca, cmd) = F_GETFL; SCARG(&fca, arg) = arg; - if ((error = sys_fcntl(p, &fca, retval))) + if ((error = sys_fcntl(l, &fca, retval))) return error; retval[0] = bsd_to_linux_ioflags(retval[0]); return 0; case LINUX_F_SETFL: val = linux_to_bsd_ioflags((unsigned long)SCARG(uap, arg)); SCARG(&fca, fd) = fd; SCARG(&fca, cmd) = F_SETFL; SCARG(&fca, arg) = (caddr_t) val; - return sys_fcntl(p, &fca, retval); + return sys_fcntl(l, &fca, retval); case LINUX_F_GETLK: sg = stackgap_init(p->p_emul); bfp = (struct flock *) stackgap_alloc(&sg, sizeof *bfp); if ((error = copyin(arg, &lfl, sizeof lfl))) @@ -331,9 +334,9 @@ return error; SCARG(&fca, fd) = fd; SCARG(&fca, cmd) = F_GETLK; SCARG(&fca, arg) = bfp; - if ((error = sys_fcntl(p, &fca, retval))) + if ((error = sys_fcntl(l, &fca, retval))) return error; if ((error = copyin(bfp, &bfl, sizeof bfl))) return error; bsd_to_linux_flock(&bfl, &lfl); @@ -351,9 +354,9 @@ return error; SCARG(&fca, fd) = fd; SCARG(&fca, cmd) = cmd; SCARG(&fca, arg) = bfp; - return sys_fcntl(p, &fca, retval); + return sys_fcntl(l, &fca, retval); break; case LINUX_F_SETOWN: case LINUX_F_GETOWN: /* @@ -402,9 +405,9 @@ SCARG(&fca, fd) = fd; SCARG(&fca, cmd) = cmd; SCARG(&fca, arg) = arg; - return sys_fcntl(p, &fca, retval); + return sys_fcntl(l, &fca, retval); } /* * Convert a NetBSD stat structure to a Linux stat structure. @@ -442,17 +445,18 @@ * The stat functions below are plain sailing. stat and lstat are handled * by one function to avoid code duplication. */ int -linux_sys_fstat(p, v, retval) - struct proc *p; +linux_sys_fstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_fstat_args /* { syscallarg(int) fd; syscallarg(linux_stat *) sp; } */ *uap = v; + struct proc *p = l->l_proc; struct sys___fstat13_args fsa; struct linux_stat tmplst; struct stat *st,tmpst; caddr_t sg; @@ -464,9 +468,9 @@ SCARG(&fsa, fd) = SCARG(uap, fd); SCARG(&fsa, sb) = st; - if ((error = sys___fstat13(p, &fsa, retval))) + if ((error = sys___fstat13(l, &fsa, retval))) return error; if ((error = copyin(st, &tmpst, sizeof tmpst))) return error; @@ -479,17 +483,18 @@ return 0; } static int -linux_stat1(p, v, retval, dolstat) - struct proc *p; +linux_stat1(l, v, retval, dolstat) + struct lwp *l; void *v; register_t *retval; int dolstat; { struct sys___stat13_args sa; struct linux_stat tmplst; struct stat *st, tmpst; + struct proc *p = l->l_proc; caddr_t sg; int error; struct linux_sys_stat_args *uap = v; @@ -502,10 +507,10 @@ SCARG(&sa, ub) = st; SCARG(&sa, path) = SCARG(uap, path); - if ((error = (dolstat ? sys___lstat13(p, &sa, retval) : - sys___stat13(p, &sa, retval)))) + if ((error = (dolstat ? sys___lstat13(l, &sa, retval) : + sys___stat13(l, &sa, retval)))) return error; if ((error = copyin(st, &tmpst, sizeof tmpst))) return error; @@ -518,101 +523,105 @@ return 0; } int -linux_sys_stat(p, v, retval) - struct proc *p; +linux_sys_stat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_stat_args /* { syscallarg(const char *) path; syscallarg(struct linux_stat *) sp; } */ *uap = v; - return linux_stat1(p, uap, retval, 0); + return linux_stat1(l, uap, retval, 0); } /* Note: this is "newlstat" in the Linux sources */ /* (we don't bother with the old lstat currently) */ int -linux_sys_lstat(p, v, retval) - struct proc *p; +linux_sys_lstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_lstat_args /* { syscallarg(const char *) path; syscallarg(struct linux_stat *) sp; } */ *uap = v; - return linux_stat1(p, uap, retval, 1); + return linux_stat1(l, uap, retval, 1); } /* * The following syscalls are mostly here because of the alternate path check. */ int -linux_sys_access(p, v, retval) - struct proc *p; +linux_sys_access(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_access_args /* { syscallarg(const char *) path; syscallarg(int) flags; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_access(p, uap, retval); + return sys_access(l, uap, retval); } int -linux_sys_unlink(p, v, retval) - struct proc *p; +linux_sys_unlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_unlink_args /* { syscallarg(const char *) path; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_unlink(p, uap, retval); + return sys_unlink(l, uap, retval); } int -linux_sys_chdir(p, v, retval) - struct proc *p; +linux_sys_chdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_chdir_args /* { syscallarg(const char *) path; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_chdir(p, uap, retval); + return sys_chdir(l, uap, retval); } int -linux_sys_mknod(p, v, retval) - struct proc *p; +linux_sys_mknod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_mknod_args /* { syscallarg(const char *) path; syscallarg(int) mode; syscallarg(int) dev; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); struct sys_mkfifo_args bma; CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); @@ -622,42 +631,44 @@ */ if (SCARG(uap, mode) & S_IFIFO) { SCARG(&bma, path) = SCARG(uap, path); SCARG(&bma, mode) = SCARG(uap, mode); - return sys_mkfifo(p, uap, retval); + return sys_mkfifo(l, uap, retval); } else - return sys_mknod(p, uap, retval); + return sys_mknod(l, uap, retval); } int -linux_sys_chmod(p, v, retval) - struct proc *p; +linux_sys_chmod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_chmod_args /* { syscallarg(const char *) path; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_chmod(p, uap, retval); + return sys_chmod(l, uap, retval); } #if defined(__i386__) || defined(__m68k__) int -linux_sys_chown16(p, v, retval) - struct proc *p; +linux_sys_chown16(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_chown16_args /* { syscallarg(const char *) path; syscallarg(int) uid; syscallarg(int) gid; } */ *uap = v; + struct proc *p = l->l_proc; struct sys___posix_chown_args bca; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); @@ -667,14 +678,14 @@ (uid_t)-1 : SCARG(uap, uid); SCARG(&bca, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ? (gid_t)-1 : SCARG(uap, gid); - return sys___posix_chown(p, &bca, retval); + return sys___posix_chown(l, &bca, retval); } int -linux_sys_fchown16(p, v, retval) - struct proc *p; +linux_sys_fchown16(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_fchown16_args /* { @@ -689,22 +700,23 @@ (uid_t)-1 : SCARG(uap, uid); SCARG(&bfa, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ? (gid_t)-1 : SCARG(uap, gid); - return sys___posix_fchown(p, &bfa, retval); + return sys___posix_fchown(l, &bfa, retval); } int -linux_sys_lchown16(p, v, retval) - struct proc *p; +linux_sys_lchown16(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_lchown16_args /* { syscallarg(char *) path; syscallarg(int) uid; syscallarg(int) gid; } */ *uap = v; + struct proc *p = l->l_proc; struct sys___posix_lchown_args bla; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path)); @@ -714,169 +726,178 @@ (uid_t)-1 : SCARG(uap, uid); SCARG(&bla, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ? (gid_t)-1 : SCARG(uap, gid); - return sys___posix_lchown(p, &bla, retval); + return sys___posix_lchown(l, &bla, retval); } #endif /* __i386__ || __m68k__ */ #if defined (__i386__) || defined (__m68k__) || defined (__powerpc__) int -linux_sys_chown(p, v, retval) - struct proc *p; +linux_sys_chown(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_chown_args /* { syscallarg(char *) path; syscallarg(int) uid; syscallarg(int) gid; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys___posix_chown(p, uap, retval); + return sys___posix_chown(l, uap, retval); } int -linux_sys_lchown(p, v, retval) - struct proc *p; +linux_sys_lchown(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_lchown_args /* { syscallarg(char *) path; syscallarg(int) uid; syscallarg(int) gid; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path)); - return sys___posix_lchown(p, uap, retval); + return sys___posix_lchown(l, uap, retval); } #endif /* __i386__ || __m68k__ || __powerpc__ */ int -linux_sys_rename(p, v, retval) - struct proc *p; +linux_sys_rename(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_rename_args /* { syscallarg(const char *) from; syscallarg(const char *) to; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, from)); CHECK_ALT_CREAT(p, &sg, SCARG(uap, to)); - return sys___posix_rename(p, uap, retval); + return sys___posix_rename(l, uap, retval); } int -linux_sys_mkdir(p, v, retval) - struct proc *p; +linux_sys_mkdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_mkdir_args /* { syscallarg(const char *) path; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); - return sys_mkdir(p, uap, retval); + return sys_mkdir(l, uap, retval); } int -linux_sys_rmdir(p, v, retval) - struct proc *p; +linux_sys_rmdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_rmdir_args /* { syscallarg(const char *) path; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_rmdir(p, uap, retval); + return sys_rmdir(l, uap, retval); } int -linux_sys_symlink(p, v, retval) - struct proc *p; +linux_sys_symlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_symlink_args /* { syscallarg(const char *) path; syscallarg(const char *) to; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); CHECK_ALT_CREAT(p, &sg, SCARG(uap, to)); - return sys_symlink(p, uap, retval); + return sys_symlink(l, uap, retval); } int -linux_sys_link(p, v, retval) - struct proc *p; +linux_sys_link(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_link_args /* { syscallarg(const char *) path; syscallarg(const char *) link; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); CHECK_ALT_CREAT(p, &sg, SCARG(uap, link)); - return sys_link(p, uap, retval); + return sys_link(l, uap, retval); } int -linux_sys_readlink(p, v, retval) - struct proc *p; +linux_sys_readlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_readlink_args /* { syscallarg(const char *) name; syscallarg(char *) buf; syscallarg(int) count; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, name)); - return sys_readlink(p, uap, retval); + return sys_readlink(l, uap, retval); } int -linux_sys_truncate(p, v, retval) - struct proc *p; +linux_sys_truncate(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_truncate_args /* { syscallarg(const char *) path; syscallarg(long) length; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return compat_43_sys_truncate(p, uap, retval); + return compat_43_sys_truncate(l, uap, retval); } /* * This is just fsync() for now (just as it is in the Linux kernel) @@ -884,27 +905,27 @@ * but should still be defined in our syscalls.master. * (syscall #148 on the arm) */ int -linux_sys_fdatasync(p, v, retval) - struct proc *p; +linux_sys_fdatasync(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #ifdef notdef struct linux_sys_fdatasync_args /* { syscallarg(int) fd; } */ *uap = v; #endif - return sys_fsync(p, v, retval); + return sys_fsync(l, v, retval); } /* * pread(2). */ int -linux_sys_pread(p, v, retval) - struct proc *p; +linux_sys_pread(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_pread_args /* { @@ -919,17 +940,17 @@ SCARG(&pra, buf) = SCARG(uap, buf); SCARG(&pra, nbyte) = SCARG(uap, nbyte); SCARG(&pra, offset) = SCARG(uap, offset); - return sys_read(p, &pra, retval); + return sys_read(l, &pra, retval); } /* * pwrite(2). */ int -linux_sys_pwrite(p, v, retval) - struct proc *p; +linux_sys_pwrite(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_pwrite_args /* { @@ -944,6 +965,6 @@ SCARG(&pra, buf) = SCARG(uap, buf); SCARG(&pra, nbyte) = SCARG(uap, nbyte); SCARG(&pra, offset) = SCARG(uap, offset); - return sys_write(p, &pra, retval); + return sys_write(l, &pra, retval); } Index: sys/compat/linux/common/linux_file64.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_file64.c,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.2 -r1.2.4.1 --- sys/compat/linux/common/linux_file64.c 2000/12/12 22:24:56 1.2 +++ sys/compat/linux/common/linux_file64.c 2001/03/05 22:49:25 1.2.4.1 @@ -65,9 +65,9 @@ #include static void bsd_to_linux_stat __P((struct stat *, struct linux_stat64 *)); -static int linux_do_stat64 __P((struct proc *, void *, register_t *, int)); +static int linux_do_stat64 __P((struct lwp *, void *, register_t *, int)); /* * Convert a NetBSD stat structure to a Linux stat structure. * Only the order of the fields and the padding in the structure @@ -103,17 +103,18 @@ * The stat functions below are plain sailing. stat and lstat are handled * by one function to avoid code duplication. */ int -linux_sys_fstat64(p, v, retval) - struct proc *p; +linux_sys_fstat64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_fstat64_args /* { syscallarg(int) fd; syscallarg(linux_stat64 *) sp; } */ *uap = v; + struct proc *p = l->l_proc; struct sys___fstat13_args fsa; struct linux_stat64 tmplst; struct stat *st,tmpst; caddr_t sg; @@ -125,9 +126,9 @@ SCARG(&fsa, fd) = SCARG(uap, fd); SCARG(&fsa, sb) = st; - if ((error = sys___fstat13(p, &fsa, retval))) + if ((error = sys___fstat13(l, &fsa, retval))) return error; if ((error = copyin(st, &tmpst, sizeof tmpst))) return error; @@ -140,14 +141,15 @@ return 0; } static int -linux_do_stat64(p, v, retval, dolstat) - struct proc *p; +linux_do_stat64(l, v, retval, dolstat) + struct lwp *l; void *v; register_t *retval; int dolstat; { + struct proc *p = l->l_proc; struct sys___stat13_args sa; struct linux_stat64 tmplst; struct stat *st, tmpst; caddr_t sg; @@ -160,10 +162,10 @@ SCARG(&sa, ub) = st; SCARG(&sa, path) = SCARG(uap, path); - if ((error = (dolstat ? sys___lstat13(p, &sa, retval) : - sys___stat13(p, &sa, retval)))) + if ((error = (dolstat ? sys___lstat13(l, &sa, retval) : + sys___stat13(l, &sa, retval)))) return error; if ((error = copyin(st, &tmpst, sizeof tmpst))) return error; @@ -176,47 +178,48 @@ return 0; } int -linux_sys_stat64(p, v, retval) - struct proc *p; +linux_sys_stat64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_stat64_args /* { syscallarg(const char *) path; syscallarg(struct linux_stat64 *) sp; } */ *uap = v; - return linux_do_stat64(p, uap, retval, 0); + return linux_do_stat64(l, uap, retval, 0); } int -linux_sys_lstat64(p, v, retval) - struct proc *p; +linux_sys_lstat64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_lstat64_args /* { syscallarg(const char *) path; syscallarg(struct linux_stat64 *) sp; } */ *uap = v; - return linux_do_stat64(p, uap, retval, 1); + return linux_do_stat64(l, uap, retval, 1); } int -linux_sys_truncate64(p, v, retval) - struct proc *p; +linux_sys_truncate64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_truncate64_args /* { syscallarg(const char *) path; syscallarg(off_t) length; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_truncate(p, uap, retval); + return sys_truncate(l, uap, retval); } Index: sys/compat/linux/common/linux_ioctl.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_ioctl.c,v retrieving revision 1.25 retrieving revision 1.25.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.25 -r1.25.2.1 --- sys/compat/linux/common/linux_ioctl.c 2001/01/10 02:28:38 1.25 +++ sys/compat/linux/common/linux_ioctl.c 2001/03/05 22:49:25 1.25.2.1 @@ -72,18 +72,19 @@ * allocating stackgap memory, letting the actual ioctl call do its * work there and converting back the data afterwards. */ int -linux_sys_ioctl(p, v, retval) - struct proc *p; +linux_sys_ioctl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_ioctl_args /* { syscallarg(int) fd; syscallarg(u_long) com; syscallarg(caddr_t) data; } */ *uap = v; + struct proc *p = l->l_proc; switch (LINUX_IOCGROUP(SCARG(uap, com))) { case 'M': return oss_ioctl_mixer(p, LINUX_TO_OSS(v), retval); Index: sys/compat/linux/common/linux_ipc.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_ipc.c,v retrieving revision 1.22 retrieving revision 1.22.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.22 -r1.22.2.1 --- sys/compat/linux/common/linux_ipc.c 2000/12/01 18:16:54 1.22 +++ sys/compat/linux/common/linux_ipc.c 2001/03/05 22:49:25 1.22.2.1 @@ -44,8 +44,9 @@ #include #include #include #include +#include #include #include #include @@ -161,10 +162,10 @@ * Most of this can be handled by directly passing the arguments on; we * just need to frob the `cmd' and convert the semid_ds and semun. */ int -linux_sys_semctl(p, v, retval) - struct proc *p; +linux_sys_semctl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_semctl_args /* { @@ -172,8 +173,9 @@ syscallarg(int) semnum; syscallarg(int) cmd; syscallarg(union linux_semun) arg; } */ *uap = v; + struct proc *p = l->l_proc; struct semid_ds sembuf; struct linux_semid_ds lsembuf; union __semun semun; int cmd, error; @@ -295,18 +297,19 @@ lmp->l_msg_ctime = bmp->msg_ctime; } int -linux_sys_msgctl(p, v, retval) - struct proc *p; +linux_sys_msgctl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_msgctl_args /* { syscallarg(int) msqid; syscallarg(int) cmd; syscallarg(struct linux_msqid_ds *) buf; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg; struct sys___msgctl13_args nua; struct msqid_ds *bmp, bm; struct linux_msqid_ds lm; @@ -318,9 +321,9 @@ sg = stackgap_init(p->p_emul); bmp = stackgap_alloc(&sg, sizeof (struct msqid_ds)); SCARG(&nua, cmd) = IPC_STAT; SCARG(&nua, buf) = bmp; - if ((error = sys___msgctl13(p, &nua, retval))) + if ((error = sys___msgctl13(l, &nua, retval))) return error; if ((error = copyin(bmp, &bm, sizeof bm))) return error; bsd_to_linux_msqid_ds(&bm, &lm); @@ -342,9 +345,9 @@ break; default: return EINVAL; } - return sys___msgctl13(p, &nua, retval); + return sys___msgctl13(l, &nua, retval); } #endif /* SYSVMSG */ #ifdef SYSVSHM @@ -353,10 +356,10 @@ * in which the return value is to be passed. This is subsequently * handled by libc, apparently. */ int -linux_sys_shmat(p, v, retval) - struct proc *p; +linux_sys_shmat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_shmat_args /* { @@ -366,9 +369,9 @@ syscallarg(u_long *) raddr; } */ *uap = v; int error; - if ((error = sys_shmat(p, uap, retval))) + if ((error = sys_shmat(l, uap, retval))) return error; if ((error = copyout(&retval[0], (caddr_t) SCARG(uap, raddr), sizeof retval[0]))) @@ -427,18 +430,19 @@ * * The usual structure conversion and massaging is done. */ int -linux_sys_shmctl(p, v, retval) - struct proc *p; +linux_sys_shmctl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_shmctl_args /* { syscallarg(int) shmid; syscallarg(int) cmd; syscallarg(struct linux_shmid_ds *) buf; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg; struct sys___shmctl13_args nua; struct shmid_ds *bsp, bs; struct linux_shmid_ds ls; @@ -450,9 +454,9 @@ sg = stackgap_init(p->p_emul); bsp = stackgap_alloc(&sg, sizeof(struct shmid_ds)); SCARG(&nua, cmd) = IPC_STAT; SCARG(&nua, buf) = bsp; - if ((error = sys___shmctl13(p, &nua, retval))) + if ((error = sys___shmctl13(l, &nua, retval))) return error; if ((error = copyin(SCARG(&nua, buf), &bs, sizeof bs))) return error; bsd_to_linux_shmid_ds(&bs, &ls); @@ -485,7 +489,7 @@ case LINUX_SHM_INFO: default: return EINVAL; } - return sys___shmctl13(p, &nua, retval); + return sys___shmctl13(l, &nua, retval); } #endif /* SYSVSHM */ Index: sys/compat/linux/common/linux_ipccall.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_ipccall.c,v retrieving revision 1.19 retrieving revision 1.19.20.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.19 -r1.19.20.1 --- sys/compat/linux/common/linux_ipccall.c 1999/01/10 15:05:36 1.19 +++ sys/compat/linux/common/linux_ipccall.c 2001/03/05 22:49:25 1.19.20.1 @@ -83,10 +83,10 @@ * functions to work. */ int -linux_sys_ipc(p, v, retval) - struct proc *p; +linux_sys_ipc(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_ipc_args /* { @@ -99,11 +99,11 @@ switch (SCARG(uap, what)) { #ifdef SYSVSEM case LINUX_SYS_semop: - return linux_semop(p, uap, retval); + return linux_semop(l, uap, retval); case LINUX_SYS_semget: - return linux_semget(p, uap, retval); + return linux_semget(l, uap, retval); case LINUX_SYS_semctl: { struct linux_sys_semctl_args bsa; union linux_semun arg; int error; @@ -115,26 +115,26 @@ if ((error = copyin(SCARG(uap, ptr), &arg, sizeof arg))) return error; SCARG(&bsa, arg) = arg; - return linux_sys_semctl(p, &bsa, retval); + return linux_sys_semctl(l, &bsa, retval); } #endif #ifdef SYSVMSG case LINUX_SYS_msgsnd: - return linux_msgsnd(p, uap, retval); + return linux_msgsnd(l, uap, retval); case LINUX_SYS_msgrcv: - return linux_msgrcv(p, uap, retval); + return linux_msgrcv(l, uap, retval); case LINUX_SYS_msgget: - return linux_msgget(p, uap, retval); + return linux_msgget(l, uap, retval); case LINUX_SYS_msgctl: { struct linux_sys_msgctl_args bsa; SCARG(&bsa, msqid) = SCARG(uap, a1); SCARG(&bsa, cmd) = SCARG(uap, a2); SCARG(&bsa, buf) = (struct linux_msqid_ds *)SCARG(uap, ptr); - return linux_sys_msgctl(p, &bsa, retval); + return linux_sys_msgctl(l, &bsa, retval); } #endif #ifdef SYSVSHM case LINUX_SYS_shmat: { @@ -145,22 +145,22 @@ SCARG(&bsa, shmflg) = SCARG(uap, a2); /* XXX passing pointer inside int here */ SCARG(&bsa, raddr) = (u_long *)SCARG(uap, a3); - return linux_sys_shmat(p, &bsa, retval); + return linux_sys_shmat(l, &bsa, retval); } case LINUX_SYS_shmdt: - return linux_shmdt(p, uap, retval); + return linux_shmdt(l, uap, retval); case LINUX_SYS_shmget: - return linux_shmget(p, uap, retval); + return linux_shmget(l, uap, retval); case LINUX_SYS_shmctl: { struct linux_sys_shmctl_args bsa; SCARG(&bsa, shmid) = SCARG(uap, a1); SCARG(&bsa, cmd) = SCARG(uap, a2); SCARG(&bsa, buf) = (struct linux_shmid_ds *)SCARG(uap, ptr); - return linux_sys_shmctl(p, &bsa, retval); + return linux_sys_shmctl(l, &bsa, retval); } #endif default: return ENOSYS; @@ -168,10 +168,10 @@ } #ifdef SYSVSEM inline int -linux_semop(p, uap, retval) - struct proc *p; +linux_semop(l, uap, retval) + struct lwp *l; struct linux_sys_ipc_args /* { syscallarg(int) what; syscallarg(int) a1; syscallarg(int) a2; @@ -185,14 +185,14 @@ SCARG(&bsa, semid) = SCARG(uap, a1); SCARG(&bsa, sops) = (struct sembuf *)SCARG(uap, ptr); SCARG(&bsa, nsops) = SCARG(uap, a2); - return sys_semop(p, &bsa, retval); + return sys_semop(l, &bsa, retval); } inline int -linux_semget(p, uap, retval) - struct proc *p; +linux_semget(l, uap, retval) + struct lwp *l; struct linux_sys_ipc_args /* { syscallarg(int) what; syscallarg(int) a1; syscallarg(int) a2; @@ -206,18 +206,18 @@ SCARG(&bsa, key) = (key_t)SCARG(uap, a1); SCARG(&bsa, nsems) = SCARG(uap, a2); SCARG(&bsa, semflg) = SCARG(uap, a3); - return sys_semget(p, &bsa, retval); + return sys_semget(l, &bsa, retval); } #endif /* SYSVSEM */ #ifdef SYSVMSG inline int -linux_msgsnd(p, uap, retval) - struct proc *p; +linux_msgsnd(l, uap, retval) + struct lwp *l; struct linux_sys_ipc_args /* { syscallarg(int) what; syscallarg(int) a1; syscallarg(int) a2; @@ -232,14 +232,14 @@ SCARG(&bma, msgp) = SCARG(uap, ptr); SCARG(&bma, msgsz) = SCARG(uap, a2); SCARG(&bma, msgflg) = SCARG(uap, a3); - return sys_msgsnd(p, &bma, retval); + return sys_msgsnd(l, &bma, retval); } inline int -linux_msgrcv(p, uap, retval) - struct proc *p; +linux_msgrcv(l, uap, retval) + struct lwp *l; struct linux_sys_ipc_args /* { syscallarg(int) what; syscallarg(int) a1; syscallarg(int) a2; @@ -260,14 +260,14 @@ SCARG(&bma, msgsz) = SCARG(uap, a2); SCARG(&bma, msgtyp) = kluge.type; SCARG(&bma, msgflg) = SCARG(uap, a3); - return sys_msgrcv(p, &bma, retval); + return sys_msgrcv(l, &bma, retval); } inline int -linux_msgget(p, uap, retval) - struct proc *p; +linux_msgget(l, uap, retval) + struct lwp *l; struct linux_sys_ipc_args /* { syscallarg(int) what; syscallarg(int) a1; syscallarg(int) a2; @@ -280,9 +280,9 @@ SCARG(&bma, key) = (key_t)SCARG(uap, a1); SCARG(&bma, msgflg) = SCARG(uap, a2); - return sys_msgget(p, &bma, retval); + return sys_msgget(l, &bma, retval); } #endif /* SYSVMSG */ @@ -291,10 +291,10 @@ * shmdt(): this could have been mapped directly, if it wasn't for * the extra indirection by the linux_ipc system call. */ inline int -linux_shmdt(p, uap, retval) - struct proc *p; +linux_shmdt(l, uap, retval) + struct lwp *l; struct linux_sys_ipc_args /* { syscallarg(int) what; syscallarg(int) a1; syscallarg(int) a2; @@ -306,17 +306,17 @@ struct sys_shmdt_args bsa; SCARG(&bsa, shmaddr) = SCARG(uap, ptr); - return sys_shmdt(p, &bsa, retval); + return sys_shmdt(l, &bsa, retval); } /* * Same story as shmdt. */ inline int -linux_shmget(p, uap, retval) - struct proc *p; +linux_shmget(l, uap, retval) + struct lwp *l; struct linux_sys_ipc_args /* { syscallarg(int) what; syscallarg(int) a1; syscallarg(int) a2; @@ -330,8 +330,8 @@ SCARG(&bsa, key) = SCARG(uap, a1); SCARG(&bsa, size) = SCARG(uap, a2); SCARG(&bsa, shmflg) = SCARG(uap, a3); - return sys_shmget(p, &bsa, retval); + return sys_shmget(l, &bsa, retval); } #endif /* SYSVSHM */ Index: sys/compat/linux/common/linux_ipccall.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_ipccall.h,v retrieving revision 1.7 retrieving revision 1.7.20.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.7 -r1.7.20.1 --- sys/compat/linux/common/linux_ipccall.h 1999/01/10 15:05:36 1.7 +++ sys/compat/linux/common/linux_ipccall.h 2001/03/05 22:49:25 1.7.20.1 @@ -65,29 +65,29 @@ #define LINUX_SYS_shmctl 24 # ifdef SYSVSEM -inline int linux_semop __P((struct proc *, struct linux_sys_ipc_args *, +inline int linux_semop __P((struct lwp *, struct linux_sys_ipc_args *, register_t *)); -inline int linux_semget __P((struct proc *, struct linux_sys_ipc_args *, +inline int linux_semget __P((struct lwp *, struct linux_sys_ipc_args *, register_t *)); # endif # ifdef SYSVMSG -inline int linux_msgsnd __P((struct proc *, struct linux_sys_ipc_args *, +inline int linux_msgsnd __P((struct lwp *, struct linux_sys_ipc_args *, register_t *)); -inline int linux_msgrcv __P((struct proc *, struct linux_sys_ipc_args *, +inline int linux_msgrcv __P((struct lwp *, struct linux_sys_ipc_args *, register_t *)); -inline int linux_msgget __P((struct proc *, struct linux_sys_ipc_args *, +inline int linux_msgget __P((struct lwp *, struct linux_sys_ipc_args *, register_t *)); # endif # ifdef SYSVSHM -inline int linux_shmdt __P((struct proc *, struct linux_sys_ipc_args *, +inline int linux_shmdt __P((struct lwp *, struct linux_sys_ipc_args *, register_t *)); -inline int linux_shmget __P((struct proc *, struct linux_sys_ipc_args *, +inline int linux_shmget __P((struct lwp *, struct linux_sys_ipc_args *, register_t *)); # endif # endif Index: sys/compat/linux/common/linux_llseek.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_llseek.c,v retrieving revision 1.25 retrieving revision 1.25.24.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.25 -r1.25.24.1 --- sys/compat/linux/common/linux_llseek.c 1998/10/04 00:02:36 1.25 +++ sys/compat/linux/common/linux_llseek.c 2001/03/05 22:49:25 1.25.24.1 @@ -58,10 +58,10 @@ /* * This appears to be part of a Linux attempt to switch to 64 bits file sizes. */ int -linux_sys_llseek(p, v, retval) - struct proc *p; +linux_sys_llseek(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_llseek_args /* { @@ -80,9 +80,9 @@ SCARG(&bla, fd) = SCARG(uap, fd); SCARG(&bla, offset) = off; SCARG(&bla, whence) = SCARG(uap, whence); - if ((error = sys_lseek(p, &bla, retval))) + if ((error = sys_lseek(l, &bla, retval))) return error; if ((error = copyout(retval, SCARG(uap, res), sizeof (off_t)))) return error; Index: sys/compat/linux/common/linux_misc.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_misc.c,v retrieving revision 1.87 retrieving revision 1.83.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.87 -r1.83.2.2 --- sys/compat/linux/common/linux_misc.c 2001/03/30 17:16:34 1.87 +++ sys/compat/linux/common/linux_misc.c 2001/04/09 01:55:42 1.83.2.2 @@ -65,8 +65,9 @@ #include #include #include +#include #include #include #include #include @@ -157,10 +158,10 @@ /* * This is very much the same as waitpid() */ int -linux_sys_wait4(p, v, retval) - struct proc *p; +linux_sys_wait4(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_wait4_args /* { @@ -168,8 +169,9 @@ syscallarg(int *) status; syscallarg(int) options; syscallarg(struct rusage *) rusage; } */ *uap = v; + struct proc *p = l->l_proc; struct sys_wait4_args w4a; int error, *status, tstat, options, linux_options; caddr_t sg; @@ -196,9 +198,9 @@ SCARG(&w4a, status) = status; SCARG(&w4a, options) = options; SCARG(&w4a, rusage) = SCARG(uap, rusage); - if ((error = sys_wait4(p, &w4a, retval))) + if ((error = sys_wait4(l, &w4a, retval))) return error; sigdelset(&p->p_sigctx.ps_siglist, SIGCHLD); @@ -217,30 +219,30 @@ * Linux brk(2). The check if the new address is >= the old one is * done in the kernel in Linux. NetBSD does it in the library. */ int -linux_sys_brk(p, v, retval) - struct proc *p; +linux_sys_brk(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_brk_args /* { syscallarg(char *) nsize; } */ *uap = v; + struct proc *p = l->l_proc; char *nbrk = SCARG(uap, nsize); struct sys_obreak_args oba; struct vmspace *vm = p->p_vmspace; struct linux_emuldata *ed = (struct linux_emuldata*)p->p_emuldata; SCARG(&oba, nsize) = nbrk; - if ((caddr_t) nbrk > vm->vm_daddr && sys_obreak(p, &oba, retval) == 0) - ed->p_break = (char*)nbrk; - else + if ((caddr_t) nbrk > vm->vm_daddr && sys_obreak(l, &oba, retval) == 0) + ed->p_break = (char *)nbrk; + else nbrk = ed->p_break; retval[0] = (register_t)nbrk; - return 0; } /* @@ -270,17 +272,18 @@ /* * Implement the fs stat functions. Straightforward. */ int -linux_sys_statfs(p, v, retval) - struct proc *p; +linux_sys_statfs(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_statfs_args /* { syscallarg(const char *) path; syscallarg(struct linux_statfs *) sp; } */ *uap = v; + struct proc *p = l->l_proc; struct statfs btmp, *bsp; struct linux_statfs ltmp; struct sys_statfs_args bsa; caddr_t sg; @@ -293,9 +296,9 @@ SCARG(&bsa, path) = SCARG(uap, path); SCARG(&bsa, buf) = bsp; - if ((error = sys_statfs(p, &bsa, retval))) + if ((error = sys_statfs(l, &bsa, retval))) return error; if ((error = copyin((caddr_t) bsp, (caddr_t) &btmp, sizeof btmp))) return error; @@ -305,17 +308,18 @@ return copyout((caddr_t) <mp, (caddr_t) SCARG(uap, sp), sizeof ltmp); } int -linux_sys_fstatfs(p, v, retval) - struct proc *p; +linux_sys_fstatfs(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_fstatfs_args /* { syscallarg(int) fd; syscallarg(struct linux_statfs *) sp; } */ *uap = v; + struct proc *p = l->l_proc; struct statfs btmp, *bsp; struct linux_statfs ltmp; struct sys_fstatfs_args bsa; caddr_t sg; @@ -326,9 +330,9 @@ SCARG(&bsa, fd) = SCARG(uap, fd); SCARG(&bsa, buf) = bsp; - if ((error = sys_fstatfs(p, &bsa, retval))) + if ((error = sys_fstatfs(l, &bsa, retval))) return error; if ((error = copyin((caddr_t) bsp, (caddr_t) &btmp, sizeof btmp))) return error; @@ -348,10 +352,10 @@ * is almost the same as the NetBSD one, only it has fields 65 characters * long, and an extra domainname field. */ int -linux_sys_uname(p, v, retval) - struct proc *p; +linux_sys_uname(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_uname_args /* { @@ -376,10 +380,10 @@ * New type Linux mmap call. * Only called directly on machines with >= 6 free regs. */ int -linux_sys_mmap(p, v, retval) - struct proc *p; +linux_sys_mmap(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_mmap_args /* { @@ -409,14 +413,14 @@ SCARG(&cma,fd) = flags & MAP_ANON ? -1 : SCARG(uap, fd); SCARG(&cma,pad) = 0; SCARG(&cma,pos) = SCARG(uap, offset); - return sys_mmap(p, &cma, retval); + return sys_mmap(l, &cma, retval); } int -linux_sys_mremap(p, v, retval) - struct proc *p; +linux_sys_mremap(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_mremap_args /* { @@ -452,9 +456,9 @@ if (new_size < old_size) { SCARG(&mua, addr) = (caddr_t)SCARG(uap, old_address) + new_size; SCARG(&mua, len) = old_size - new_size; - error = sys_munmap(p, &mua, retval); + error = sys_munmap(l, &mua, retval); *retval = error ? 0 : (register_t)SCARG(uap, old_address); return (error); } @@ -465,10 +469,10 @@ return (0); } int -linux_sys_msync(p, v, retval) - struct proc *p; +linux_sys_msync(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_msync_args /* { @@ -483,9 +487,9 @@ SCARG(&bma, addr) = SCARG(uap, addr); SCARG(&bma, len) = SCARG(uap, len); SCARG(&bma, flags) = SCARG(uap, fl); - return sys___msync13(p, &bma, retval); + return sys___msync13(l, &bma, retval); } /* * This code is partly stolen from src/lib/libc/compat-43/times.c @@ -495,16 +499,17 @@ #define CLK_TCK 100 #define CONVTCK(r) (r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK)) int -linux_sys_times(p, v, retval) - struct proc *p; +linux_sys_times(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_times_args /* { syscallarg(struct times *) tms; } */ *uap = v; + struct proc *p = l->l_proc; struct timeval t; struct linux_tms ltms; struct rusage ru; int error, s; @@ -541,18 +546,19 @@ * * Note that this doesn't handle union-mounted filesystems. */ int -linux_sys_getdents(p, v, retval) - struct proc *p; +linux_sys_getdents(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_getdents_args /* { syscallarg(int) fd; syscallarg(struct linux_dirent *) dent; syscallarg(unsigned int) count; } */ *uap = v; + struct proc *p = l->l_proc; struct dirent *bdp; struct vnode *vp; caddr_t inp, buf; /* BSD-format */ int len, reclen; /* BSD-format */ @@ -701,10 +707,10 @@ * have 5 of them on the i386. So this newer version of select() does * this. */ int -linux_sys_select(p, v, retval) - struct proc *p; +linux_sys_select(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_select_args /* { @@ -714,9 +720,9 @@ syscallarg(fd_set *) exceptfds; syscallarg(struct timeval *) timeout; } */ *uap = v; - return linux_select1(p, retval, SCARG(uap, nfds), SCARG(uap, readfds), + return linux_select1(l, retval, SCARG(uap, nfds), SCARG(uap, readfds), SCARG(uap, writefds), SCARG(uap, exceptfds), SCARG(uap, timeout)); } /* @@ -725,16 +731,17 @@ * 1) return the amount of time left in the 'timeout' parameter * 2) select never returns ERESTART on Linux, always return EINTR */ int -linux_select1(p, retval, nfds, readfds, writefds, exceptfds, timeout) - struct proc *p; +linux_select1(l, retval, nfds, readfds, writefds, exceptfds, timeout) + struct lwp *l; register_t *retval; int nfds; fd_set *readfds, *writefds, *exceptfds; struct timeval *timeout; { struct sys_select_args bsa; + struct proc *p = l->l_proc; struct timeval tv0, tv1, utv, *tvp; caddr_t sg; int error; @@ -772,9 +779,9 @@ } microtime(&tv0); } - error = sys_select(p, &bsa, retval); + error = sys_select(l, &bsa, retval); if (error) { /* * See fs/select.c in the Linux kernel. Without this, * Maelstrom doesn't work. @@ -810,16 +817,17 @@ * Get the process group of a certain process. Look it up * and return the value. */ int -linux_sys_getpgid(p, v, retval) - struct proc *p; +linux_sys_getpgid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_getpgid_args /* { syscallarg(int) pid; } */ *uap = v; + struct proc *p = l->l_proc; struct proc *targp; if (SCARG(uap, pid) != 0 && SCARG(uap, pid) != p->p_pid) { if ((targp = pfind(SCARG(uap, pid))) == 0) @@ -838,10 +846,10 @@ * the Linux ELF crt0 issues it in an ugly kludge to make sure that * ELF binaries run in Linux mode, not SVR4 mode. */ int -linux_sys_personality(p, v, retval) - struct proc *p; +linux_sys_personality(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_personality_args /* { @@ -858,10 +866,10 @@ /* * The calls are here because of type conversions. */ int -linux_sys_setreuid16(p, v, retval) - struct proc *p; +linux_sys_setreuid16(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_setreuid16_args /* { @@ -874,14 +882,14 @@ (uid_t)-1 : SCARG(uap, ruid); SCARG(&bsa, euid) = ((linux_uid_t)SCARG(uap, euid) == (linux_uid_t)-1) ? (uid_t)-1 : SCARG(uap, euid); - return sys_setreuid(p, &bsa, retval); + return sys_setreuid(l, &bsa, retval); } int -linux_sys_setregid16(p, v, retval) - struct proc *p; +linux_sys_setregid16(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_setregid16_args /* { @@ -894,14 +902,14 @@ (uid_t)-1 : SCARG(uap, rgid); SCARG(&bsa, egid) = ((linux_gid_t)SCARG(uap, egid) == (linux_gid_t)-1) ? (uid_t)-1 : SCARG(uap, egid); - return sys_setregid(p, &bsa, retval); + return sys_setregid(l, &bsa, retval); } int -linux_sys_setresuid16(p, v, retval) - struct proc *p; +linux_sys_setresuid16(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_setresuid16_args /* { @@ -917,14 +925,14 @@ (uid_t)-1 : SCARG(uap, euid); SCARG(&lsa, suid) = ((linux_uid_t)SCARG(uap, suid) == (linux_uid_t)-1) ? (uid_t)-1 : SCARG(uap, suid); - return linux_sys_setresuid(p, &lsa, retval); + return linux_sys_setresuid(l, &lsa, retval); } int -linux_sys_setresgid16(p, v, retval) - struct proc *p; +linux_sys_setresgid16(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_setresgid16_args /* { @@ -940,21 +948,22 @@ (gid_t)-1 : SCARG(uap, egid); SCARG(&lsa, sgid) = ((linux_gid_t)SCARG(uap, sgid) == (linux_gid_t)-1) ? (gid_t)-1 : SCARG(uap, sgid); - return linux_sys_setresgid(p, &lsa, retval); + return linux_sys_setresgid(l, &lsa, retval); } int -linux_sys_getgroups16(p, v, retval) - struct proc *p; +linux_sys_getgroups16(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_getgroups16_args /* { syscallarg(int) gidsetsize; syscallarg(linux_gid_t *) gidset; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg; int n, error, i; struct sys_getgroups_args bsa; gid_t *bset, *kbset; @@ -976,9 +985,9 @@ if (bset == NULL || kbset == NULL || lset == NULL) return ENOMEM; SCARG(&bsa, gidsetsize) = n; SCARG(&bsa, gidset) = bset; - error = sys_getgroups(p, &bsa, retval); + error = sys_getgroups(l, &bsa, retval); if (error != 0) goto out; error = copyin(bset, kbset, n * sizeof (gid_t)); if (error != 0) @@ -997,17 +1006,18 @@ return error; } int -linux_sys_setgroups16(p, v, retval) - struct proc *p; +linux_sys_setgroups16(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_setgroups16_args /* { syscallarg(int) gidsetsize; syscallarg(linux_gid_t *) gidset; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg; int n; int error, i; struct sys_setgroups_args bsa; @@ -1032,9 +1042,9 @@ if (error != 0) goto out; SCARG(&bsa, gidsetsize) = n; SCARG(&bsa, gidset) = bset; - error = sys_setgroups(p, &bsa, retval); + error = sys_setgroups(l, &bsa, retval); out: if (lset != NULL) free(lset, M_TEMP); @@ -1050,40 +1060,41 @@ * We have nonexistent fsuid equal to uid. * If modification is requested, refuse. */ int -linux_sys_setfsuid(p, v, retval) - struct proc *p; +linux_sys_setfsuid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_setfsuid_args /* { syscallarg(uid_t) uid; } */ *uap = v; + struct proc *p = l->l_proc; uid_t uid; uid = SCARG(uap, uid); if (p->p_cred->p_ruid != uid) - return sys_nosys(p, v, retval); + return sys_nosys(l, v, retval); else return (0); } /* XXX XXX XXX */ #ifndef alpha int -linux_sys_getfsuid(p, v, retval) - struct proc *p; +linux_sys_getfsuid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { - return sys_getuid(p, v, retval); + return sys_getuid(l, v, retval); } #endif int -linux_sys___sysctl(p, v, retval) - struct proc *p; +linux_sys___sysctl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys___sysctl_args /* { @@ -1101,22 +1112,23 @@ SCARG(&bsa, oldlenp) = ls.oldlenp; SCARG(&bsa, new) = ls.new; SCARG(&bsa, newlen) = ls.newlen; - return sys___sysctl(p, &bsa, retval); + return sys___sysctl(l, &bsa, retval); } int -linux_sys_setresuid(p, v, retval) - struct proc *p; +linux_sys_setresuid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_setresuid_args /* { syscallarg(uid_t) ruid; syscallarg(uid_t) euid; syscallarg(uid_t) suid; } */ *uap = v; + struct proc *p = l->l_proc; struct pcred *pc = p->p_cred; uid_t ruid, euid, suid; int error; @@ -1175,18 +1187,19 @@ return (0); } int -linux_sys_getresuid(p, v, retval) - struct proc *p; +linux_sys_getresuid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_getresuid_args /* { syscallarg(uid_t *) ruid; syscallarg(uid_t *) euid; syscallarg(uid_t *) suid; } */ *uap = v; + struct proc *p = l->l_proc; struct pcred *pc = p->p_cred; int error; /* @@ -1207,10 +1220,10 @@ return (copyout(&pc->p_svuid, SCARG(uap, suid), sizeof(uid_t))); } int -linux_sys_ptrace(p, v, retval) - struct proc *p; +linux_sys_ptrace(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_ptrace_args /* { @@ -1220,8 +1233,9 @@ syscallarg(T) pid; syscallarg(T) addr; syscallarg(T) data; } */ *uap = v; + struct proc *p = l->l_proc; const int *ptr; int request; ptr = linux_ptrace_request_map; @@ -1246,18 +1260,18 @@ */ if (request == LINUX_PTRACE_CONT && SCARG(uap, addr)==0) SCARG(&pta, addr) = (caddr_t) 1; - return sys_ptrace(p, &pta, retval); + return sys_ptrace(l, &pta, retval); } else ptr++; - return LINUX_SYS_PTRACE_ARCH(p, uap, retval); + return LINUX_SYS_PTRACE_ARCH(l, uap, retval); } int -linux_sys_reboot(struct proc *p, void *v, register_t *retval) +linux_sys_reboot(struct lwp *l, void *v, register_t *retval) { struct linux_sys_reboot_args /* { syscallarg(int) magic1; syscallarg(int) magic2; @@ -1267,8 +1281,9 @@ struct sys_reboot_args /* { syscallarg(int) opt; syscallarg(char *) bootstr; } */ sra; + struct proc *p = l->l_proc; int error; if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) return(error); @@ -1302,17 +1317,17 @@ default: return(EINVAL); } - return(sys_reboot(p, &sra, retval)); + return(sys_reboot(l, &sra, retval)); } /* * Copy of compat_12_sys_swapon(). */ int -linux_sys_swapon(p, v, retval) - struct proc *p; +linux_sys_swapon(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_swapctl_args ua; @@ -1322,17 +1337,17 @@ SCARG(&ua, cmd) = SWAP_ON; SCARG(&ua, arg) = (void *)SCARG(uap, name); SCARG(&ua, misc) = 0; /* priority */ - return (sys_swapctl(p, &ua, retval)); + return (sys_swapctl(l, &ua, retval)); } /* * Stop swapping to the file or block device specified by path. */ int -linux_sys_swapoff(p, v, retval) - struct proc *p; +linux_sys_swapoff(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_swapctl_args ua; @@ -1341,25 +1356,26 @@ } */ *uap = v; SCARG(&ua, cmd) = SWAP_OFF; SCARG(&ua, arg) = (void *)SCARG(uap, path); - return (sys_swapctl(p, &ua, retval)); + return (sys_swapctl(l, &ua, retval)); } /* * Copy of compat_09_sys_setdomainname() */ /* ARGSUSED */ int -linux_sys_setdomainname(p, v, retval) - struct proc *p; +linux_sys_setdomainname(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_setdomainname_args /* { syscallarg(char *) domainname; syscallarg(int) len; } */ *uap = v; + struct proc *p = l->l_proc; int name; int error; if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) @@ -1373,10 +1389,10 @@ * sysinfo() */ /* ARGSUSED */ int -linux_sys_sysinfo(p, v, retval) - struct proc *p; +linux_sys_sysinfo(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_sysinfo_args /* { @@ -1411,10 +1427,10 @@ * is that process does not get SIGSYS, the call just returns with ENOSYS. * This is the way Linux does it and glibc depends on this behaviour. */ int -linux_sys_nosys(p, v, retval) - struct proc *p; +linux_sys_nosys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { return (ENOSYS); Index: sys/compat/linux/common/linux_misc.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_misc.h,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.4 -r1.4.2.1 --- sys/compat/linux/common/linux_misc.h 2000/12/13 21:41:24 1.4 +++ sys/compat/linux/common/linux_misc.h 2001/03/05 22:49:26 1.4.2.1 @@ -66,9 +66,9 @@ #ifdef _KERNEL __BEGIN_DECLS void bsd_to_linux_wstat __P((int *)); -int linux_select1 __P((struct proc *, register_t *, int, fd_set *, fd_set *, +int linux_select1 __P((struct lwp *, register_t *, int, fd_set *, fd_set *, fd_set *, struct timeval *)); __END_DECLS #endif /* !_KERNEL */ Index: sys/compat/linux/common/linux_misc_notalpha.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_misc_notalpha.c,v retrieving revision 1.60 retrieving revision 1.60.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.60 -r1.60.2.1 --- sys/compat/linux/common/linux_misc_notalpha.c 2000/12/22 22:58:58 1.60 +++ sys/compat/linux/common/linux_misc_notalpha.c 2001/03/05 22:49:26 1.60.2.1 @@ -74,16 +74,17 @@ * Alarm. This is a libc call which uses setitimer(2) in NetBSD. * Fiddle with the timers to make it work. */ int -linux_sys_alarm(p, v, retval) - struct proc *p; +linux_sys_alarm(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_alarm_args /* { syscallarg(unsigned int) secs; } */ *uap = v; + struct proc *p = l->l_proc; int s; struct itimerval *itp, it; itp = &p->p_realtimer; @@ -138,10 +139,10 @@ return 0; } int -linux_sys_nice(p, v, retval) - struct proc *p; +linux_sys_nice(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_nice_args /* { @@ -151,9 +152,9 @@ SCARG(&bsa, which) = PRIO_PROCESS; SCARG(&bsa, who) = 0; SCARG(&bsa, prio) = SCARG(uap, incr); - return sys_setpriority(p, &bsa, retval); + return sys_setpriority(l, &bsa, retval); } /* * The old Linux readdir was only able to read one entry at a time, @@ -164,10 +165,10 @@ * newer one actually does multiple entries, and the reclen field * really is the reclen, not the namelength. */ int -linux_sys_readdir(p, v, retval) - struct proc *p; +linux_sys_readdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_readdir_args /* { @@ -176,18 +177,18 @@ syscallarg(unsigned int) count; } */ *uap = v; SCARG(uap, count) = 1; - return linux_sys_getdents(p, uap, retval); + return linux_sys_getdents(l, uap, retval); } /* * I wonder why Linux has gettimeofday() _and_ time().. Still, we * need to deal with it. */ int -linux_sys_time(p, v, retval) - struct proc *p; +linux_sys_time(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_time_args /* { @@ -211,17 +212,18 @@ * utime(). Do conversion to things that utimes() understands, * and pass it on. */ int -linux_sys_utime(p, v, retval) - struct proc *p; +linux_sys_utime(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_utime_args /* { syscallarg(const char *) path; syscallarg(struct linux_utimbuf *)times; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg; int error; struct sys_utimes_args ua; struct timeval tv[2], *tvp; @@ -245,27 +247,28 @@ } else SCARG(&ua, tptr) = NULL; - return sys_utimes(p, &ua, retval); + return sys_utimes(l, &ua, retval); } /* * waitpid(2). Passed on to the NetBSD call, surrounded by code to * reserve some space for a NetBSD-style wait status, and converting * it to what Linux wants. */ int -linux_sys_waitpid(p, v, retval) - struct proc *p; +linux_sys_waitpid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_waitpid_args /* { syscallarg(int) pid; syscallarg(int *) status; syscallarg(int) options; } */ *uap = v; + struct proc *p = l->l_proc; struct sys_wait4_args w4a; int error, *status, tstat; caddr_t sg; @@ -279,9 +282,9 @@ SCARG(&w4a, status) = status; SCARG(&w4a, options) = SCARG(uap, options); SCARG(&w4a, rusage) = NULL; - if ((error = sys_wait4(p, &w4a, retval))) + if ((error = sys_wait4(l, &w4a, retval))) return error; sigdelset(&p->p_sigctx.ps_siglist, SIGCHLD); @@ -296,18 +299,19 @@ return 0; } int -linux_sys_setresgid(p, v, retval) - struct proc *p; +linux_sys_setresgid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_setresgid_args /* { syscallarg(gid_t) rgid; syscallarg(gid_t) egid; syscallarg(gid_t) sgid; } */ *uap = v; + struct proc *p = l->l_proc; struct pcred *pc = p->p_cred; gid_t rgid, egid, sgid; int error; @@ -363,18 +367,19 @@ return (0); } int -linux_sys_getresgid(p, v, retval) - struct proc *p; +linux_sys_getresgid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_getresgid_args /* { syscallarg(gid_t *) rgid; syscallarg(gid_t *) egid; syscallarg(gid_t *) sgid; } */ *uap = v; + struct proc *p = l->l_proc; struct pcred *pc = p->p_cred; int error; /* @@ -399,16 +404,17 @@ * I wonder why Linux has settimeofday() _and_ stime().. Still, we * need to deal with it. */ int -linux_sys_stime(p, v, retval) - struct proc *p; +linux_sys_stime(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_time_args /* { linux_time_t *t; } */ *uap = v; + struct proc *p = l->l_proc; struct timeval atv; linux_time_t tt; int error; Index: sys/compat/linux/common/linux_mmap.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_mmap.h,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.8 -r1.8.2.1 --- sys/compat/linux/common/linux_mmap.h 2001/01/19 12:35:47 1.8 +++ sys/compat/linux/common/linux_mmap.h 2001/03/05 22:49:26 1.8.2.1 @@ -86,9 +86,9 @@ }; #ifdef _KERNEL __BEGIN_DECLS -int linux_sys_mmap __P((struct proc *p, void *v, register_t *retval)); +int linux_sys_mmap __P((struct lwp *p, void *v, register_t *retval)); __END_DECLS #endif /* !_KERNEL */ #endif /* !_LINUX_MMAP_H */ Index: sys/compat/linux/common/linux_msg.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_msg.h,v retrieving revision 1.5 retrieving revision 1.5.24.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.5 -r1.5.24.1 --- sys/compat/linux/common/linux_msg.h 1998/10/04 00:02:37 1.5 +++ sys/compat/linux/common/linux_msg.h 2001/03/05 22:49:26 1.5.24.1 @@ -107,9 +107,9 @@ #ifdef SYSVMSG #ifdef _KERNEL __BEGIN_DECLS -int linux_sys_msgctl __P((struct proc *, void *, register_t *)); +int linux_sys_msgctl __P((struct lwp *, void *, register_t *)); void linux_to_bsd_msqid_ds __P((struct linux_msqid_ds *, struct msqid_ds *)); void bsd_to_linux_msqid_ds __P((struct msqid_ds *, struct linux_msqid_ds *)); Index: sys/compat/linux/common/linux_oldmmap.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_oldmmap.c,v retrieving revision 1.53 retrieving revision 1.53.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.53 -r1.53.2.1 --- sys/compat/linux/common/linux_oldmmap.c 2000/12/29 20:08:54 1.53 +++ sys/compat/linux/common/linux_oldmmap.c 2001/03/05 22:49:26 1.53.2.1 @@ -57,10 +57,10 @@ * However mmap() has 6 of them. Oops: out of register error. * They just pass everything in a structure. */ int -linux_sys_old_mmap(p, v, retval) - struct proc *p; +linux_sys_old_mmap(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_old_mmap_args /* { @@ -79,7 +79,7 @@ SCARG(&nlmap,flags) = lmap.lm_flags; SCARG(&nlmap,fd) = lmap.lm_fd; SCARG(&nlmap,offset) = (unsigned)lmap.lm_pos; - return linux_sys_mmap(p, &nlmap, retval); + return linux_sys_mmap(l, &nlmap, retval); } Index: sys/compat/linux/common/linux_oldolduname.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_oldolduname.c,v retrieving revision 1.55 retrieving revision 1.55.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.55 -r1.55.2.1 --- sys/compat/linux/common/linux_oldolduname.c 2000/12/29 21:07:16 1.55 +++ sys/compat/linux/common/linux_oldolduname.c 2001/03/05 22:49:26 1.55.2.1 @@ -53,10 +53,10 @@ /* Used on: arm, i386, mips, ppc */ /* Not used on: alpha, m68k, sparc, sparc64 */ int -linux_sys_oldolduname(p, v, retval) - struct proc *p; +linux_sys_oldolduname(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_uname_args /* { Index: sys/compat/linux/common/linux_oldselect.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_oldselect.c,v retrieving revision 1.51 retrieving revision 1.51.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.51 -r1.51.2.1 --- sys/compat/linux/common/linux_oldselect.c 2000/06/29 02:40:39 1.51 +++ sys/compat/linux/common/linux_oldselect.c 2001/03/05 22:49:26 1.51.2.1 @@ -58,10 +58,10 @@ * into a structure, because there are 5, and that can all be handled * in registers on the i386 like Linux wants to. */ int -linux_sys_oldselect(p, v, retval) - struct proc *p; +linux_sys_oldselect(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_oldselect_args /* { @@ -72,8 +72,8 @@ if ((error = copyin(SCARG(uap, lsp), &ls, sizeof(ls)))) return error; - return linux_select1(p, retval, ls.nfds, ls.readfds, ls.writefds, + return linux_select1(l, retval, ls.nfds, ls.readfds, ls.writefds, ls.exceptfds, ls.timeout); } Index: sys/compat/linux/common/linux_olduname.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_olduname.c,v retrieving revision 1.56 retrieving revision 1.56.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.56 -r1.56.2.1 --- sys/compat/linux/common/linux_olduname.c 2000/12/29 21:07:16 1.56 +++ sys/compat/linux/common/linux_olduname.c 2001/03/05 22:49:27 1.56.2.1 @@ -56,10 +56,10 @@ /* Not used on: sparc */ /* Alpha: XXX Only if we assume osf_utsname is used by Linux programs. */ int -linux_sys_olduname(p, v, retval) - struct proc *p; +linux_sys_olduname(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_uname_args /* { Index: sys/compat/linux/common/linux_pipe.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_pipe.c,v retrieving revision 1.51 retrieving revision 1.51.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.51 -r1.51.2.1 --- sys/compat/linux/common/linux_pipe.c 2000/06/29 02:40:39 1.51 +++ sys/compat/linux/common/linux_pipe.c 2001/03/05 22:49:27 1.51.2.1 @@ -60,19 +60,19 @@ * NetBSD passes fd[0] in retval[0], and fd[1] in retval[1]. * Linux directly passes the pointer. */ int -linux_sys_pipe(p, v, retval) - struct proc *p; +linux_sys_pipe(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_pipe_args /* { syscallarg(int *) pfds; } */ *uap = v; int error; - if ((error = sys_pipe(p, 0, retval))) + if ((error = sys_pipe(l, 0, retval))) return error; /* Assumes register_t is an int */ if ((error = copyout(retval, SCARG(uap, pfds), 2 * sizeof (int)))) Index: sys/compat/linux/common/linux_ptrace.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_ptrace.h,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.3 -r1.3.4.1 --- sys/compat/linux/common/linux_ptrace.h 2000/11/01 21:02:09 1.3 +++ sys/compat/linux/common/linux_ptrace.h 2001/03/05 22:49:27 1.3.4.1 @@ -57,12 +57,12 @@ #define LINUX_PTRACE_DETACH 17 #define LINUX_PTRACE_SYSCALL 24 #if defined(__i386__) -int linux_sys_ptrace_arch __P((struct proc *, void *, register_t *)); +int linux_sys_ptrace_arch __P((struct lwp *, void *, register_t *)); -#define LINUX_SYS_PTRACE_ARCH(p,v,r) linux_sys_ptrace_arch((p),(v),(r)) +#define LINUX_SYS_PTRACE_ARCH(l,v,r) linux_sys_ptrace_arch((l),(v),(r)) #else -#define LINUX_SYS_PTRACE_ARCH(p,v,r) EIO +#define LINUX_SYS_PTRACE_ARCH(l,v,r) EIO #endif #endif /* !_LINUX_PTRACE_H */ Index: sys/compat/linux/common/linux_sched.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_sched.c,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.7 -r1.7.2.1 --- sys/compat/linux/common/linux_sched.c 2000/08/25 01:04:12 1.7 +++ sys/compat/linux/common/linux_sched.c 2001/03/05 22:49:27 1.7.2.1 @@ -43,8 +43,9 @@ #include #include #include +#include #include #include #include @@ -57,10 +58,10 @@ #include int -linux_sys_clone(p, v, retval) - struct proc *p; +linux_sys_clone(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_clone_args /* { @@ -98,22 +99,23 @@ * the stack area; the caller must know if the stack grows up * or down. So, we pass a stack size of 0, so that the code * that makes this adjustment is a noop. */ - return (fork1(p, flags, sig, SCARG(uap, stack), 0, + return (fork1(l, flags, sig, SCARG(uap, stack), 0, NULL, NULL, retval, NULL)); } int -linux_sys_sched_setparam(cp, v, retval) - struct proc *cp; +linux_sys_sched_setparam(cl, v, retval) + struct lwp *cl; void *v; register_t *retval; { struct linux_sys_sched_setparam_args /* { syscallarg(linux_pid_t) pid; syscallarg(const struct linux_sched_param *) sp; } */ *uap = v; + struct proc *cp = cl->l_proc; int error; struct linux_sched_param lp; struct proc *p; @@ -145,17 +147,18 @@ return 0; } int -linux_sys_sched_getparam(cp, v, retval) - struct proc *cp; +linux_sys_sched_getparam(cl, v, retval) + struct lwp *cl; void *v; register_t *retval; { struct linux_sys_sched_getparam_args /* { syscallarg(linux_pid_t) pid; syscallarg(struct linux_sched_param *) sp; } */ *uap = v; + struct proc *cp = cl->l_proc; struct proc *p; struct linux_sched_param lp; /* @@ -182,18 +185,19 @@ return copyout(&lp, SCARG(uap, sp), sizeof(lp)); } int -linux_sys_sched_setscheduler(cp, v, retval) - struct proc *cp; +linux_sys_sched_setscheduler(cl, v, retval) + struct lwp *cl; void *v; register_t *retval; { struct linux_sys_sched_setscheduler_args /* { syscallarg(linux_pid_t) pid; syscallarg(int) policy; syscallarg(cont struct linux_sched_scheduler *) sp; } */ *uap = v; + struct proc *cp = cl->l_proc; int error; struct linux_sched_param lp; struct proc *p; @@ -231,16 +235,17 @@ return 0; } int -linux_sys_sched_getscheduler(cp, v, retval) - struct proc *cp; +linux_sys_sched_getscheduler(cl, v, retval) + struct lwp *cl; void *v; register_t *retval; { struct linux_sys_sched_getscheduler_args /* { syscallarg(linux_pid_t) pid; } */ *uap = v; + struct proc *cp = cl->l_proc; struct proc *p; *retval = -1; /* @@ -268,20 +273,20 @@ return 0; } int -linux_sys_sched_yield(cp, v, retval) - struct proc *cp; +linux_sys_sched_yield(cl, v, retval) + struct lwp *cl; void *v; register_t *retval; { need_resched(curcpu()); return 0; } int -linux_sys_sched_get_priority_max(cp, v, retval) - struct proc *cp; +linux_sys_sched_get_priority_max(cl, v, retval) + struct lwp *cl; void *v; register_t *retval; { struct linux_sys_sched_get_priority_max_args /* { @@ -300,10 +305,10 @@ return 0; } int -linux_sys_sched_get_priority_min(cp, v, retval) - struct proc *cp; +linux_sys_sched_get_priority_min(cl, v, retval) + struct lwp *cl; void *v; register_t *retval; { struct linux_sys_sched_get_priority_min_args /* { Index: sys/compat/linux/common/linux_sem.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_sem.h,v retrieving revision 1.4 retrieving revision 1.4.24.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.4 -r1.4.24.1 --- sys/compat/linux/common/linux_sem.h 1998/10/04 00:02:41 1.4 +++ sys/compat/linux/common/linux_sem.h 2001/03/05 22:49:27 1.4.24.1 @@ -87,9 +87,9 @@ #ifdef SYSVSEM #ifdef _KERNEL __BEGIN_DECLS -int linux_sys_semctl __P((struct proc *, void *, register_t *)); +int linux_sys_semctl __P((struct lwp *, void *, register_t *)); void bsd_to_linux_semid_ds __P((struct semid_ds *, struct linux_semid_ds *)); void linux_to_bsd_semid_ds __P((struct linux_semid_ds *, struct semid_ds *)); Index: sys/compat/linux/common/linux_shm.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_shm.h,v retrieving revision 1.4 retrieving revision 1.4.24.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.4 -r1.4.24.1 --- sys/compat/linux/common/linux_shm.h 1998/10/04 00:02:41 1.4 +++ sys/compat/linux/common/linux_shm.h 2001/03/05 22:49:27 1.4.24.1 @@ -84,10 +84,10 @@ #ifdef SYSVSHM #ifdef _KERNEL __BEGIN_DECLS -int linux_sys_shmat __P((struct proc *, void *, register_t *)); -int linux_sys_shmctl __P((struct proc *, void *, register_t *)); +int linux_sys_shmat __P((struct lwp *, void *, register_t *)); +int linux_sys_shmctl __P((struct lwp *, void *, register_t *)); void linux_to_bsd_shmid_ds __P((struct linux_shmid_ds *, struct shmid_ds *)); void bsd_to_linux_shmid_ds __P((struct shmid_ds *, struct linux_shmid_ds *)); Index: sys/compat/linux/common/linux_sig_notalpha.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_sig_notalpha.c,v retrieving revision 1.22 retrieving revision 1.22.6.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.22 -r1.22.6.1 --- sys/compat/linux/common/linux_sig_notalpha.c 2000/03/30 11:27:17 1.22 +++ sys/compat/linux/common/linux_sig_notalpha.c 2001/03/05 22:49:28 1.22.6.1 @@ -66,17 +66,18 @@ * But hey, it can't hurt having it here. The same restrictions as for * sigaction() apply. */ int -linux_sys_signal(p, v, retval) - struct proc *p; +linux_sys_signal(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_signal_args /* { syscallarg(int) signum; syscallarg(linux_handler_t) handler; } */ *uap = v; + struct proc *p = l->l_proc; struct sigaction nbsa, obsa; int error, sig; *retval = -1; @@ -96,13 +97,14 @@ /* ARGSUSED */ int -linux_sys_siggetmask(p, v, retval) - struct proc *p; +linux_sys_siggetmask(l, v, retval) + struct lwp *l; void *v; register_t *retval; { + struct proc *p = l->l_proc; sigset_t bss; linux_old_sigset_t lss; int error; @@ -119,16 +121,17 @@ * values for Linux. The need for this is the reason why * they are here, and have not been mapped directly. */ int -linux_sys_sigsetmask(p, v, retval) - struct proc *p; +linux_sys_sigsetmask(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_sigsetmask_args /* { syscallarg(linux_old_sigset_t) mask; } */ *uap = v; + struct proc *p = l->l_proc; sigset_t nbss, obss; linux_old_sigset_t nlss, olss; int error; @@ -142,18 +145,19 @@ return (0); } int -linux_sys_sigprocmask(p, v, retval) - struct proc *p; +linux_sys_sigprocmask(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_sigprocmask_args /* { syscallarg(int) how; syscallarg(const linux_old_sigset_t *) set; syscallarg(linux_old_sigset_t *) oset; } */ *uap = v; + struct proc *p = l->l_proc; return(linux_sigprocmask1(p, SCARG(uap, how), SCARG(uap, set), SCARG(uap, oset))); } @@ -162,13 +166,14 @@ * The deprecated pause(2), which is really just an instance * of sigsuspend(2). */ int -linux_sys_pause(p, v, retval) - struct proc *p; +linux_sys_pause(l, v, retval) + struct lwp *l; void *v; register_t *retval; { + struct proc *p = l->l_proc; return (sigsuspend1(p, 0)); } Index: sys/compat/linux/common/linux_sigaction.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_sigaction.c,v retrieving revision 1.20 retrieving revision 1.20.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.20 -r1.20.2.1 --- sys/compat/linux/common/linux_sigaction.c 2000/08/09 20:20:49 1.20 +++ sys/compat/linux/common/linux_sigaction.c 2001/03/05 22:49:28 1.20.2.1 @@ -64,18 +64,19 @@ * The Linux sigaction() system call. Do the usual conversions, * and just call sigaction(). */ int -linux_sys_sigaction(p, v, retval) - struct proc *p; +linux_sys_sigaction(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_sigaction_args /* { syscallarg(int) signum; syscallarg(const struct linux_old_sigaction *) nsa; syscallarg(struct linux_old_sigaction *) osa; } */ *uap = v; + struct proc *p = l->l_proc; struct linux_old_sigaction nlsa, olsa; struct sigaction nbsa, obsa; int error, sig; Index: sys/compat/linux/common/linux_signal.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_signal.c,v retrieving revision 1.31 retrieving revision 1.31.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.31 -r1.31.2.1 --- sys/compat/linux/common/linux_signal.c 2001/01/18 20:28:27 1.31 +++ sys/compat/linux/common/linux_signal.c 2001/03/05 22:49:28 1.31.2.1 @@ -57,8 +57,9 @@ #include #include #include +#include #include #include #include #include @@ -316,10 +317,10 @@ * and just call sigaction(). Some flags and values are silently * ignored (see above). */ int -linux_sys_rt_sigaction(p, v, retval) - struct proc *p; +linux_sys_rt_sigaction(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_rt_sigaction_args /* { @@ -327,8 +328,9 @@ syscallarg(const struct linux_sigaction *) nsa; syscallarg(struct linux_sigaction *) osa; syscallarg(size_t) sigsetsize; } */ *uap = v; + struct proc *p = l->l_proc; struct linux_sigaction nlsa, olsa; struct sigaction nbsa, obsa; int error, sig; @@ -408,10 +410,10 @@ return (error); } int -linux_sys_rt_sigprocmask(p, v, retval) - struct proc *p; +linux_sys_rt_sigprocmask(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_rt_sigprocmask_args /* { @@ -419,9 +421,9 @@ syscallarg(const linux_sigset_t *) set; syscallarg(linux_sigset_t *) oset; syscallarg(size_t) sigsetsize; } */ *uap = v; - + struct proc *p = l->l_proc; linux_sigset_t nlss, olss, *oset; const linux_sigset_t *set; sigset_t nbss, obss; int error, how; @@ -461,17 +463,18 @@ return (error); } int -linux_sys_rt_sigpending(p, v, retval) - struct proc *p; +linux_sys_rt_sigpending(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_rt_sigpending_args /* { syscallarg(linux_sigset_t *) set; syscallarg(size_t) sigsetsize; } */ *uap = v; + struct proc *p = l->l_proc; sigset_t bss; linux_sigset_t lss; if (SCARG(uap, sigsetsize) != sizeof(linux_sigset_t)) @@ -482,16 +485,17 @@ return copyout(&lss, SCARG(uap, set), sizeof(lss)); } int -linux_sys_sigpending(p, v, retval) - struct proc *p; +linux_sys_sigpending(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_sigpending_args /* { syscallarg(linux_old_sigset_t *) mask; } */ *uap = v; + struct proc *p = l->l_proc; sigset_t bss; linux_old_sigset_t lss; sigpending1(p, &bss); @@ -499,35 +503,37 @@ return copyout(&lss, SCARG(uap, set), sizeof(lss)); } int -linux_sys_sigsuspend(p, v, retval) - struct proc *p; +linux_sys_sigsuspend(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_sigsuspend_args /* { syscallarg(caddr_t) restart; syscallarg(int) oldmask; syscallarg(int) mask; } */ *uap = v; + struct proc *p = l->l_proc; linux_old_sigset_t lss; sigset_t bss; lss = SCARG(uap, mask); linux_old_to_native_sigset(&lss, &bss); return (sigsuspend1(p, &bss)); } int -linux_sys_rt_sigsuspend(p, v, retval) - struct proc *p; +linux_sys_rt_sigsuspend(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_rt_sigsuspend_args /* { syscallarg(linux_sigset_t *) unewset; syscallarg(size_t) sigsetsize; } */ *uap = v; + struct proc *p = l->l_proc; linux_sigset_t lss; sigset_t bss; int error; @@ -547,10 +553,10 @@ * Once more: only a signal conversion is needed. * Note: also used as sys_rt_queueinfo. The info field is ignored. */ int -linux_sys_rt_queueinfo(p, v, retval) - struct proc *p; +linux_sys_rt_queueinfo(l, v, retval) + struct lwp *l; void *v; register_t *retval; { /* XXX XAX This isn't this really int, int, siginfo_t *, is it? */ @@ -563,30 +569,31 @@ #endif /* XXX To really implement this we need to */ /* XXX keep a list of queued signals somewhere. */ - return (linux_sys_kill(p, v, retval)); + return (linux_sys_kill(l, v, retval)); } int -linux_sys_kill(p, v, retval) - struct proc *p; +linux_sys_kill(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_kill_args /* { syscallarg(int) pid; syscallarg(int) signum; } */ *uap = v; + struct sys_kill_args ka; int sig; SCARG(&ka, pid) = SCARG(uap, pid); sig = SCARG(uap, signum); if (sig < 0 || sig >= LINUX__NSIG) return (EINVAL); SCARG(&ka, signum) = linux_to_native_sig[sig]; - return sys_kill(p, &ka, retval); + return sys_kill(l, &ka, retval); } #ifdef LINUX_SS_ONSTACK static void linux_to_native_sigaltstack __P((struct sigaltstack *, @@ -624,17 +631,18 @@ lss->ss_flags = 0; } int -linux_sys_sigaltstack(p, v, retval) - struct proc *p; +linux_sys_sigaltstack(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_sigaltstack_args /* { syscallarg(const struct linux_sigaltstack *) ss; syscallarg(struct linux_sigaltstack *) oss; } */ *uap = v; + struct proc *p = l->l_proc; struct linux_sigaltstack ss; struct sigaltstack nss, oss; int error; Index: sys/compat/linux/common/linux_socket.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_socket.c,v retrieving revision 1.29 retrieving revision 1.28.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.29 -r1.28.2.2 --- sys/compat/linux/common/linux_socket.c 2001/03/29 10:37:37 1.29 +++ sys/compat/linux/common/linux_socket.c 2001/04/09 01:55:43 1.28.2.2 @@ -58,8 +58,9 @@ #include #include #include #include +#include #include #include #include #include @@ -128,10 +129,10 @@ } } int -linux_sys_socket(p, v, retval) - struct proc *p; +linux_sys_socket(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_socket_args /* { @@ -145,14 +146,14 @@ SCARG(&bsa, type) = SCARG(uap, type); SCARG(&bsa, domain) = linux_to_bsd_domain(SCARG(uap, domain)); if (SCARG(&bsa, domain) == -1) return EINVAL; - return sys_socket(p, &bsa, retval); + return sys_socket(l, &bsa, retval); } int -linux_sys_socketpair(p, v, retval) - struct proc *p; +linux_sys_socketpair(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_socketpair_args /* { @@ -169,14 +170,14 @@ SCARG(&bsa, type) = SCARG(uap, type); SCARG(&bsa, protocol) = SCARG(uap, protocol); SCARG(&bsa, rsv) = SCARG(uap, rsv); - return sys_socketpair(p, &bsa, retval); + return sys_socketpair(l, &bsa, retval); } int -linux_sys_sendto(p, v, retval) - struct proc *p; +linux_sys_sendto(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_sendto_args /* { @@ -195,14 +196,14 @@ SCARG(&bsa, flags) = SCARG(uap, flags); SCARG(&bsa, to) = (void *) SCARG(uap, to); SCARG(&bsa, tolen) = SCARG(uap, tolen); - return sys_sendto(p, &bsa, retval); + return sys_sendto(l, &bsa, retval); } int -linux_sys_recvfrom(p, v, retval) - struct proc *p; +linux_sys_recvfrom(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_recvfrom_args /* { @@ -221,9 +222,9 @@ SCARG(&bra, flags) = SCARG(uap, flags); SCARG(&bra, from) = (caddr_t) SCARG(uap, from); SCARG(&bra, fromlenaddr) = SCARG(uap, fromlen); - return compat_43_sys_recvfrom(p, &bra, retval); + return compat_43_sys_recvfrom(l, &bra, retval); } /* * Convert socket option level from Linux to NetBSD value. Only SOL_SOCKET @@ -352,10 +353,10 @@ * are not (yet) converted, the ones currently implemented don't * need conversion, as they are the same on both systems. */ int -linux_sys_setsockopt(p, v, retval) - struct proc *p; +linux_sys_setsockopt(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_setsockopt_args /* { @@ -393,17 +394,17 @@ if (name == -1) return EINVAL; SCARG(&bsa, name) = name; - return sys_setsockopt(p, &bsa, retval); + return sys_setsockopt(l, &bsa, retval); } /* * getsockopt(2) is very much the same as setsockopt(2) (see above) */ int -linux_sys_getsockopt(p, v, retval) - struct proc *p; +linux_sys_getsockopt(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_getsockopt_args /* { @@ -441,9 +442,9 @@ if (name == -1) return EINVAL; SCARG(&bga, name) = name; - return sys_getsockopt(p, &bga, retval); + return sys_getsockopt(l, &bga, retval); } #define IF_NAME_LEN 16 @@ -683,17 +684,18 @@ if (error ==0 && dosys) { SCARG(&ia, fd) = SCARG(uap, fd); SCARG(&ia, data) = SCARG(uap, data); - error = sys_ioctl(p, &ia, retval); + /* XXX NJWLWP */ + error = sys_ioctl(curproc, &ia, retval); } return error; } int -linux_sys_connect(p, v, retval) - struct proc *p; +linux_sys_connect(l, v, retval) + struct lwp *l; void *v; register_t *retval; { int error; @@ -702,10 +704,11 @@ syscallarg(int) s; syscallarg(const struct sockaddr *) name; syscallarg(unsigned int) namelen; } */ *uap = v; - - error = sys_connect (p, v, retval); + struct proc *p = l->l_proc; + + error = sys_connect (l, v, retval); if (error == EISCONN) { struct file *fp; struct socket *so; Index: sys/compat/linux/common/linux_socketcall.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_socketcall.c,v retrieving revision 1.19 retrieving revision 1.19.20.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.19 -r1.19.20.1 --- sys/compat/linux/common/linux_socketcall.c 1999/03/25 04:26:45 1.19 +++ sys/compat/linux/common/linux_socketcall.c 2001/03/05 22:49:28 1.19.20.1 @@ -104,10 +104,10 @@ * Entry point to all Linux socket calls. Just check which call to * make and take appropriate action. */ int -linux_sys_socketcall(p, v, retval) - struct proc *p; +linux_sys_socketcall(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_socketcall_args /* { @@ -125,41 +125,41 @@ return error; switch (SCARG(uap, what)) { case LINUX_SYS_socket: - return linux_sys_socket(p, (void *)&lda, retval); + return linux_sys_socket(l, (void *)&lda, retval); case LINUX_SYS_bind: - return sys_bind(p, (void *)&lda, retval); + return sys_bind(l, (void *)&lda, retval); case LINUX_SYS_connect: - return linux_sys_connect(p, (void *)&lda, retval); + return linux_sys_connect(l, (void *)&lda, retval); case LINUX_SYS_listen: - return sys_listen(p, (void *)&lda, retval); + return sys_listen(l, (void *)&lda, retval); case LINUX_SYS_accept: - return compat_43_sys_accept(p, (void *)&lda, retval); + return compat_43_sys_accept(l, (void *)&lda, retval); case LINUX_SYS_getsockname: - return compat_43_sys_getsockname(p, (void *)&lda, retval); + return compat_43_sys_getsockname(l, (void *)&lda, retval); case LINUX_SYS_getpeername: - return compat_43_sys_getpeername(p, (void *)&lda, retval); + return compat_43_sys_getpeername(l, (void *)&lda, retval); case LINUX_SYS_socketpair: - return linux_sys_socketpair(p, (void *)&lda, retval); + return linux_sys_socketpair(l, (void *)&lda, retval); case LINUX_SYS_send: - return compat_43_sys_send(p, (void *)&lda, retval); + return compat_43_sys_send(l, (void *)&lda, retval); case LINUX_SYS_recv: - return compat_43_sys_recv(p, (void *)&lda, retval); + return compat_43_sys_recv(l, (void *)&lda, retval); case LINUX_SYS_sendto: - return linux_sys_sendto(p, (void *)&lda, retval); + return linux_sys_sendto(l, (void *)&lda, retval); case LINUX_SYS_recvfrom: - return linux_sys_recvfrom(p, (void *)&lda, retval); + return linux_sys_recvfrom(l, (void *)&lda, retval); case LINUX_SYS_shutdown: - return sys_shutdown(p, (void *)&lda, retval); + return sys_shutdown(l, (void *)&lda, retval); case LINUX_SYS_setsockopt: - return linux_sys_setsockopt(p, (void *)&lda, retval); + return linux_sys_setsockopt(l, (void *)&lda, retval); case LINUX_SYS_getsockopt: - return linux_sys_getsockopt(p, (void *)&lda, retval); + return linux_sys_getsockopt(l, (void *)&lda, retval); case LINUX_SYS_sendmsg: - return sys_sendmsg(p, (void *)&lda, retval); + return sys_sendmsg(l, (void *)&lda, retval); case LINUX_SYS_recvmsg: - return sys_recvmsg(p, (void *)&lda, retval); + return sys_recvmsg(l, (void *)&lda, retval); default: return ENOSYS; } } Index: sys/compat/linux/common/linux_socketcall.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_socketcall.h,v retrieving revision 1.5 retrieving revision 1.5.20.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.5 -r1.5.20.1 --- sys/compat/linux/common/linux_socketcall.h 1999/03/25 04:26:45 1.5 +++ sys/compat/linux/common/linux_socketcall.h 2001/03/05 22:49:28 1.5.20.1 @@ -228,15 +228,15 @@ }; # ifdef _KERNEL __BEGIN_DECLS -int linux_sys_socket __P((struct proc *, void *, register_t *)); -int linux_sys_socketpair __P((struct proc *, void *, register_t *)); -int linux_sys_sendto __P((struct proc *, void *, register_t *)); -int linux_sys_recvfrom __P((struct proc *, void *, register_t *)); -int linux_sys_setsockopt __P((struct proc *, void *, register_t *)); -int linux_sys_getsockopt __P((struct proc *, void *, register_t *)); -int linux_sys_connect __P((struct proc *, void *, register_t *)); +int linux_sys_socket __P((struct lwp *, void *, register_t *)); +int linux_sys_socketpair __P((struct lwp *, void *, register_t *)); +int linux_sys_sendto __P((struct lwp *, void *, register_t *)); +int linux_sys_recvfrom __P((struct lwp *, void *, register_t *)); +int linux_sys_setsockopt __P((struct lwp *, void *, register_t *)); +int linux_sys_getsockopt __P((struct lwp *, void *, register_t *)); +int linux_sys_connect __P((struct lwp *, void *, register_t *)); __END_DECLS # endif /* !_KERNEL */ # endif Index: sys/compat/linux/common/linux_termios.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_termios.c,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.11 -r1.11.2.1 --- sys/compat/linux/common/linux_termios.c 2001/02/21 21:39:57 1.11 +++ sys/compat/linux/common/linux_termios.c 2001/03/05 22:49:28 1.11.2.1 @@ -690,6 +690,7 @@ } SCARG(&ia, fd) = SCARG(uap, fd); SCARG(&ia, data) = SCARG(uap, data); - return sys_ioctl(p, &ia, retval); + /* XXX NJWLWP */ + return sys_ioctl(curproc, &ia, retval); } Index: sys/compat/linux/common/linux_uselib.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/linux/common/linux_uselib.c,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.2 -r1.2.2.1 --- sys/compat/linux/common/linux_uselib.c 2000/12/12 17:52:56 1.2 +++ sys/compat/linux/common/linux_uselib.c 2001/03/05 22:49:29 1.2.2.1 @@ -84,16 +84,17 @@ * shared libs are not handled very efficiently :-( */ int -linux_sys_uselib(p, v, retval) - struct proc *p; +linux_sys_uselib(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct linux_sys_uselib_args /* { syscallarg(const char *) path; } */ *uap = v; + struct proc *p = l->l_proc; caddr_t sg; long bsize, dsize, tsize, taddr, baddr, daddr; struct nameidata ni; struct vnode *vp; Index: sys/compat/svr4/svr4_exec.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_exec.h,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.17 -r1.17.2.1 --- sys/compat/svr4/svr4_exec.h 2001/02/21 23:53:01 1.17 +++ sys/compat/svr4/svr4_exec.h 2001/03/05 22:49:29 1.17.2.1 @@ -86,9 +86,9 @@ #endif extern const struct emul emul_svr4; -void svr4_setregs __P((struct proc *, struct exec_package *, u_long)); +void svr4_setregs __P((struct lwp *, struct exec_package *, u_long)); int svr4_elf32_probe __P((struct proc *, struct exec_package *, void *, char *, vaddr_t *)); int svr4_elf64_probe __P((struct proc *, struct exec_package *, void *, char *, vaddr_t *)); Index: sys/compat/svr4/svr4_fcntl.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_fcntl.c,v retrieving revision 1.36 retrieving revision 1.36.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.36 -r1.36.2.1 --- sys/compat/svr4/svr4_fcntl.c 2000/12/01 12:28:36 1.36 +++ sys/compat/svr4/svr4_fcntl.c 2001/03/05 22:49:29 1.36.2.1 @@ -65,10 +65,10 @@ static void bsd_to_svr4_flock __P((struct flock *, struct svr4_flock *)); static void svr4_to_bsd_flock __P((struct svr4_flock *, struct flock *)); static void bsd_to_svr4_flock64 __P((struct flock *, struct svr4_flock64 *)); static void svr4_to_bsd_flock64 __P((struct svr4_flock64 *, struct flock *)); -static int fd_revoke __P((struct proc *, int, register_t *)); -static int fd_truncate __P((struct proc *, int, struct flock *, register_t *)); +static int fd_revoke __P((struct lwp *, int, register_t *)); +static int fd_truncate __P((struct lwp *, int, struct flock *, register_t *)); static u_long svr4_to_bsd_cmd(cmd) u_long cmd; @@ -253,13 +253,14 @@ } static int -fd_revoke(p, fd, retval) - struct proc *p; +fd_revoke(l, fd, retval) + struct lwp *l; int fd; register_t *retval; { + struct proc *p = l->l_proc; struct filedesc *fdp = p->p_fd; struct file *fp; struct vnode *vp; struct vattr vattr; @@ -300,14 +301,15 @@ } static int -fd_truncate(p, fd, flp, retval) - struct proc *p; +fd_truncate(l, fd, flp, retval) + struct lwp *l; int fd; struct flock *flp; register_t *retval; { + struct proc *p = l->l_proc; struct filedesc *fdp = p->p_fd; struct file *fp; off_t start, length; struct vnode *vp; @@ -354,19 +356,20 @@ SCARG(&ft, fd) = fd; SCARG(&ft, length) = start; - return sys_ftruncate(p, &ft, retval); + return sys_ftruncate(l, &ft, retval); } int -svr4_sys_open(p, v, retval) - struct proc *p; +svr4_sys_open(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_open_args *uap = v; + struct proc *p = l->l_proc; int error; struct sys_open_args cup; caddr_t sg = stackgap_init(p->p_emul); @@ -379,9 +382,9 @@ CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, mode) = SCARG(uap, mode); - error = sys_open(p, &cup, retval); + error = sys_open(l, &cup, retval); if (error) return error; @@ -398,50 +401,50 @@ } int -svr4_sys_open64(p, v, retval) - struct proc *p; +svr4_sys_open64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { - return svr4_sys_open(p, v, retval); + return svr4_sys_open(l, v, retval); } int -svr4_sys_creat(p, v, retval) - struct proc *p; +svr4_sys_creat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_creat_args *uap = v; struct sys_open_args cup; - caddr_t sg = stackgap_init(p->p_emul); - CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + caddr_t sg = stackgap_init(l->l_proc->p_emul); + CHECK_ALT_EXIST(l->l_proc, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, mode) = SCARG(uap, mode); SCARG(&cup, flags) = O_WRONLY | O_CREAT | O_TRUNC; - return sys_open(p, &cup, retval); + return sys_open(l, &cup, retval); } int -svr4_sys_creat64(p, v, retval) - struct proc *p; +svr4_sys_creat64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { - return svr4_sys_creat(p, v, retval); + return svr4_sys_creat(l, v, retval); } int -svr4_sys_llseek(p, v, retval) - struct proc *p; +svr4_sys_llseek(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_llseek_args *uap = v; @@ -457,33 +460,33 @@ SCARG(uap, offset1); #endif SCARG(&ap, whence) = SCARG(uap, whence); - return sys_lseek(p, &ap, retval); + return sys_lseek(l, &ap, retval); } int -svr4_sys_access(p, v, retval) - struct proc *p; +svr4_sys_access(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_access_args *uap = v; struct sys_access_args cup; - caddr_t sg = stackgap_init(p->p_emul); - CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + caddr_t sg = stackgap_init(l->l_proc->p_emul); + CHECK_ALT_EXIST(l->l_proc, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, flags) = SCARG(uap, flags); - return sys_access(p, &cup, retval); + return sys_access(l, &cup, retval); } int -svr4_sys_pread(p, v, retval) - struct proc *p; +svr4_sys_pread(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_pread_args *uap = v; @@ -497,15 +500,15 @@ SCARG(&pra, buf) = SCARG(uap, buf); SCARG(&pra, nbyte) = SCARG(uap, nbyte); SCARG(&pra, offset) = SCARG(uap, off); - return (sys_pread(p, &pra, retval)); + return (sys_pread(l, &pra, retval)); } int -svr4_sys_pread64(p, v, retval) - struct proc *p; +svr4_sys_pread64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -520,15 +523,15 @@ SCARG(&pra, buf) = SCARG(uap, buf); SCARG(&pra, nbyte) = SCARG(uap, nbyte); SCARG(&pra, offset) = SCARG(uap, off); - return (sys_pread(p, &pra, retval)); + return (sys_pread(l, &pra, retval)); } int -svr4_sys_pwrite(p, v, retval) - struct proc *p; +svr4_sys_pwrite(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_pwrite_args *uap = v; @@ -542,15 +545,15 @@ SCARG(&pwa, buf) = SCARG(uap, buf); SCARG(&pwa, nbyte) = SCARG(uap, nbyte); SCARG(&pwa, offset) = SCARG(uap, off); - return (sys_pwrite(p, &pwa, retval)); + return (sys_pwrite(l, &pwa, retval)); } int -svr4_sys_pwrite64(p, v, retval) - struct proc *p; +svr4_sys_pwrite64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_pwrite64_args *uap = v; @@ -564,15 +567,15 @@ SCARG(&pwa, buf) = SCARG(uap, buf); SCARG(&pwa, nbyte) = SCARG(uap, nbyte); SCARG(&pwa, offset) = SCARG(uap, off); - return (sys_pwrite(p, &pwa, retval)); + return (sys_pwrite(l, &pwa, retval)); } int -svr4_sys_fcntl(p, v, retval) - struct proc *p; +svr4_sys_fcntl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_fcntl_args *uap = v; @@ -586,13 +589,13 @@ case F_DUPFD: case F_GETFD: case F_SETFD: SCARG(&fa, arg) = SCARG(uap, arg); - return sys_fcntl(p, &fa, retval); + return sys_fcntl(l, &fa, retval); case F_GETFL: SCARG(&fa, arg) = SCARG(uap, arg); - error = sys_fcntl(p, &fa, retval); + error = sys_fcntl(l, &fa, retval); if (error) return error; *retval = bsd_to_svr4_flags(*retval); return error; @@ -608,24 +611,24 @@ cmd = SCARG(&fa, cmd); /* save it for a while */ SCARG(&fa, cmd) = F_GETFL; - if ((error = sys_fcntl(p, &fa, &flags)) != 0) + if ((error = sys_fcntl(l, &fa, &flags)) != 0) return error; flags &= O_ASYNC; flags |= svr4_to_bsd_flags((u_long) SCARG(uap, arg)); SCARG(&fa, cmd) = cmd; SCARG(&fa, arg) = (void *) flags; - return sys_fcntl(p, &fa, retval); + return sys_fcntl(l, &fa, retval); } case F_GETLK: case F_SETLK: case F_SETLKW: { struct svr4_flock ifl; struct flock *flp, fl; - caddr_t sg = stackgap_init(p->p_emul); + caddr_t sg = stackgap_init(l->l_proc->p_emul); flp = stackgap_alloc(&sg, sizeof(struct flock)); SCARG(&fa, arg) = (void *) flp; @@ -638,9 +641,9 @@ error = copyout(&fl, flp, sizeof fl); if (error) return error; - error = sys_fcntl(p, &fa, retval); + error = sys_fcntl(l, &fa, retval); if (error || SCARG(&fa, cmd) != F_GETLK) return error; error = copyin(flp, &fl, sizeof fl); @@ -658,9 +661,9 @@ struct sys_dup2_args du; SCARG(&du, from) = SCARG(uap, fd); SCARG(&du, to) = (int)(u_long)SCARG(uap, arg); - error = sys_dup2(p, &du, retval); + error = sys_dup2(l, &du, retval); if (error) return error; *retval = SCARG(&du, to); return 0; @@ -675,9 +678,9 @@ sizeof ifl); if (error) return error; svr4_to_bsd_flock(&ifl, &fl); - return fd_truncate(p, SCARG(uap, fd), &fl, + return fd_truncate(l, SCARG(uap, fd), &fl, retval); } case SVR4_F_GETLK64: @@ -685,9 +688,9 @@ case SVR4_F_SETLKW64: { struct svr4_flock64 ifl; struct flock *flp, fl; - caddr_t sg = stackgap_init(p->p_emul); + caddr_t sg = stackgap_init(l->l_proc->p_emul); flp = stackgap_alloc(&sg, sizeof(struct flock)); SCARG(&fa, arg) = (void *) flp; @@ -701,9 +704,9 @@ error = copyout(&fl, flp, sizeof fl); if (error) return error; - error = sys_fcntl(p, &fa, retval); + error = sys_fcntl(l, &fa, retval); if (error || SCARG(&fa, cmd) != F_GETLK) return error; error = copyin(flp, &fl, sizeof fl); @@ -725,14 +728,14 @@ sizeof ifl); if (error) return error; svr4_to_bsd_flock64(&ifl, &fl); - return fd_truncate(p, SCARG(uap, fd), &fl, + return fd_truncate(l, SCARG(uap, fd), &fl, retval); } case SVR4_F_REVOKE: - return fd_revoke(p, SCARG(uap, fd), retval); + return fd_revoke(l, SCARG(uap, fd), retval); default: return ENOSYS; } Index: sys/compat/svr4/svr4_ioctl.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_ioctl.c,v retrieving revision 1.20 retrieving revision 1.20.6.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.20 -r1.20.6.1 --- sys/compat/svr4/svr4_ioctl.c 2000/03/30 11:27:20 1.20 +++ sys/compat/svr4/svr4_ioctl.c 2001/03/05 22:49:29 1.20.6.1 @@ -36,8 +36,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +#include #include #include #include #include @@ -93,14 +94,15 @@ } #endif int -svr4_sys_ioctl(p, v, retval) - struct proc *p; +svr4_sys_ioctl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_ioctl_args *uap = v; + struct proc *p = l->l_proc; struct file *fp; struct filedesc *fdp; u_long cmd; int (*fun) __P((struct file *, struct proc *, register_t *, Index: sys/compat/svr4/svr4_ipc.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_ipc.c,v retrieving revision 1.10 retrieving revision 1.10.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.10 -r1.10.2.1 --- sys/compat/svr4/svr4_ipc.c 2000/11/29 22:05:37 1.10 +++ sys/compat/svr4/svr4_ipc.c 2001/03/05 22:49:29 1.10.2.1 @@ -45,8 +45,9 @@ #include #include #include #include +#include #include #include #include #include @@ -76,33 +77,33 @@ static void bsd_to_svr4_semid_ds __P((const struct semid_ds *, struct svr4_semid_ds *)); static void svr4_to_bsd_semid_ds __P((const struct svr4_semid_ds *, struct semid_ds *)); -static int svr4_semop __P((struct proc *, void *, register_t *)); -static int svr4_semget __P((struct proc *, void *, register_t *)); -static int svr4_semctl __P((struct proc *, void *, register_t *)); +static int svr4_semop __P((struct lwp *, void *, register_t *)); +static int svr4_semget __P((struct lwp *, void *, register_t *)); +static int svr4_semctl __P((struct lwp *, void *, register_t *)); #endif #ifdef SYSVMSG static void bsd_to_svr4_msqid_ds __P((const struct msqid_ds *, struct svr4_msqid_ds *)); static void svr4_to_bsd_msqid_ds __P((const struct svr4_msqid_ds *, struct msqid_ds *)); -static int svr4_msgsnd __P((struct proc *, void *, register_t *)); -static int svr4_msgrcv __P((struct proc *, void *, register_t *)); -static int svr4_msgget __P((struct proc *, void *, register_t *)); -static int svr4_msgctl __P((struct proc *, void *, register_t *)); +static int svr4_msgsnd __P((struct lwp *, void *, register_t *)); +static int svr4_msgrcv __P((struct lwp *, void *, register_t *)); +static int svr4_msgget __P((struct lwp *, void *, register_t *)); +static int svr4_msgctl __P((struct lwp *, void *, register_t *)); #endif #ifdef SYSVSHM static void bsd_to_svr4_shmid_ds __P((const struct shmid_ds *, struct svr4_shmid_ds *)); static void svr4_to_bsd_shmid_ds __P((const struct svr4_shmid_ds *, struct shmid_ds *)); -static int svr4_shmat __P((struct proc *, void *, register_t *)); -static int svr4_shmdt __P((struct proc *, void *, register_t *)); -static int svr4_shmget __P((struct proc *, void *, register_t *)); -static int svr4_shmctl __P((struct proc *, void *, register_t *)); +static int svr4_shmat __P((struct lwp *, void *, register_t *)); +static int svr4_shmdt __P((struct lwp *, void *, register_t *)); +static int svr4_shmget __P((struct lwp *, void *, register_t *)); +static int svr4_shmctl __P((struct lwp *, void *, register_t *)); #endif #if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM) @@ -168,10 +169,10 @@ syscallarg(union __semun) arg; }; static int -svr4_semctl(p, v, retval) - struct proc *p; +svr4_semctl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_semctl_args *uap = v; @@ -238,9 +239,9 @@ return (error); svr4_to_bsd_semid_ds(&ssembuf, &sembuf); } - error = semctl1(p, SCARG(uap, semid), SCARG(uap, semnum), cmd, + error = semctl1(l->l_proc, SCARG(uap, semid), SCARG(uap, semnum), cmd, pass_arg, retval); if (error == 0 && cmd == IPC_STAT) { bsd_to_svr4_semid_ds(&sembuf, &ssembuf); @@ -257,10 +258,10 @@ syscallarg(int) semflg; }; static int -svr4_semget(p, v, retval) - struct proc *p; +svr4_semget(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_semget_args *uap = v; @@ -269,9 +270,9 @@ SCARG(&ap, key) = SCARG(uap, key); SCARG(&ap, nsems) = SCARG(uap, nsems); SCARG(&ap, semflg) = SCARG(uap, semflg); - return sys_semget(p, &ap, retval); + return sys_semget(l, &ap, retval); } struct svr4_sys_semop_args { syscallarg(int) what; @@ -280,10 +281,10 @@ syscallarg(u_int) nsops; }; static int -svr4_semop(p, v, retval) - struct proc *p; +svr4_semop(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_semop_args *uap = v; @@ -293,14 +294,14 @@ /* These are the same */ SCARG(&ap, sops) = (struct sembuf *) SCARG(uap, sops); SCARG(&ap, nsops) = SCARG(uap, nsops); - return sys_semop(p, &ap, retval); + return sys_semop(l, &ap, retval); } int -svr4_sys_semsys(p, v, retval) - struct proc *p; +svr4_sys_semsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_semsys_args *uap = v; @@ -308,13 +309,13 @@ DPRINTF(("svr4_semsys(%d)\n", SCARG(uap, what))); switch (SCARG(uap, what)) { case SVR4_semctl: - return svr4_semctl(p, v, retval); + return svr4_semctl(l, v, retval); case SVR4_semget: - return svr4_semget(p, v, retval); + return svr4_semget(l, v, retval); case SVR4_semop: - return svr4_semop(p, v, retval); + return svr4_semop(l, v, retval); default: return EINVAL; } } @@ -376,10 +377,10 @@ syscallarg(int) msgflg; }; static int -svr4_msgsnd(p, v, retval) - struct proc *p; +svr4_msgsnd(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_msgsnd_args *uap = v; @@ -389,9 +390,9 @@ SCARG(&ap, msgp) = SCARG(uap, msgp); SCARG(&ap, msgsz) = SCARG(uap, msgsz); SCARG(&ap, msgflg) = SCARG(uap, msgflg); - return sys_msgsnd(p, &ap, retval); + return sys_msgsnd(l, &ap, retval); } struct svr4_sys_msgrcv_args { syscallarg(int) what; @@ -402,10 +403,10 @@ syscallarg(int) msgflg; }; static int -svr4_msgrcv(p, v, retval) - struct proc *p; +svr4_msgrcv(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_msgrcv_args *uap = v; @@ -416,9 +417,9 @@ SCARG(&ap, msgsz) = SCARG(uap, msgsz); SCARG(&ap, msgtyp) = SCARG(uap, msgtyp); SCARG(&ap, msgflg) = SCARG(uap, msgflg); - return sys_msgrcv(p, &ap, retval); + return sys_msgrcv(l, &ap, retval); } struct svr4_sys_msgget_args { syscallarg(int) what; @@ -426,10 +427,10 @@ syscallarg(int) msgflg; }; static int -svr4_msgget(p, v, retval) - struct proc *p; +svr4_msgget(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_msgget_args *uap = v; @@ -437,9 +438,9 @@ SCARG(&ap, key) = SCARG(uap, key); SCARG(&ap, msgflg) = SCARG(uap, msgflg); - return sys_msgget(p, &ap, retval); + return sys_msgget(l, &ap, retval); } struct svr4_sys_msgctl_args { syscallarg(int) what; @@ -448,28 +449,28 @@ syscallarg(struct svr4_msqid_ds *) buf; }; static int -svr4_msgctl(p, v, retval) - struct proc *p; +svr4_msgctl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { int error; struct svr4_sys_msgctl_args *uap = v; struct sys___msgctl13_args ap; struct svr4_msqid_ds ss; struct msqid_ds bs; - caddr_t sg = stackgap_init(p->p_emul); + caddr_t sg = stackgap_init(l->l_proc->p_emul); SCARG(&ap, msqid) = SCARG(uap, msqid); SCARG(&ap, cmd) = SCARG(uap, cmd); SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof(bs)); switch (SCARG(uap, cmd)) { case SVR4_IPC_STAT: SCARG(&ap, cmd) = IPC_STAT; - if ((error = sys___msgctl13(p, &ap, retval)) != 0) + if ((error = sys___msgctl13(l, &ap, retval)) != 0) return error; error = copyin(&bs, SCARG(&ap, buf), sizeof bs); if (error) return error; @@ -484,9 +485,9 @@ svr4_to_bsd_msqid_ds(&ss, &bs); error = copyout(&bs, SCARG(&ap, buf), sizeof bs); if (error) return error; - return sys___msgctl13(p, &ap, retval); + return sys___msgctl13(l, &ap, retval); case SVR4_IPC_RMID: SCARG(&ap, cmd) = IPC_RMID; error = copyin(SCARG(uap, buf), &ss, sizeof ss); @@ -495,18 +496,18 @@ svr4_to_bsd_msqid_ds(&ss, &bs); error = copyout(&bs, SCARG(&ap, buf), sizeof bs); if (error) return error; - return sys___msgctl13(p, &ap, retval); + return sys___msgctl13(l, &ap, retval); default: return EINVAL; } } int -svr4_sys_msgsys(p, v, retval) - struct proc *p; +svr4_sys_msgsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_msgsys_args *uap = v; @@ -514,15 +515,15 @@ DPRINTF(("svr4_msgsys(%d)\n", SCARG(uap, what))); switch (SCARG(uap, what)) { case SVR4_msgsnd: - return svr4_msgsnd(p, v, retval); + return svr4_msgsnd(l, v, retval); case SVR4_msgrcv: - return svr4_msgrcv(p, v, retval); + return svr4_msgrcv(l, v, retval); case SVR4_msgget: - return svr4_msgget(p, v, retval); + return svr4_msgget(l, v, retval); case SVR4_msgctl: - return svr4_msgctl(p, v, retval); + return svr4_msgctl(l, v, retval); default: return EINVAL; } } @@ -574,10 +575,10 @@ syscallarg(int) shmflg; }; static int -svr4_shmat(p, v, retval) - struct proc *p; +svr4_shmat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_shmat_args *uap = v; @@ -586,28 +587,28 @@ SCARG(&ap, shmid) = SCARG(uap, shmid); SCARG(&ap, shmaddr) = SCARG(uap, shmaddr); SCARG(&ap, shmflg) = SCARG(uap, shmflg); - return sys_shmat(p, &ap, retval); + return sys_shmat(l, &ap, retval); } struct svr4_sys_shmdt_args { syscallarg(int) what; syscallarg(void *) shmaddr; }; static int -svr4_shmdt(p, v, retval) - struct proc *p; +svr4_shmdt(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_shmdt_args *uap = v; struct sys_shmdt_args ap; SCARG(&ap, shmaddr) = SCARG(uap, shmaddr); - return sys_shmdt(p, &ap, retval); + return sys_shmdt(l, &ap, retval); } struct svr4_sys_shmget_args { syscallarg(int) what; @@ -616,10 +617,10 @@ syscallarg(int) shmflg; }; static int -svr4_shmget(p, v, retval) - struct proc *p; +svr4_shmget(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_shmget_args *uap = v; @@ -628,9 +629,9 @@ SCARG(&ap, key) = SCARG(uap, key); SCARG(&ap, size) = SCARG(uap, size); SCARG(&ap, shmflg) = SCARG(uap, shmflg); - return sys_shmget(p, &ap, retval); + return sys_shmget(l, &ap, retval); } struct svr4_sys_shmctl_args { syscallarg(int) what; @@ -639,16 +640,16 @@ syscallarg(struct svr4_shmid_ds *) buf; }; int -svr4_shmctl(p, v, retval) - struct proc *p; +svr4_shmctl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_shmctl_args *uap = v; int error; - caddr_t sg = stackgap_init(p->p_emul); + caddr_t sg = stackgap_init(l->l_proc->p_emul); struct sys___shmctl13_args ap; struct shmid_ds bs; struct svr4_shmid_ds ss; @@ -680,9 +681,9 @@ switch (SCARG(uap, cmd)) { case SVR4_IPC_STAT: SCARG(&ap, cmd) = IPC_STAT; - if ((error = sys___shmctl13(p, &ap, retval)) != 0) + if ((error = sys___shmctl13(l, &ap, retval)) != 0) return error; if (SCARG(uap, buf) == NULL) return 0; error = copyin(&bs, SCARG(&ap, buf), sizeof bs); @@ -692,9 +693,9 @@ return copyout(&ss, SCARG(uap, buf), sizeof ss); case SVR4_IPC_SET: SCARG(&ap, cmd) = IPC_SET; - return sys___shmctl13(p, &ap, retval); + return sys___shmctl13(l, &ap, retval); case SVR4_IPC_RMID: case SVR4_SHM_LOCK: case SVR4_SHM_UNLOCK: @@ -710,18 +711,18 @@ break; default: return EINVAL; } - return sys___shmctl13(p, &ap, retval); + return sys___shmctl13(l, &ap, retval); default: return EINVAL; } } int -svr4_sys_shmsys(p, v, retval) - struct proc *p; +svr4_sys_shmsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_shmsys_args *uap = v; @@ -729,15 +730,15 @@ DPRINTF(("svr4_shmsys(%d)\n", SCARG(uap, what))); switch (SCARG(uap, what)) { case SVR4_shmat: - return svr4_shmat(p, v, retval); + return svr4_shmat(l, v, retval); case SVR4_shmdt: - return svr4_shmdt(p, v, retval); + return svr4_shmdt(l, v, retval); case SVR4_shmget: - return svr4_shmget(p, v, retval); + return svr4_shmget(l, v, retval); case SVR4_shmctl: - return svr4_shmctl(p, v, retval); + return svr4_shmctl(l, v, retval); default: return ENOSYS; } } Index: sys/compat/svr4/svr4_lwp.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_lwp.c,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.5 -r1.5.2.1 --- sys/compat/svr4/svr4_lwp.c 2000/09/05 16:20:28 1.5 +++ sys/compat/svr4/svr4_lwp.c 2001/03/05 22:49:29 1.5.2.1 @@ -44,8 +44,9 @@ #include #include #include #include +#include #include #include #include #include @@ -63,220 +64,160 @@ #include int -svr4_sys__lwp_self(p, v, retval) - struct proc *p; +svr4_sys__lwp_self(l, v, retval) + struct lwp *l; void *v; register_t *retval; { - return sys_getpid(p, v, retval); + return sys__lwp_self(l, v, retval); } int -svr4_sys__lwp_create(p, v, retval) - struct proc *p; +svr4_sys__lwp_create(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys__lwp_create_args *uap = v; - int error; - struct proc *pt; - svr4_ucontext_t uc; -#define SVR4_FORK_FLAGS \ - (FORK_SHAREVM|FORK_SHARECWD|FORK_SHAREFILES|FORK_SHARESIGS) - - - if ((error = fork1(p, SVR4_FORK_FLAGS, SIGCHLD, NULL, 0, - NULL, NULL, retval, &pt)) == -1) - return error; - + struct sys__lwp_create_args lc; + int flags; + + flags = 0; + if (SCARG(uap, flags) & SVR4_LWP_DETACHED) - pt->p_flag &= ~P_CONTROLT; - + flags &= LWP_DETACHED; + if (SCARG(uap, flags) & SVR4_LWP_SUSPENDED) - pt->p_stat = SSTOP; + flags &= LWP_SUSPENDED; if (SCARG(uap, flags) & SVR4___LWP_ASLWP) { - /* - * XXX: This does not really work, we don't have - * the facility to deliver all async signals - * to a single lwp, and also we don't keep - * track of having only one ASLWP. For now - * we just block all signals as we are supposed - * to. - */ - sigset_t ss; - sigfillset(&ss); - (void)sigprocmask1(pt, SIG_BLOCK, &ss, 0); - } else { - /* - * XXX: We block all signals to the rest of the of - * the lwp's, so that they don't get confused - * as of the above. Will that work? What does - * sharing s - */ - sigset_t ss; - sigfillset(&ss); - (void)sigprocmask1(pt, SIG_BLOCK, &ss, 0); + /* XXX Punt! */ } - if ((error = copyin(SCARG(uap, uc), &uc, sizeof(uc))) != 0) - return error; - if ((error = svr4_setcontext(pt, &uc)) != 0) - return error; + /* XXX At the moment, svr4_ucontext_t and ucontext_t are the same */ + SCARG(&lc, ucp) = (ucontext_t *)SCARG(uap, uc); + SCARG(&lc, flags) = flags; + SCARG(&lc, new_lwp) = SCARG(uap, lwpid); + - if ((error = copyout(&pt->p_pid, SCARG(uap, lwpid), - sizeof(svr4_lwpid_t))) == -1) - return error; - return 0; + return sys__lwp_create(l, &lc, retval); } int -svr4_sys__lwp_kill(p, v, retval) - struct proc *p; +svr4_sys__lwp_kill(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys__lwp_kill_args *uap = v; struct sys_kill_args ap; SCARG(&ap, pid) = SCARG(uap, lwpid); SCARG(&ap, signum) = SCARG(uap, signum); - return sys_kill(p, &ap, retval); + /* XXX NJWLWP */ + return sys_kill(l, &ap, retval); } int -svr4_sys__lwp_info(p, v, retval) - struct proc *p; +svr4_sys__lwp_info(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys__lwp_info_args *uap = v; struct svr4_lwpinfo lwpinfo; int error; - TIMEVAL_TO_TIMESPEC(&p->p_stats->p_ru.ru_stime, &lwpinfo.lwp_stime); - TIMEVAL_TO_TIMESPEC(&p->p_stats->p_ru.ru_utime, &lwpinfo.lwp_utime); + /* XXX NJWLWP */ + TIMEVAL_TO_TIMESPEC(&l->l_proc->p_stats->p_ru.ru_stime, &lwpinfo.lwp_stime); + TIMEVAL_TO_TIMESPEC(&l->l_proc->p_stats->p_ru.ru_utime, &lwpinfo.lwp_utime); if ((error = copyout(&lwpinfo, SCARG(uap, lwpinfo), sizeof(lwpinfo))) == -1) return error; return 0; } int -svr4_sys__lwp_exit(p, v, retval) - struct proc *p; +svr4_sys__lwp_exit(l, v, retval) + struct lwp *l; void *v; register_t *retval; { - struct sys_exit_args ap; - int error; - - /* XXX: We don't handle the suspended case correctly here */ - SCARG(&ap, rval) = 0; - if ((error = sys_exit(p, &ap, retval)) == -1) - return error; - - *retval = 0; - return 0; + return sys__lwp_exit(l, NULL, retval); } int -svr4_sys__lwp_wait(p, v, retval) - struct proc *p; +svr4_sys__lwp_wait(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys__lwp_wait_args *uap = v; - struct sys_wait4_args ap; - int error; + struct sys__lwp_wait_args ap; - SCARG(&ap, pid) = SCARG(uap, wait_for); - SCARG(&ap, status) = NULL; - SCARG(&ap, options) = 0; - - if ((error = sys_wait4(p, &ap, retval)) == -1) - return error; - - if (SCARG(uap, departed_lwp) != NULL) - if ((error = copyout(retval, SCARG(uap, departed_lwp), - sizeof(svr4_lwpid_t))) == -1) - return error; + SCARG(&ap, wait_for) = SCARG(uap, wait_for); + SCARG(&ap, departed) = SCARG(uap, departed_lwp); - *retval = 0; - return 0; + return sys__lwp_wait(l, &ap, retval); } -/* XXX Stolen from kern_sig.c */ -#define CANSIGNAL(p, pc, q, signum) \ - ((pc)->pc_ucred->cr_uid == 0 || \ - (pc)->p_ruid == (q)->p_cred->p_ruid || \ - (pc)->pc_ucred->cr_uid == (q)->p_cred->p_ruid || \ - (pc)->p_ruid == (q)->p_ucred->cr_uid || \ - (pc)->pc_ucred->cr_uid == (q)->p_ucred->cr_uid || \ - ((signum) == SIGCONT && (q)->p_session == (p)->p_session)) int -svr4_sys__lwp_suspend(p, v, retval) - struct proc *p; +svr4_sys__lwp_suspend(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys__lwp_suspend_args *uap = v; - struct proc *pt; - - /* Security implications here! */ - if ((pt = pfind(SCARG(uap, lwpid))) == NULL) - return ESRCH; + struct sys__lwp_suspend_args ap; - if (!CANSIGNAL(p, p->p_cred, pt, 0)) - return EPERM; + SCARG(&ap, target) = SCARG(uap, lwpid); - pt->p_stat = SSTOP; - return 0; + return sys__lwp_suspend(l, &ap, retval); } + int -svr4_sys__lwp_continue(p, v, retval) - struct proc *p; +svr4_sys__lwp_continue(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys__lwp_continue_args *uap = v; - struct proc *pt; + struct sys__lwp_continue_args ap; - if ((pt = pfind(SCARG(uap, lwpid))) == NULL) - return ESRCH; + SCARG(&ap, target) = SCARG(uap, lwpid); - if (!CANSIGNAL(p, p->p_cred, pt, 0)) - return EPERM; - - pt->p_stat = SRUN; - return 0; + return sys__lwp_continue(l, &ap, retval); } int -svr4_sys__lwp_getprivate(p, v, retval) - struct proc *p; +svr4_sys__lwp_getprivate(l, v, retval) + struct lwp *l; void *v; register_t *retval; { - /* XXX: Use mach field! */ - *retval = (register_t)p->p_thread; + /* XXX NJWLWP: Replace with call to native version if we ever + * implement that. */ + + *retval = (register_t)l->l_private; return 0; } int -svr4_sys__lwp_setprivate(p, v, retval) - struct proc *p; +svr4_sys__lwp_setprivate(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys__lwp_setprivate_args *uap = v; + + /* XXX NJWLWP: Replace with call to native version if we ever + * implement that. */ - /* XXX: Use mach field! */ - return copyin(SCARG(uap, buffer), &p->p_thread, sizeof(void *)); + return copyin(SCARG(uap, buffer), &l->l_private, sizeof(void *)); return 0; } Index: sys/compat/svr4/svr4_misc.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_misc.c,v retrieving revision 1.90 retrieving revision 1.89.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.90 -r1.89.2.2 --- sys/compat/svr4/svr4_misc.c 2001/03/15 06:10:54 1.90 +++ sys/compat/svr4/svr4_misc.c 2001/04/09 01:55:49 1.89.2.2 @@ -46,8 +46,9 @@ #include #include #include #include +#include #include #include #include #include @@ -101,27 +102,28 @@ static __inline clock_t timeval_to_clock_t __P((struct timeval *)); static int svr4_setinfo __P((struct proc *, int, svr4_siginfo_t *)); struct svr4_hrtcntl_args; -static int svr4_hrtcntl __P((struct proc *, struct svr4_hrtcntl_args *, +static int svr4_hrtcntl __P((struct lwp *, struct svr4_hrtcntl_args *, register_t *)); static void bsd_statfs_to_svr4_statvfs __P((const struct statfs *, struct svr4_statvfs *)); static void bsd_statfs_to_svr4_statvfs64 __P((const struct statfs *, struct svr4_statvfs64 *)); static struct proc *svr4_pfind __P((pid_t pid)); -static int svr4_mknod __P((struct proc *, register_t *, const char *, +static int svr4_mknod __P((struct lwp *, register_t *, const char *, svr4_mode_t, svr4_dev_t)); int -svr4_sys_wait(p, v, retval) - struct proc *p; +svr4_sys_wait(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_wait_args *uap = v; struct sys_wait4_args w4; + struct proc *p = l->l_proc; int error; size_t sz = sizeof(*SCARG(&w4, status)); int st, sig; @@ -137,9 +139,9 @@ SCARG(&w4, status) = SCARG(uap, status); SCARG(&w4, pid) = WAIT_ANY; - if ((error = sys_wait4(p, &w4, retval)) != 0) + if ((error = sys_wait4(l, &w4, retval)) != 0) return error; if ((error = copyin(SCARG(&w4, status), &st, sizeof(st))) != 0) return error; @@ -168,18 +170,19 @@ } int -svr4_sys_execv(p, v, retval) - struct proc *p; +svr4_sys_execv(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_execv_args /* { syscallarg(char *) path; syscallarg(char **) argv; } */ *uap = v; struct sys_execve_args ap; + struct proc *p = l->l_proc; caddr_t sg; sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); @@ -187,15 +190,15 @@ SCARG(&ap, path) = SCARG(uap, path); SCARG(&ap, argp) = SCARG(uap, argp); SCARG(&ap, envp) = NULL; - return sys_execve(p, &ap, retval); + return sys_execve(l, &ap, retval); } int -svr4_sys_execve(p, v, retval) - struct proc *p; +svr4_sys_execve(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_execve_args /* { @@ -203,8 +206,9 @@ syscallarg(char **) argv; syscallarg(char **) envp; } */ *uap = v; struct sys_execve_args ap; + struct proc *p = l->l_proc; caddr_t sg; sg = stackgap_init(p->p_emul); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); @@ -212,15 +216,15 @@ SCARG(&ap, path) = SCARG(uap, path); SCARG(&ap, argp) = SCARG(uap, argp); SCARG(&ap, envp) = SCARG(uap, envp); - return sys_execve(p, &ap, retval); + return sys_execve(l, &ap, retval); } int -svr4_sys_time(p, v, retval) - struct proc *p; +svr4_sys_time(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_time_args *uap = v; @@ -244,14 +248,15 @@ * * This is quite ugly, but what do you expect from compatibility code? */ int -svr4_sys_getdents64(p, v, retval) - struct proc *p; +svr4_sys_getdents64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_getdents64_args *uap = v; + struct proc *p = l->l_proc; struct dirent *bdp; struct vnode *vp; caddr_t inp, buf; /* BSD-format */ int len, reclen; /* BSD-format */ @@ -363,14 +368,15 @@ } int -svr4_sys_getdents(p, v, retval) - struct proc *p; +svr4_sys_getdents(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_getdents_args *uap = v; + struct proc *p = l->l_proc; struct dirent *bdp; struct vnode *vp; caddr_t inp, buf; /* BSD-format */ int len, reclen; /* BSD-format */ @@ -486,10 +492,10 @@ } int -svr4_sys_mmap(p, v, retval) - struct proc *p; +svr4_sys_mmap(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_mmap_args *uap = v; @@ -511,20 +517,20 @@ SCARG(&mm, fd) = SCARG(uap, fd); SCARG(&mm, addr) = SCARG(uap, addr); SCARG(&mm, pos) = SCARG(uap, pos); - rp = (void *) round_page((vaddr_t)p->p_vmspace->vm_daddr + MAXDSIZ); + rp = (void *) round_page((vaddr_t)l->l_proc->p_vmspace->vm_daddr + MAXDSIZ); if ((SCARG(&mm, flags) & MAP_FIXED) == 0 && SCARG(&mm, addr) != 0 && SCARG(&mm, addr) < rp) SCARG(&mm, addr) = rp; - return sys_mmap(p, &mm, retval); + return sys_mmap(l, &mm, retval); } int -svr4_sys_mmap64(p, v, retval) - struct proc *p; +svr4_sys_mmap64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_mmap64_args *uap = v; @@ -546,83 +552,83 @@ SCARG(&mm, fd) = SCARG(uap, fd); SCARG(&mm, addr) = SCARG(uap, addr); SCARG(&mm, pos) = SCARG(uap, pos); - rp = (void *) round_page((vaddr_t)p->p_vmspace->vm_daddr + MAXDSIZ); + rp = (void *) round_page((vaddr_t)l->l_proc->p_vmspace->vm_daddr + MAXDSIZ); if ((SCARG(&mm, flags) & MAP_FIXED) == 0 && SCARG(&mm, addr) != 0 && SCARG(&mm, addr) < rp) SCARG(&mm, addr) = rp; - return sys_mmap(p, &mm, retval); + return sys_mmap(l, &mm, retval); } static int -svr4_mknod(p, retval, path, mode, dev) - struct proc *p; +svr4_mknod(l, retval, path, mode, dev) + struct lwp *l; register_t *retval; const char *path; svr4_mode_t mode; svr4_dev_t dev; { - caddr_t sg = stackgap_init(p->p_emul); + caddr_t sg = stackgap_init(l->l_proc->p_emul); - CHECK_ALT_CREAT(p, &sg, path); + CHECK_ALT_CREAT(l->l_proc, &sg, path); if (S_ISFIFO(mode)) { struct sys_mkfifo_args ap; SCARG(&ap, path) = path; SCARG(&ap, mode) = mode; - return sys_mkfifo(p, &ap, retval); + return sys_mkfifo(l, &ap, retval); } else { struct sys_mknod_args ap; SCARG(&ap, path) = path; SCARG(&ap, mode) = mode; SCARG(&ap, dev) = dev; - return sys_mknod(p, &ap, retval); + return sys_mknod(l, &ap, retval); } } int -svr4_sys_mknod(p, v, retval) - struct proc *p; +svr4_sys_mknod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_mknod_args *uap = v; - return svr4_mknod(p, retval, + return svr4_mknod(l, retval, SCARG(uap, path), SCARG(uap, mode), svr4_to_bsd_odev_t(SCARG(uap, dev))); } int -svr4_sys_xmknod(p, v, retval) - struct proc *p; +svr4_sys_xmknod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_xmknod_args *uap = v; - return svr4_mknod(p, retval, + return svr4_mknod(l, retval, SCARG(uap, path), SCARG(uap, mode), svr4_to_bsd_dev_t(SCARG(uap, dev))); } int -svr4_sys_vhangup(p, v, retval) - struct proc *p; +svr4_sys_vhangup(l, v, retval) + struct lwp *l; void *v; register_t *retval; { return 0; } int -svr4_sys_sysconfig(p, v, retval) - struct proc *p; +svr4_sys_sysconfig(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_sysconfig_args *uap = v; @@ -745,14 +751,15 @@ /* ARGSUSED */ int -svr4_sys_break(p, v, retval) - struct proc *p; +svr4_sys_break(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_break_args *uap = v; + struct proc *p = l->l_proc; struct vmspace *vm = p->p_vmspace; vaddr_t new, old; int error, diff; @@ -801,10 +808,10 @@ } int -svr4_sys_times(p, v, retval) - struct proc *p; +svr4_sys_times(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_times_args *uap = v; @@ -814,15 +821,15 @@ struct rusage *ru; struct rusage r; struct sys_getrusage_args ga; - caddr_t sg = stackgap_init(p->p_emul); + caddr_t sg = stackgap_init(l->l_proc->p_emul); ru = stackgap_alloc(&sg, sizeof(struct rusage)); SCARG(&ga, who) = RUSAGE_SELF; SCARG(&ga, rusage) = ru; - error = sys_getrusage(p, &ga, retval); + error = sys_getrusage(l, &ga, retval); if (error) return error; if ((error = copyin(ru, &r, sizeof r)) != 0) @@ -831,9 +838,9 @@ tms.tms_utime = timeval_to_clock_t(&r.ru_utime); tms.tms_stime = timeval_to_clock_t(&r.ru_stime); SCARG(&ga, who) = RUSAGE_CHILDREN; - error = sys_getrusage(p, &ga, retval); + error = sys_getrusage(l, &ga, retval); if (error) return error; if ((error = copyin(ru, &r, sizeof r)) != 0) @@ -849,14 +856,15 @@ } int -svr4_sys_ulimit(p, v, retval) - struct proc *p; +svr4_sys_ulimit(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_ulimit_args *uap = v; + struct proc *p = l->l_proc; switch (SCARG(uap, cmd)) { case SVR4_GFILLIM: *retval = p->p_rlimit[RLIMIT_FSIZE].rlim_cur / 512; @@ -882,9 +890,9 @@ SCARG(&srl, which) = RLIMIT_FSIZE; SCARG(&srl, rlp) = url; - error = sys_setrlimit(p, &srl, retval); + error = sys_setrlimit(l, &srl, retval); if (error) return error; *retval = p->p_rlimit[RLIMIT_FSIZE].rlim_cur; @@ -942,14 +950,15 @@ } int -svr4_sys_pgrpsys(p, v, retval) - struct proc *p; +svr4_sys_pgrpsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_pgrpsys_args *uap = v; + struct proc *p = l->l_proc; switch (SCARG(uap, cmd)) { case 1: /* setpgrp() */ /* @@ -958,9 +967,9 @@ * in almost every sense, setpgrp() is identical to * setsid() for SVR4. (Under BSD, the difference is that * a setpgid(0,0) will not create a new session.) */ - sys_setsid(p, NULL, retval); + sys_setsid(l, NULL, retval); /*FALLTHROUGH*/ case 0: /* getpgrp() */ *retval = p->p_pgrp->pg_id; @@ -977,9 +986,9 @@ *retval = (register_t) p->p_session->s_sid; return 0; case 3: /* setsid() */ - return sys_setsid(p, NULL, retval); + return sys_setsid(l, NULL, retval); case 4: /* getpgid(pid) */ if (SCARG(uap, pid) != 0 && @@ -994,9 +1003,9 @@ struct sys_setpgid_args sa; SCARG(&sa, pid) = SCARG(uap, pid); SCARG(&sa, pgid) = SCARG(uap, pgid); - return sys_setpgid(p, &sa, retval); + return sys_setpgid(l, &sa, retval); } default: return EINVAL; @@ -1012,10 +1021,10 @@ }; static int -svr4_hrtcntl(p, uap, retval) - struct proc *p; +svr4_hrtcntl(l, uap, retval) + struct lwp *l; struct svr4_hrtcntl_args *uap; register_t *retval; { switch (SCARG(uap, fun)) { @@ -1058,18 +1067,18 @@ } int -svr4_sys_hrtsys(p, v, retval) - struct proc *p; +svr4_sys_hrtsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_hrtsys_args *uap = v; switch (SCARG(uap, cmd)) { case SVR4_HRT_CNTL: - return svr4_hrtcntl(p, (struct svr4_hrtcntl_args *) uap, + return svr4_hrtcntl(l, (struct svr4_hrtcntl_args *) uap, retval); case SVR4_HRT_ALRM: DPRINTF(("hrtalarm\n")); @@ -1146,15 +1155,16 @@ } int -svr4_sys_waitsys(p, v, retval) - struct proc *p; +svr4_sys_waitsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_waitsys_args *uap = v; int nfound, error, s; + struct proc *p = l->l_proc; struct proc *q, *t; switch (SCARG(uap, grp)) { @@ -1339,15 +1349,16 @@ } int -svr4_sys_statvfs(p, v, retval) - struct proc *p; +svr4_sys_statvfs(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_statvfs_args *uap = v; struct sys_statfs_args fs_args; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs)); struct statfs bfs; struct svr4_statvfs sfs; @@ -1356,9 +1367,9 @@ CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); SCARG(&fs_args, path) = SCARG(uap, path); SCARG(&fs_args, buf) = fs; - if ((error = sys_statfs(p, &fs_args, retval)) != 0) + if ((error = sys_statfs(l, &fs_args, retval)) != 0) return error; if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0) return error; @@ -1369,25 +1380,25 @@ } int -svr4_sys_fstatvfs(p, v, retval) - struct proc *p; +svr4_sys_fstatvfs(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_fstatvfs_args *uap = v; struct sys_fstatfs_args fs_args; - caddr_t sg = stackgap_init(p->p_emul); + caddr_t sg = stackgap_init(l->l_proc->p_emul); struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs)); struct statfs bfs; struct svr4_statvfs sfs; int error; SCARG(&fs_args, fd) = SCARG(uap, fd); SCARG(&fs_args, buf) = fs; - if ((error = sys_fstatfs(p, &fs_args, retval)) != 0) + if ((error = sys_fstatfs(l, &fs_args, retval)) != 0) return error; if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0) return error; @@ -1398,26 +1409,26 @@ } int -svr4_sys_statvfs64(p, v, retval) - struct proc *p; +svr4_sys_statvfs64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_statvfs64_args *uap = v; struct sys_statfs_args fs_args; - caddr_t sg = stackgap_init(p->p_emul); + caddr_t sg = stackgap_init(l->l_proc->p_emul); struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs)); struct statfs bfs; struct svr4_statvfs64 sfs; int error; - CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + CHECK_ALT_EXIST(l->l_proc, &sg, SCARG(uap, path)); SCARG(&fs_args, path) = SCARG(uap, path); SCARG(&fs_args, buf) = fs; - if ((error = sys_statfs(p, &fs_args, retval)) != 0) + if ((error = sys_statfs(l, &fs_args, retval)) != 0) return error; if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0) return error; @@ -1428,25 +1439,25 @@ } int -svr4_sys_fstatvfs64(p, v, retval) - struct proc *p; +svr4_sys_fstatvfs64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_fstatvfs64_args *uap = v; struct sys_fstatfs_args fs_args; - caddr_t sg = stackgap_init(p->p_emul); + caddr_t sg = stackgap_init(l->l_proc->p_emul); struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs)); struct statfs bfs; struct svr4_statvfs64 sfs; int error; SCARG(&fs_args, fd) = SCARG(uap, fd); SCARG(&fs_args, buf) = fs; - if ((error = sys_fstatfs(p, &fs_args, retval)) != 0) + if ((error = sys_fstatfs(l, &fs_args, retval)) != 0) return error; if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0) return error; @@ -1457,18 +1468,18 @@ } int -svr4_sys_alarm(p, v, retval) - struct proc *p; +svr4_sys_alarm(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_alarm_args *uap = v; int error; struct itimerval *ntp, *otp, tp; struct sys_setitimer_args sa; - caddr_t sg = stackgap_init(p->p_emul); + caddr_t sg = stackgap_init(l->l_proc->p_emul); ntp = stackgap_alloc(&sg, sizeof(struct itimerval)); otp = stackgap_alloc(&sg, sizeof(struct itimerval)); @@ -1482,9 +1493,9 @@ SCARG(&sa, which) = ITIMER_REAL; SCARG(&sa, itv) = ntp; SCARG(&sa, oitv) = otp; - if ((error = sys_setitimer(p, &sa, retval)) != 0) + if ((error = sys_setitimer(l, &sa, retval)) != 0) return error; if ((error = copyin(otp, &tp, sizeof(tp))) != 0) return error; @@ -1498,10 +1509,10 @@ } int -svr4_sys_gettimeofday(p, v, retval) - struct proc *p; +svr4_sys_gettimeofday(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_gettimeofday_args *uap = v; @@ -1517,10 +1528,10 @@ } int -svr4_sys_facl(p, v, retval) - struct proc *p; +svr4_sys_facl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_facl_args *uap = v; @@ -1545,20 +1556,20 @@ } int -svr4_sys_acl(p, v, retval) - struct proc *p; +svr4_sys_acl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { - return svr4_sys_facl(p, v, retval); /* XXX: for now the same */ + return svr4_sys_facl(l, v, retval); /* XXX: for now the same */ } int -svr4_sys_auditsys(p, v, retval) - struct proc *p; +svr4_sys_auditsys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { /* @@ -1568,10 +1579,10 @@ } int -svr4_sys_memcntl(p, v, retval) - struct proc *p; +svr4_sys_memcntl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_memcntl_args *uap = v; @@ -1583,9 +1594,9 @@ SCARG(&msa, addr) = SCARG(uap, addr); SCARG(&msa, len) = SCARG(uap, len); SCARG(&msa, flags) = (int)(u_long)SCARG(uap, arg); - return sys___msync13(p, &msa, retval); + return sys___msync13(l, &msa, retval); } case SVR4_MC_ADVISE: { struct sys_madvise_args maa; @@ -1593,9 +1604,9 @@ SCARG(&maa, addr) = SCARG(uap, addr); SCARG(&maa, len) = SCARG(uap, len); SCARG(&maa, behav) = (int)(u_long)SCARG(uap, arg); - return sys_madvise(p, &maa, retval); + return sys_madvise(l, &maa, retval); } case SVR4_MC_LOCK: case SVR4_MC_UNLOCK: case SVR4_MC_LOCKAS: @@ -1607,10 +1618,10 @@ } int -svr4_sys_nice(p, v, retval) - struct proc *p; +svr4_sys_nice(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_nice_args *uap = v; @@ -1620,21 +1631,21 @@ SCARG(&ap, which) = PRIO_PROCESS; SCARG(&ap, who) = 0; SCARG(&ap, prio) = SCARG(uap, prio); - if ((error = sys_setpriority(p, &ap, retval)) != 0) + if ((error = sys_setpriority(l, &ap, retval)) != 0) return error; - if ((error = sys_getpriority(p, &ap, retval)) != 0) + if ((error = sys_getpriority(l, &ap, retval)) != 0) return error; return 0; } int -svr4_sys_resolvepath(p, v, retval) - struct proc *p; +svr4_sys_resolvepath(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_resolvepath_args *uap = v; @@ -1642,9 +1653,9 @@ int error; size_t len; NDINIT(&nd, LOOKUP, NOFOLLOW | SAVENAME, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), l->l_proc); if ((error = namei(&nd)) != 0) return error; Index: sys/compat/svr4/svr4_net.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_net.c,v retrieving revision 1.25 retrieving revision 1.24.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.25 -r1.24.2.2 --- sys/compat/svr4/svr4_net.c 2001/04/07 17:37:10 1.25 +++ sys/compat/svr4/svr4_net.c 2001/04/09 01:55:49 1.24.2.2 @@ -265,9 +265,9 @@ if ((error = copyout(ptyname, path, sizeof(ptyname))) != 0) return error; - switch (error = sys_open(p, &oa, &fd)) { + switch (error = sys_open(curproc, &oa, &fd)) { /* XXX NJWLWP */ case ENOENT: case ENXIO: return error; case 0: Index: sys/compat/svr4/svr4_resource.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_resource.c,v retrieving revision 1.6 retrieving revision 1.6.6.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.6 -r1.6.6.1 --- sys/compat/svr4/svr4_resource.c 2000/03/30 11:27:20 1.6 +++ sys/compat/svr4/svr4_resource.c 2001/03/05 22:49:30 1.6.6.1 @@ -37,8 +37,9 @@ */ #include #include +#include #include #include #include #include @@ -91,15 +92,16 @@ ((svr4_rlim64_t)(l)) != SVR4_RLIM64_SAVED_CUR && \ ((svr4_rlim64_t)(l)) != SVR4_RLIM64_SAVED_MAX) int -svr4_sys_getrlimit(p, v, retval) - struct proc *p; +svr4_sys_getrlimit(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_getrlimit_args *uap = v; int rl = svr4_to_native_rl(SCARG(uap, which)); + struct proc *p = l->l_proc; struct rlimit blim; struct svr4_rlimit slim; if (rl == -1) @@ -138,15 +140,16 @@ } int -svr4_sys_setrlimit(p, v, retval) - struct proc *p; +svr4_sys_setrlimit(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_setrlimit_args *uap = v; int rl = svr4_to_native_rl(SCARG(uap, which)); + struct proc *p = l->l_proc; struct rlimit blim, *limp; struct svr4_rlimit slim; int error; @@ -189,15 +192,16 @@ } int -svr4_sys_getrlimit64(p, v, retval) - struct proc *p; +svr4_sys_getrlimit64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_getrlimit64_args *uap = v; int rl = svr4_to_native_rl(SCARG(uap, which)); + struct proc *p = l->l_proc; struct rlimit blim; struct svr4_rlimit64 slim; if (rl == -1) @@ -236,15 +240,16 @@ } int -svr4_sys_setrlimit64(p, v, retval) - struct proc *p; +svr4_sys_setrlimit64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_setrlimit64_args *uap = v; int rl = svr4_to_native_rl(SCARG(uap, which)); + struct proc *p = l->l_proc; struct rlimit blim, *limp; struct svr4_rlimit64 slim; int error; Index: sys/compat/svr4/svr4_signal.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_signal.c,v retrieving revision 1.41 retrieving revision 1.41.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.41 -r1.41.2.1 --- sys/compat/svr4/svr4_signal.c 2001/02/21 21:39:59 1.41 +++ sys/compat/svr4/svr4_signal.c 2001/03/05 22:49:30 1.41.2.1 @@ -38,8 +38,9 @@ #include #include #include +#include #include #include #include #include @@ -274,10 +275,10 @@ sss->ss_flags |= SVR4_SS_ONSTACK; } int -svr4_sys_sigaction(p, v, retval) - struct proc *p; +svr4_sys_sigaction(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_sigaction_args /* { @@ -294,9 +295,9 @@ if (error) return (error); svr4_to_native_sigaction(&nssa, &nbsa); } - error = sigaction1(p, svr4_to_native_sig[SCARG(uap, signum)], + error = sigaction1(l->l_proc, svr4_to_native_sig[SCARG(uap, signum)], SCARG(uap, nsa) ? &nbsa : 0, SCARG(uap, osa) ? &obsa : 0); if (error) return (error); if (SCARG(uap, osa)) { @@ -308,10 +309,10 @@ return (0); } int -svr4_sys_sigaltstack(p, v, retval) - struct proc *p; +svr4_sys_sigaltstack(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_sigaltstack_args /* { @@ -327,9 +328,9 @@ if (error) return (error); svr4_to_native_sigaltstack(&nsss, &nbss); } - error = sigaltstack1(p, + error = sigaltstack1(l->l_proc, SCARG(uap, nss) ? &nbss : 0, SCARG(uap, oss) ? &obss : 0); if (error) return (error); if (SCARG(uap, oss)) { @@ -344,17 +345,18 @@ /* * Stolen from the ibcs2 one */ int -svr4_sys_signal(p, v, retval) - struct proc *p; +svr4_sys_signal(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_signal_args /* { syscallarg(int) signum; syscallarg(svr4_sig_t) handler; } */ *uap = v; + struct proc *p = l->l_proc; int signum = svr4_to_native_sig[SVR4_SIGNO(SCARG(uap, signum))]; struct sigaction nbsa, obsa; sigset_t ss; int error; @@ -405,10 +407,10 @@ } } int -svr4_sys_sigprocmask(p, v, retval) - struct proc *p; +svr4_sys_sigprocmask(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_sigprocmask_args /* { @@ -448,9 +450,9 @@ if (error) return error; svr4_to_native_sigset(&nsss, &nbss); } - error = sigprocmask1(p, how, + error = sigprocmask1(l->l_proc, how, SCARG(uap, set) ? &nbss : NULL, SCARG(uap, oset) ? &obss : NULL); if (error) return error; if (SCARG(uap, oset)) { @@ -462,10 +464,10 @@ return 0; } int -svr4_sys_sigpending(p, v, retval) - struct proc *p; +svr4_sys_sigpending(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_sigpending_args /* { @@ -476,9 +478,9 @@ svr4_sigset_t sss; switch (SCARG(uap, what)) { case 1: /* sigpending */ - sigpending1(p, &bss); + sigpending1(l->l_proc, &bss); native_to_svr4_sigset(&bss, &sss); break; case 2: /* sigfillset */ @@ -491,10 +493,10 @@ return (copyout(&sss, SCARG(uap, set), sizeof(sss))); } int -svr4_sys_sigsuspend(p, v, retval) - struct proc *p; +svr4_sys_sigsuspend(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_sigsuspend_args /* { @@ -510,24 +512,24 @@ return (error); svr4_to_native_sigset(&sss, &bss); } - return (sigsuspend1(p, SCARG(uap, set) ? &bss : 0)); + return (sigsuspend1(l->l_proc, SCARG(uap, set) ? &bss : 0)); } int -svr4_sys_pause(p, v, retval) - struct proc *p; +svr4_sys_pause(l, v, retval) + struct lwp *l; void *v; register_t *retval; { - return (sigsuspend1(p, 0)); + return (sigsuspend1(l->l_proc, 0)); } int -svr4_sys_kill(p, v, retval) - struct proc *p; +svr4_sys_kill(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_kill_args /* { @@ -537,103 +539,74 @@ struct sys_kill_args ka; SCARG(&ka, pid) = SCARG(uap, pid); SCARG(&ka, signum) = svr4_to_native_sig[SCARG(uap, signum)]; - return sys_kill(p, &ka, retval); + return sys_kill(l, &ka, retval); } void -svr4_getcontext(p, uc, mask) - struct proc *p; +svr4_getcontext(l, uc) + struct lwp *l; struct svr4_ucontext *uc; - sigset_t *mask; { - void *sp; - struct svr4_sigaltstack *ss = &uc->uc_stack; + sigset_t mask; + ucontext_t *nuc; + + nuc = (ucontext_t *) uc; + + getucontext(l, nuc); + mask = nuc->uc_sigmask; + native_to_svr4_sigset(&mask, &uc->uc_sigmask); - memset(uc, 0, sizeof(*uc)); - - /* get machine context */ - sp = svr4_getmcontext(p, &uc->uc_mcontext, &uc->uc_flags); - - /* get link */ - uc->uc_link = p->p_ctxlink; - - /* get stack state. XXX: solaris appears to do this */ -#if 0 - svr4_to_native_sigaltstack(&uc->uc_stack, &p->p_sigacts->ps_sigstk); -#else - ss->ss_sp = (void *)(((u_long) sp) & ~(16384 - 1)); - ss->ss_size = 16384; - ss->ss_flags = 0; -#endif - /* get signal mask */ - native_to_svr4_sigset(mask, &uc->uc_sigmask); - - uc->uc_flags |= SVR4_UC_STACK|SVR4_UC_SIGMASK; } int -svr4_setcontext(p, uc) - struct proc *p; +svr4_setcontext(l, uc) + struct lwp *l; struct svr4_ucontext *uc; { - int error; - - /* set machine context */ - if ((error = svr4_setmcontext(p, &uc->uc_mcontext, uc->uc_flags)) != 0) - return error; - - /* set link */ - p->p_ctxlink = uc->uc_link; - - /* set signal stack */ - if (uc->uc_flags & SVR4_UC_STACK) { - svr4_to_native_sigaltstack(&uc->uc_stack, - &p->p_sigctx.ps_sigstk); - } + sigset_t mask; + ucontext_t *nuc; - /* set signal mask */ - if (uc->uc_flags & SVR4_UC_SIGMASK) { - sigset_t mask; + nuc = (ucontext_t *) uc; + + svr4_to_native_sigset(&uc->uc_sigmask, &mask); + nuc->uc_sigmask = mask; + setucontext(l, (ucontext_t *) uc); - svr4_to_native_sigset(&uc->uc_sigmask, &mask); - (void)sigprocmask1(p, SIG_SETMASK, &mask, 0); - } - return EJUSTRETURN; } int -svr4_sys_context(p, v, retval) - struct proc *p; +svr4_sys_context(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_context_args /* { syscallarg(int) func; syscallarg(struct svr4_ucontext *) uc; } */ *uap = v; - struct svr4_ucontext uc; int error; + svr4_ucontext_t uc; *retval = 0; switch (SCARG(uap, func)) { case SVR4_GETCONTEXT: DPRINTF(("getcontext(%p)\n", SCARG(uap, uc))); - svr4_getcontext(p, &uc, &p->p_sigctx.ps_sigmask); - return copyout(&uc, SCARG(uap, uc), sizeof(uc)); + svr4_getcontext(l, &uc); + return (copyout(&uc, SCARG(uap, uc), sizeof (*SCARG(uap, uc)))); + case SVR4_SETCONTEXT: DPRINTF(("setcontext(%p)\n", SCARG(uap, uc))); - if (SCARG(uap, uc) == NULL) - exit1(p, W_EXITCODE(0, 0)); - else if ((error = copyin(SCARG(uap, uc), &uc, sizeof(uc))) != 0) - return error; - else - return svr4_setcontext(p, &uc); - + error = copyin(SCARG(uap, uc), &uc, sizeof (uc)); + if (error) + return (error); + svr4_setcontext(l, &uc); + return EJUSTRETURN; + default: DPRINTF(("context(%d, %p)\n", SCARG(uap, func), SCARG(uap, uc))); return ENOSYS; Index: sys/compat/svr4/svr4_socket.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_socket.c,v retrieving revision 1.8 retrieving revision 1.8.14.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.8 -r1.8.14.1 --- sys/compat/svr4/svr4_socket.c 1999/09/07 18:20:19 1.8 +++ sys/compat/svr4/svr4_socket.c 2001/03/05 22:49:30 1.8.14.1 @@ -180,10 +180,10 @@ } int -svr4_sys_socket(p, v, retval) - struct proc *p; +svr4_sys_socket(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_socket_args *uap = v; @@ -210,6 +210,6 @@ break; default: return EINVAL; } - return sys_socket(p, uap, retval); + return sys_socket(l, uap, retval); } Index: sys/compat/svr4/svr4_stat.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_stat.c,v retrieving revision 1.42 retrieving revision 1.42.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.42 -r1.42.2.1 --- sys/compat/svr4/svr4_stat.c 2001/02/21 23:53:01 1.42 +++ sys/compat/svr4/svr4_stat.c 2001/03/05 22:49:30 1.42.2.1 @@ -79,9 +79,9 @@ #endif static void bsd_to_svr4_xstat __P((struct stat *, struct svr4_xstat *)); static void bsd_to_svr4_stat64 __P((struct stat *, struct svr4_stat64 *)); -int svr4_ustat __P((struct proc *, void *, register_t *)); +int svr4_ustat __P((struct lwp *, void *, register_t *)); static int svr4_to_bsd_pathconf __P((int)); /* * SVR4 uses named pipes as named sockets, so we tell programs @@ -166,14 +166,15 @@ } int -svr4_sys_stat(p, v, retval) - struct proc *p; +svr4_sys_stat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_stat_args *uap = v; + struct proc *p = l->l_proc; #ifdef SVR4_NO_OSTAT struct svr4_sys_xstat_args cup; SCARG(&cup, two) = 2; @@ -190,9 +191,9 @@ SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); - if ((error = sys___stat13(p, &cup, retval)) != 0) + if ((error = sys___stat13(l, &cup, retval)) != 0) return error; if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) return error; @@ -210,14 +211,15 @@ } int -svr4_sys_lstat(p, v, retval) - struct proc *p; +svr4_sys_lstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_lstat_args *uap = v; + struct proc *p = l->l_proc; #ifdef SVR4_NO_OSTAT struct svr4_sys_lxstat_args cup; SCARG(&cup, two) = 2; @@ -234,9 +236,9 @@ SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); - if ((error = sys___lstat13(p, &cup, retval)) != 0) + if ((error = sys___lstat13(l, &cup, retval)) != 0) return error; if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) return error; @@ -254,14 +256,15 @@ } int -svr4_sys_fstat(p, v, retval) - struct proc *p; +svr4_sys_fstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_fstat_args *uap = v; + struct proc *p = l->l_proc; #ifdef SVR4_NO_OSTAT struct svr4_sys_fxstat_args cup; SCARG(&cup, two) = 2; @@ -278,9 +281,9 @@ SCARG(&cup, fd) = SCARG(uap, fd); SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat)); - if ((error = sys___fstat13(p, &cup, retval)) != 0) + if ((error = sys___fstat13(l, &cup, retval)) != 0) return error; if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0) return error; @@ -295,14 +298,15 @@ } int -svr4_sys_xstat(p, v, retval) - struct proc *p; +svr4_sys_xstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_xstat_args *uap = v; + struct proc *p = l->l_proc; struct stat st; struct svr4_xstat svr4_st; struct sys___stat13_args cup; int error; @@ -312,9 +316,9 @@ SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); - if ((error = sys___stat13(p, &cup, retval)) != 0) + if ((error = sys___stat13(l, &cup, retval)) != 0) return error; if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) return error; @@ -331,14 +335,15 @@ } int -svr4_sys_lxstat(p, v, retval) - struct proc *p; +svr4_sys_lxstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_lxstat_args *uap = v; + struct proc *p = l->l_proc; struct stat st; struct svr4_xstat svr4_st; struct sys___lstat13_args cup; int error; @@ -348,9 +353,9 @@ SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); - if ((error = sys___lstat13(p, &cup, retval)) != 0) + if ((error = sys___lstat13(l, &cup, retval)) != 0) return error; if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) return error; @@ -367,14 +372,15 @@ } int -svr4_sys_fxstat(p, v, retval) - struct proc *p; +svr4_sys_fxstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_fxstat_args *uap = v; + struct proc *p = l->l_proc; struct stat st; struct svr4_xstat svr4_st; struct sys___fstat13_args cup; int error; @@ -383,9 +389,9 @@ SCARG(&cup, fd) = SCARG(uap, fd); SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat)); - if ((error = sys___fstat13(p, &cup, retval)) != 0) + if ((error = sys___fstat13(l, &cup, retval)) != 0) return error; if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0) return error; @@ -399,14 +405,15 @@ } int -svr4_sys_stat64(p, v, retval) - struct proc *p; +svr4_sys_stat64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_stat64_args *uap = v; + struct proc *p = l->l_proc; struct stat st; struct svr4_stat64 svr4_st; struct sys___stat13_args cup; int error; @@ -416,9 +423,9 @@ SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); - if ((error = sys___stat13(p, &cup, retval)) != 0) + if ((error = sys___stat13(l, &cup, retval)) != 0) return error; if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) return error; @@ -435,14 +442,15 @@ } int -svr4_sys_lstat64(p, v, retval) - struct proc *p; +svr4_sys_lstat64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_lstat64_args *uap = v; + struct proc *p = l->l_proc; struct stat st; struct svr4_stat64 svr4_st; struct sys___lstat13_args cup; int error; @@ -452,9 +460,9 @@ SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); - if ((error = sys___lstat13(p, &cup, retval)) != 0) + if ((error = sys___lstat13(l, &cup, retval)) != 0) return error; if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) return error; @@ -471,14 +479,15 @@ } int -svr4_sys_fstat64(p, v, retval) - struct proc *p; +svr4_sys_fstat64(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_fstat64_args *uap = v; + struct proc *p = l->l_proc; struct stat st; struct svr4_stat64 svr4_st; struct sys___fstat13_args cup; int error; @@ -487,9 +496,9 @@ SCARG(&cup, fd) = SCARG(uap, fd); SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat)); - if ((error = sys___fstat13(p, &cup, retval)) != 0) + if ((error = sys___fstat13(l, &cup, retval)) != 0) return error; if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0) return error; @@ -508,10 +517,10 @@ syscallarg(struct svr4_ustat *) name; }; int -svr4_ustat(p, v, retval) - struct proc *p; +svr4_ustat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_ustat_args /* { @@ -535,10 +544,10 @@ int -svr4_sys_uname(p, v, retval) - struct proc *p; +svr4_sys_uname(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_uname_args *uap = v; @@ -566,14 +575,15 @@ } int -svr4_sys_systeminfo(p, v, retval) - struct proc *p; +svr4_sys_systeminfo(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_systeminfo_args *uap = v; + struct proc *p = l->l_proc; const char *str = NULL; int name; int error; size_t len; @@ -680,10 +690,10 @@ } int -svr4_sys_utssys(p, v, retval) - struct proc *p; +svr4_sys_utssys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_utssys_args *uap = v; @@ -692,17 +702,17 @@ case 0: /* uname(2) */ { struct svr4_sys_uname_args ua; SCARG(&ua, name) = SCARG(uap, a1); - return svr4_sys_uname(p, &ua, retval); + return svr4_sys_uname(l, &ua, retval); } case 2: /* ustat(2) */ { struct svr4_ustat_args ua; SCARG(&ua, dev) = (svr4_dev_t) SCARG(uap, a2); SCARG(&ua, name) = SCARG(uap, a1); - return svr4_ustat(p, &ua, retval); + return svr4_ustat(l, &ua, retval); } case 3: /* fusers(2) */ return ENOSYS; @@ -714,14 +724,15 @@ } int -svr4_sys_utime(p, v, retval) - struct proc *p; +svr4_sys_utime(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_utime_args *uap = v; + struct proc *p = l->l_proc; struct svr4_utimbuf ub; struct timeval tbuf[2]; struct sys_utimes_args ap; int error; @@ -744,22 +755,24 @@ SCARG(&ap, tptr) = ttp; } else SCARG(&ap, tptr) = NULL; - return sys_utimes(p, &ap, retval); + return sys_utimes(l, &ap, retval); } int -svr4_sys_utimes(p, v, retval) - struct proc *p; +svr4_sys_utimes(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_utimes_args *uap = v; + struct proc *p = l->l_proc; caddr_t sg = stackgap_init(p->p_emul); + CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - return sys_utimes(p, uap, retval); + return sys_utimes(l, uap, retval); } static int @@ -812,17 +825,17 @@ } int -svr4_sys_pathconf(p, v, retval) - struct proc *p; +svr4_sys_pathconf(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_pathconf_args *uap = v; - caddr_t sg = stackgap_init(p->p_emul); + caddr_t sg = stackgap_init(l->l_proc->p_emul); - CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + CHECK_ALT_EXIST(l->l_proc, &sg, SCARG(uap, path)); SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name)); switch (SCARG(uap, name)) { @@ -832,16 +845,16 @@ case 0: *retval = 0; return 0; default: - return sys_pathconf(p, uap, retval); + return sys_pathconf(l, uap, retval); } } int -svr4_sys_fpathconf(p, v, retval) - struct proc *p; +svr4_sys_fpathconf(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_fpathconf_args *uap = v; @@ -855,7 +868,7 @@ case 0: *retval = 0; return 0; default: - return sys_fpathconf(p, uap, retval); + return sys_fpathconf(l, uap, retval); } } Index: sys/compat/svr4/svr4_stream.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_stream.c,v retrieving revision 1.41 retrieving revision 1.41.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.41 -r1.41.2.1 --- sys/compat/svr4/svr4_stream.c 2000/08/30 01:13:22 1.41 +++ sys/compat/svr4/svr4_stream.c 2001/03/05 22:49:30 1.41.2.1 @@ -289,9 +289,10 @@ return error; SCARG(&la, path) = tpath; - if ((error = sys___lstat13(p, &la, &retval)) != 0) + /* XXX NJWLWP */ + if ((error = sys___lstat13(curproc, &la, &retval)) != 0) return 0; if ((error = copyin(SCARG(&la, ub), &st, sizeof(st))) != 0) return 0; @@ -304,11 +305,13 @@ if ((st.st_mode & ALLPERMS) != 0) return 0; + SCARG(&ua, path) = SCARG(&la, path); - if ((error = sys_unlink(p, &ua, &retval)) != 0) { + /* XXX NJWLWP */ + if ((error = sys_unlink(curproc, &ua, &retval)) != 0) { DPRINTF(("clean_pipe: unlink failed %d\n", error)); return error; } @@ -536,9 +539,10 @@ SCARG(&la, s) = fd; DPRINTF(("SI_LISTEN: fileno %d backlog = %d\n", fd, 5)); SCARG(&la, backlog) = 5; - if ((error = sys_listen(p, &la, &retval)) != 0) { + /* XXX NJWLWP */ + if ((error = sys_listen(curproc, &la, &retval)) != 0) { DPRINTF(("SI_LISTEN: listen failed %d\n", error)); return error; } @@ -649,9 +653,10 @@ return error; SCARG(&ap, s) = fd; - return sys_shutdown(p, &ap, &retval); + /* XXX NJWLWP */ + return sys_shutdown(curproc, &ap, &retval); } static int @@ -836,9 +841,10 @@ DPRINTF(("TI_BIND: fileno %d\n", fd)); SCARG(&ba, name) = (void *) sup; SCARG(&ba, namelen) = sasize; - if ((error = sys_bind(p, &ba, &retval)) != 0) { + /* XXX NJWLWP */ + if ((error = sys_bind(curproc, &ba, &retval)) != 0) { DPRINTF(("TI_BIND: bind failed %d\n", error)); return error; } @@ -952,9 +958,10 @@ struct sys_getsockname_args ap; SCARG(&ap, fdes) = fd; SCARG(&ap, asa) = sup; SCARG(&ap, alen) = lenp; - if ((error = sys_getsockname(p, &ap, retval)) != 0) { + /* XXX NJWLWP */ + if ((error = sys_getsockname(curproc, &ap, retval)) != 0) { DPRINTF(("ti_ioctl: getsockname error\n")); return error; } } @@ -966,9 +973,10 @@ struct sys_getpeername_args ap; SCARG(&ap, fdes) = fd; SCARG(&ap, asa) = sup; SCARG(&ap, alen) = lenp; - if ((error = sys_getpeername(p, &ap, retval)) != 0) { + /* XXX NJWLWP */ + if ((error = sys_getpeername(curproc, &ap, retval)) != 0) { DPRINTF(("ti_ioctl: getpeername error\n")); return error; } } @@ -1100,17 +1108,19 @@ SCARG(&d2p, from) = st->s_afd; SCARG(&d2p, to) = fdi.fd; - if ((error = sys_dup2(p, &d2p, retval)) != 0) { + /* XXX NJWLWP */ + if ((error = sys_dup2(curproc, &d2p, retval)) != 0) { DPRINTF(("fdinsert: dup2(%d, %d) failed %d\n", st->s_afd, fdi.fd, error)); return error; } SCARG(&clp, fd) = st->s_afd; - if ((error = sys_close(p, &clp, retval)) != 0) { + /* XXX NJWLWP */ + if ((error = sys_close(curproc, &clp, retval)) != 0) { DPRINTF(("fdinsert: close(%d) failed %d\n", st->s_afd, error)); return error; } @@ -1142,9 +1152,10 @@ */ SCARG(&ap, path) = dat; SCARG(&ap, mode) = S_IFIFO; - return sys_mkfifo(p, &ap, retval); + /* XXX NJWLWP */ + return sys_mkfifo(curproc, &ap, retval); } static int _i_rele_rsvd(fp, p, retval, fd, cmd, dat) @@ -1162,9 +1173,10 @@ * I guess it is supposed to release the socket. */ SCARG(&ap, path) = dat; - return sys_unlink(p, &ap, retval); + /* XXXNJWLWP */ + return sys_unlink(curproc, &ap, retval); } static int i_str(fp, p, retval, fd, cmd, dat) @@ -1244,9 +1256,10 @@ } /* get old status flags */ SCARG(&fa, fd) = fd; SCARG(&fa, cmd) = F_GETFL; - if ((error = sys_fcntl(p, &fa, &oflags)) != 0) + /* XXX NJWLWP */ + if ((error = sys_fcntl(curproc, &fa, &oflags)) != 0) return error; /* update the flags */ if (dat != NULL) { @@ -1268,17 +1281,19 @@ /* set the new flags, if changed */ if (flags != oflags) { SCARG(&fa, cmd) = F_SETFL; SCARG(&fa, arg) = (void *) flags; - if ((error = sys_fcntl(p, &fa, &flags)) != 0) + /* XXX NJWLWP */ + if ((error = sys_fcntl(curproc, &fa, &flags)) != 0) return error; } /* set up SIGIO receiver if needed */ if (dat != NULL) { SCARG(&fa, cmd) = F_SETOWN; SCARG(&fa, arg) = (void *)(u_long)p->p_pid; - return sys_fcntl(p, &fa, &flags); + /* XXX NJWLWP */ + return sys_fcntl(curproc, &fa, &flags); } return 0; } @@ -1484,14 +1499,15 @@ int -svr4_sys_putmsg(p, v, retval) - struct proc *p; +svr4_sys_putmsg(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_putmsg_args *uap = v; + struct proc *p = l->l_proc; struct filedesc *fdp = p->p_fd; struct file *fp; struct svr4_strbuf dat, ctl; struct svr4_strmcmd sc; @@ -1568,9 +1584,9 @@ DPRINTF(("sending expedited data (???)\n")); SCARG(&wa, fd) = SCARG(uap, fd); SCARG(&wa, buf) = dat.buf; SCARG(&wa, nbyte) = dat.len; - return sys_write(p, &wa, retval); + return sys_write(l, &wa, retval); } #endif DPRINTF(("putmsg: Invalid inet length %ld\n", sc.len)); return EINVAL; @@ -1621,9 +1637,9 @@ SCARG(&co, s) = SCARG(uap, fd); SCARG(&co, name) = (void *) sup; SCARG(&co, namelen) = (int) sasize; - return sys_connect(p, &co, retval); + return sys_connect(l, &co, retval); } case SVR4_TI_SENDTO_REQUEST: /* sendto */ { @@ -1652,14 +1668,15 @@ } int -svr4_sys_getmsg(p, v, retval) - struct proc *p; +svr4_sys_getmsg(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct svr4_sys_getmsg_args *uap = v; + struct proc *p = l->l_proc; struct filedesc *fdp = p->p_fd; struct file *fp; struct sys_getpeername_args ga; struct sys_accept_args aa; @@ -1774,9 +1791,9 @@ SCARG(&ga, fdes) = SCARG(uap, fd); SCARG(&ga, asa) = (void *) sup; SCARG(&ga, alen) = flen; - if ((error = sys_getpeername(p, &ga, retval)) != 0) { + if ((error = sys_getpeername(l, &ga, retval)) != 0) { DPRINTF(("getmsg: getpeername failed %d\n", error)); return error; } @@ -1833,9 +1850,9 @@ SCARG(&aa, s) = SCARG(uap, fd); SCARG(&aa, name) = (void *) sup; SCARG(&aa, anamelen) = flen; - if ((error = sys_accept(p, &aa, retval)) != 0) { + if ((error = sys_accept(l, &aa, retval)) != 0) { DPRINTF(("getmsg: accept failed %d\n", error)); return error; } Index: sys/compat/svr4/svr4_syscall.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_syscall.h,v retrieving revision 1.67 retrieving revision 1.67.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.67 -r1.67.2.1 --- sys/compat/svr4/svr4_syscall.h 2001/02/11 01:14:25 1.67 +++ sys/compat/svr4/svr4_syscall.h 2001/03/05 22:49:31 1.67.2.1 @@ -3,9 +3,9 @@ /* * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.49 2001/01/27 07:59:58 thorpej Exp + * created from NetBSD: syscalls.master,v 1.50 2001/02/11 01:13:01 eeh Exp */ /* syscall: "syscall" ret: "int" args: */ #define SVR4_SYS_syscall 0 @@ -485,6 +485,6 @@ /* syscall: "ntp_adjtime" ret: "int" args: "struct timex *" */ #define SVR4_SYS_ntp_adjtime 249 /* 249 is excluded ntp_adjtime */ -#define SVR4_SYS_MAXSYSCALL 250 +#define SVR4_SYS_MAXSYSCALL 256 #define SVR4_SYS_NSYSENT 256 Index: sys/compat/svr4/svr4_syscallargs.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_syscallargs.h,v retrieving revision 1.66 retrieving revision 1.66.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.66 -r1.66.2.1 --- sys/compat/svr4/svr4_syscallargs.h 2001/02/11 01:14:25 1.66 +++ sys/compat/svr4/svr4_syscallargs.h 2001/03/05 22:49:31 1.66.2.1 @@ -3,9 +3,9 @@ /* * System call argument lists. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.49 2001/01/27 07:59:58 thorpej Exp + * created from NetBSD: syscalls.master,v 1.50 2001/02/11 01:13:01 eeh Exp */ #ifndef _SVR4_SYS__SYSCALLARGS_H_ #define _SVR4_SYS__SYSCALLARGS_H_ @@ -500,173 +500,173 @@ /* * System call prototypes. */ -int sys_nosys(struct proc *, void *, register_t *); -int sys_exit(struct proc *, void *, register_t *); -int sys_fork(struct proc *, void *, register_t *); -int sys_read(struct proc *, void *, register_t *); -int sys_write(struct proc *, void *, register_t *); -int svr4_sys_open(struct proc *, void *, register_t *); -int sys_close(struct proc *, void *, register_t *); -int svr4_sys_wait(struct proc *, void *, register_t *); -int svr4_sys_creat(struct proc *, void *, register_t *); -int sys_link(struct proc *, void *, register_t *); -int sys_unlink(struct proc *, void *, register_t *); -int svr4_sys_execv(struct proc *, void *, register_t *); -int sys_chdir(struct proc *, void *, register_t *); -int svr4_sys_time(struct proc *, void *, register_t *); -int svr4_sys_mknod(struct proc *, void *, register_t *); -int sys_chmod(struct proc *, void *, register_t *); -int sys___posix_chown(struct proc *, void *, register_t *); -int svr4_sys_break(struct proc *, void *, register_t *); -int svr4_sys_stat(struct proc *, void *, register_t *); -int compat_43_sys_lseek(struct proc *, void *, register_t *); -int sys_getpid(struct proc *, void *, register_t *); -int sys_setuid(struct proc *, void *, register_t *); -int sys_getuid_with_euid(struct proc *, void *, register_t *); -int svr4_sys_alarm(struct proc *, void *, register_t *); -int svr4_sys_fstat(struct proc *, void *, register_t *); -int svr4_sys_pause(struct proc *, void *, register_t *); -int svr4_sys_utime(struct proc *, void *, register_t *); -int svr4_sys_access(struct proc *, void *, register_t *); -int svr4_sys_nice(struct proc *, void *, register_t *); -int sys_sync(struct proc *, void *, register_t *); -int svr4_sys_kill(struct proc *, void *, register_t *); -int svr4_sys_pgrpsys(struct proc *, void *, register_t *); -int sys_dup(struct proc *, void *, register_t *); -int sys_pipe(struct proc *, void *, register_t *); -int svr4_sys_times(struct proc *, void *, register_t *); -int sys_setgid(struct proc *, void *, register_t *); -int sys_getgid_with_egid(struct proc *, void *, register_t *); -int svr4_sys_signal(struct proc *, void *, register_t *); +int sys_nosys(struct lwp *, void *, register_t *); +int sys_exit(struct lwp *, void *, register_t *); +int sys_fork(struct lwp *, void *, register_t *); +int sys_read(struct lwp *, void *, register_t *); +int sys_write(struct lwp *, void *, register_t *); +int svr4_sys_open(struct lwp *, void *, register_t *); +int sys_close(struct lwp *, void *, register_t *); +int svr4_sys_wait(struct lwp *, void *, register_t *); +int svr4_sys_creat(struct lwp *, void *, register_t *); +int sys_link(struct lwp *, void *, register_t *); +int sys_unlink(struct lwp *, void *, register_t *); +int svr4_sys_execv(struct lwp *, void *, register_t *); +int sys_chdir(struct lwp *, void *, register_t *); +int svr4_sys_time(struct lwp *, void *, register_t *); +int svr4_sys_mknod(struct lwp *, void *, register_t *); +int sys_chmod(struct lwp *, void *, register_t *); +int sys___posix_chown(struct lwp *, void *, register_t *); +int svr4_sys_break(struct lwp *, void *, register_t *); +int svr4_sys_stat(struct lwp *, void *, register_t *); +int compat_43_sys_lseek(struct lwp *, void *, register_t *); +int sys_getpid(struct lwp *, void *, register_t *); +int sys_setuid(struct lwp *, void *, register_t *); +int sys_getuid_with_euid(struct lwp *, void *, register_t *); +int svr4_sys_alarm(struct lwp *, void *, register_t *); +int svr4_sys_fstat(struct lwp *, void *, register_t *); +int svr4_sys_pause(struct lwp *, void *, register_t *); +int svr4_sys_utime(struct lwp *, void *, register_t *); +int svr4_sys_access(struct lwp *, void *, register_t *); +int svr4_sys_nice(struct lwp *, void *, register_t *); +int sys_sync(struct lwp *, void *, register_t *); +int svr4_sys_kill(struct lwp *, void *, register_t *); +int svr4_sys_pgrpsys(struct lwp *, void *, register_t *); +int sys_dup(struct lwp *, void *, register_t *); +int sys_pipe(struct lwp *, void *, register_t *); +int svr4_sys_times(struct lwp *, void *, register_t *); +int sys_setgid(struct lwp *, void *, register_t *); +int sys_getgid_with_egid(struct lwp *, void *, register_t *); +int svr4_sys_signal(struct lwp *, void *, register_t *); #ifdef SYSVMSG -int svr4_sys_msgsys(struct proc *, void *, register_t *); +int svr4_sys_msgsys(struct lwp *, void *, register_t *); #else #endif -int svr4_sys_sysarch(struct proc *, void *, register_t *); +int svr4_sys_sysarch(struct lwp *, void *, register_t *); #ifdef SYSVSHM -int svr4_sys_shmsys(struct proc *, void *, register_t *); +int svr4_sys_shmsys(struct lwp *, void *, register_t *); #else #endif #ifdef SYSVSEM -int svr4_sys_semsys(struct proc *, void *, register_t *); +int svr4_sys_semsys(struct lwp *, void *, register_t *); #else #endif -int svr4_sys_ioctl(struct proc *, void *, register_t *); -int svr4_sys_utssys(struct proc *, void *, register_t *); -int sys_fsync(struct proc *, void *, register_t *); -int svr4_sys_execve(struct proc *, void *, register_t *); -int sys_umask(struct proc *, void *, register_t *); -int sys_chroot(struct proc *, void *, register_t *); -int svr4_sys_fcntl(struct proc *, void *, register_t *); -int svr4_sys_ulimit(struct proc *, void *, register_t *); -int sys_rmdir(struct proc *, void *, register_t *); -int sys_mkdir(struct proc *, void *, register_t *); -int svr4_sys_getdents(struct proc *, void *, register_t *); -int svr4_sys_getmsg(struct proc *, void *, register_t *); -int svr4_sys_putmsg(struct proc *, void *, register_t *); -int sys_poll(struct proc *, void *, register_t *); -int svr4_sys_lstat(struct proc *, void *, register_t *); -int sys_symlink(struct proc *, void *, register_t *); -int sys_readlink(struct proc *, void *, register_t *); -int sys_getgroups(struct proc *, void *, register_t *); -int sys_setgroups(struct proc *, void *, register_t *); -int sys_fchmod(struct proc *, void *, register_t *); -int sys___posix_fchown(struct proc *, void *, register_t *); -int svr4_sys_sigprocmask(struct proc *, void *, register_t *); -int svr4_sys_sigsuspend(struct proc *, void *, register_t *); -int svr4_sys_sigaltstack(struct proc *, void *, register_t *); -int svr4_sys_sigaction(struct proc *, void *, register_t *); -int svr4_sys_sigpending(struct proc *, void *, register_t *); -int svr4_sys_context(struct proc *, void *, register_t *); -int svr4_sys_statvfs(struct proc *, void *, register_t *); -int svr4_sys_fstatvfs(struct proc *, void *, register_t *); -int svr4_sys_waitsys(struct proc *, void *, register_t *); -int svr4_sys_hrtsys(struct proc *, void *, register_t *); -int svr4_sys_pathconf(struct proc *, void *, register_t *); -int svr4_sys_mmap(struct proc *, void *, register_t *); -int sys_mprotect(struct proc *, void *, register_t *); -int sys_munmap(struct proc *, void *, register_t *); -int svr4_sys_fpathconf(struct proc *, void *, register_t *); -int sys_vfork(struct proc *, void *, register_t *); -int sys_fchdir(struct proc *, void *, register_t *); -int sys_readv(struct proc *, void *, register_t *); -int sys_writev(struct proc *, void *, register_t *); -int svr4_sys_xstat(struct proc *, void *, register_t *); -int svr4_sys_lxstat(struct proc *, void *, register_t *); -int svr4_sys_fxstat(struct proc *, void *, register_t *); -int svr4_sys_xmknod(struct proc *, void *, register_t *); -int svr4_sys_setrlimit(struct proc *, void *, register_t *); -int svr4_sys_getrlimit(struct proc *, void *, register_t *); -int sys___posix_lchown(struct proc *, void *, register_t *); -int svr4_sys_memcntl(struct proc *, void *, register_t *); -int sys___posix_rename(struct proc *, void *, register_t *); -int svr4_sys_uname(struct proc *, void *, register_t *); -int sys_setegid(struct proc *, void *, register_t *); -int svr4_sys_sysconfig(struct proc *, void *, register_t *); -int sys_adjtime(struct proc *, void *, register_t *); -int svr4_sys_systeminfo(struct proc *, void *, register_t *); -int sys_seteuid(struct proc *, void *, register_t *); -int sys_fork(struct proc *, void *, register_t *); -int svr4_sys__lwp_info(struct proc *, void *, register_t *); -int sys_fchroot(struct proc *, void *, register_t *); -int svr4_sys_utimes(struct proc *, void *, register_t *); -int svr4_sys_vhangup(struct proc *, void *, register_t *); -int svr4_sys_gettimeofday(struct proc *, void *, register_t *); -int sys_getitimer(struct proc *, void *, register_t *); -int sys_setitimer(struct proc *, void *, register_t *); -int svr4_sys__lwp_create(struct proc *, void *, register_t *); -int svr4_sys__lwp_exit(struct proc *, void *, register_t *); -int svr4_sys__lwp_suspend(struct proc *, void *, register_t *); -int svr4_sys__lwp_continue(struct proc *, void *, register_t *); -int svr4_sys__lwp_kill(struct proc *, void *, register_t *); -int svr4_sys__lwp_self(struct proc *, void *, register_t *); -int svr4_sys__lwp_getprivate(struct proc *, void *, register_t *); -int svr4_sys__lwp_setprivate(struct proc *, void *, register_t *); -int svr4_sys__lwp_wait(struct proc *, void *, register_t *); -int svr4_sys_pread(struct proc *, void *, register_t *); -int svr4_sys_pwrite(struct proc *, void *, register_t *); -int svr4_sys_llseek(struct proc *, void *, register_t *); -int svr4_sys_acl(struct proc *, void *, register_t *); -int svr4_sys_auditsys(struct proc *, void *, register_t *); -int sys_nanosleep(struct proc *, void *, register_t *); -int svr4_sys_facl(struct proc *, void *, register_t *); -int sys_setreuid(struct proc *, void *, register_t *); -int sys_setregid(struct proc *, void *, register_t *); -int svr4_sys_resolvepath(struct proc *, void *, register_t *); -int svr4_sys_getdents64(struct proc *, void *, register_t *); -int svr4_sys_mmap64(struct proc *, void *, register_t *); -int svr4_sys_stat64(struct proc *, void *, register_t *); -int svr4_sys_lstat64(struct proc *, void *, register_t *); -int svr4_sys_fstat64(struct proc *, void *, register_t *); -int svr4_sys_statvfs64(struct proc *, void *, register_t *); -int svr4_sys_fstatvfs64(struct proc *, void *, register_t *); -int svr4_sys_setrlimit64(struct proc *, void *, register_t *); -int svr4_sys_getrlimit64(struct proc *, void *, register_t *); -int svr4_sys_pread64(struct proc *, void *, register_t *); -int svr4_sys_pwrite64(struct proc *, void *, register_t *); -int svr4_sys_creat64(struct proc *, void *, register_t *); -int svr4_sys_open64(struct proc *, void *, register_t *); -int svr4_sys_socket(struct proc *, void *, register_t *); -int sys_socketpair(struct proc *, void *, register_t *); -int sys_bind(struct proc *, void *, register_t *); -int sys_listen(struct proc *, void *, register_t *); -int compat_43_sys_accept(struct proc *, void *, register_t *); -int sys_connect(struct proc *, void *, register_t *); -int sys_shutdown(struct proc *, void *, register_t *); -int compat_43_sys_recv(struct proc *, void *, register_t *); -int compat_43_sys_recvfrom(struct proc *, void *, register_t *); -int compat_43_sys_recvmsg(struct proc *, void *, register_t *); -int compat_43_sys_send(struct proc *, void *, register_t *); -int compat_43_sys_sendmsg(struct proc *, void *, register_t *); -int sys_sendto(struct proc *, void *, register_t *); -int compat_43_sys_getpeername(struct proc *, void *, register_t *); -int compat_43_sys_getsockname(struct proc *, void *, register_t *); -int sys_getsockopt(struct proc *, void *, register_t *); -int sys_setsockopt(struct proc *, void *, register_t *); -int sys_ntp_gettime(struct proc *, void *, register_t *); +int svr4_sys_ioctl(struct lwp *, void *, register_t *); +int svr4_sys_utssys(struct lwp *, void *, register_t *); +int sys_fsync(struct lwp *, void *, register_t *); +int svr4_sys_execve(struct lwp *, void *, register_t *); +int sys_umask(struct lwp *, void *, register_t *); +int sys_chroot(struct lwp *, void *, register_t *); +int svr4_sys_fcntl(struct lwp *, void *, register_t *); +int svr4_sys_ulimit(struct lwp *, void *, register_t *); +int sys_rmdir(struct lwp *, void *, register_t *); +int sys_mkdir(struct lwp *, void *, register_t *); +int svr4_sys_getdents(struct lwp *, void *, register_t *); +int svr4_sys_getmsg(struct lwp *, void *, register_t *); +int svr4_sys_putmsg(struct lwp *, void *, register_t *); +int sys_poll(struct lwp *, void *, register_t *); +int svr4_sys_lstat(struct lwp *, void *, register_t *); +int sys_symlink(struct lwp *, void *, register_t *); +int sys_readlink(struct lwp *, void *, register_t *); +int sys_getgroups(struct lwp *, void *, register_t *); +int sys_setgroups(struct lwp *, void *, register_t *); +int sys_fchmod(struct lwp *, void *, register_t *); +int sys___posix_fchown(struct lwp *, void *, register_t *); +int svr4_sys_sigprocmask(struct lwp *, void *, register_t *); +int svr4_sys_sigsuspend(struct lwp *, void *, register_t *); +int svr4_sys_sigaltstack(struct lwp *, void *, register_t *); +int svr4_sys_sigaction(struct lwp *, void *, register_t *); +int svr4_sys_sigpending(struct lwp *, void *, register_t *); +int svr4_sys_context(struct lwp *, void *, register_t *); +int svr4_sys_statvfs(struct lwp *, void *, register_t *); +int svr4_sys_fstatvfs(struct lwp *, void *, register_t *); +int svr4_sys_waitsys(struct lwp *, void *, register_t *); +int svr4_sys_hrtsys(struct lwp *, void *, register_t *); +int svr4_sys_pathconf(struct lwp *, void *, register_t *); +int svr4_sys_mmap(struct lwp *, void *, register_t *); +int sys_mprotect(struct lwp *, void *, register_t *); +int sys_munmap(struct lwp *, void *, register_t *); +int svr4_sys_fpathconf(struct lwp *, void *, register_t *); +int sys_vfork(struct lwp *, void *, register_t *); +int sys_fchdir(struct lwp *, void *, register_t *); +int sys_readv(struct lwp *, void *, register_t *); +int sys_writev(struct lwp *, void *, register_t *); +int svr4_sys_xstat(struct lwp *, void *, register_t *); +int svr4_sys_lxstat(struct lwp *, void *, register_t *); +int svr4_sys_fxstat(struct lwp *, void *, register_t *); +int svr4_sys_xmknod(struct lwp *, void *, register_t *); +int svr4_sys_setrlimit(struct lwp *, void *, register_t *); +int svr4_sys_getrlimit(struct lwp *, void *, register_t *); +int sys___posix_lchown(struct lwp *, void *, register_t *); +int svr4_sys_memcntl(struct lwp *, void *, register_t *); +int sys___posix_rename(struct lwp *, void *, register_t *); +int svr4_sys_uname(struct lwp *, void *, register_t *); +int sys_setegid(struct lwp *, void *, register_t *); +int svr4_sys_sysconfig(struct lwp *, void *, register_t *); +int sys_adjtime(struct lwp *, void *, register_t *); +int svr4_sys_systeminfo(struct lwp *, void *, register_t *); +int sys_seteuid(struct lwp *, void *, register_t *); +int sys_fork(struct lwp *, void *, register_t *); +int svr4_sys__lwp_info(struct lwp *, void *, register_t *); +int sys_fchroot(struct lwp *, void *, register_t *); +int svr4_sys_utimes(struct lwp *, void *, register_t *); +int svr4_sys_vhangup(struct lwp *, void *, register_t *); +int svr4_sys_gettimeofday(struct lwp *, void *, register_t *); +int sys_getitimer(struct lwp *, void *, register_t *); +int sys_setitimer(struct lwp *, void *, register_t *); +int svr4_sys__lwp_create(struct lwp *, void *, register_t *); +int svr4_sys__lwp_exit(struct lwp *, void *, register_t *); +int svr4_sys__lwp_suspend(struct lwp *, void *, register_t *); +int svr4_sys__lwp_continue(struct lwp *, void *, register_t *); +int svr4_sys__lwp_kill(struct lwp *, void *, register_t *); +int svr4_sys__lwp_self(struct lwp *, void *, register_t *); +int svr4_sys__lwp_getprivate(struct lwp *, void *, register_t *); +int svr4_sys__lwp_setprivate(struct lwp *, void *, register_t *); +int svr4_sys__lwp_wait(struct lwp *, void *, register_t *); +int svr4_sys_pread(struct lwp *, void *, register_t *); +int svr4_sys_pwrite(struct lwp *, void *, register_t *); +int svr4_sys_llseek(struct lwp *, void *, register_t *); +int svr4_sys_acl(struct lwp *, void *, register_t *); +int svr4_sys_auditsys(struct lwp *, void *, register_t *); +int sys_nanosleep(struct lwp *, void *, register_t *); +int svr4_sys_facl(struct lwp *, void *, register_t *); +int sys_setreuid(struct lwp *, void *, register_t *); +int sys_setregid(struct lwp *, void *, register_t *); +int svr4_sys_resolvepath(struct lwp *, void *, register_t *); +int svr4_sys_getdents64(struct lwp *, void *, register_t *); +int svr4_sys_mmap64(struct lwp *, void *, register_t *); +int svr4_sys_stat64(struct lwp *, void *, register_t *); +int svr4_sys_lstat64(struct lwp *, void *, register_t *); +int svr4_sys_fstat64(struct lwp *, void *, register_t *); +int svr4_sys_statvfs64(struct lwp *, void *, register_t *); +int svr4_sys_fstatvfs64(struct lwp *, void *, register_t *); +int svr4_sys_setrlimit64(struct lwp *, void *, register_t *); +int svr4_sys_getrlimit64(struct lwp *, void *, register_t *); +int svr4_sys_pread64(struct lwp *, void *, register_t *); +int svr4_sys_pwrite64(struct lwp *, void *, register_t *); +int svr4_sys_creat64(struct lwp *, void *, register_t *); +int svr4_sys_open64(struct lwp *, void *, register_t *); +int svr4_sys_socket(struct lwp *, void *, register_t *); +int sys_socketpair(struct lwp *, void *, register_t *); +int sys_bind(struct lwp *, void *, register_t *); +int sys_listen(struct lwp *, void *, register_t *); +int compat_43_sys_accept(struct lwp *, void *, register_t *); +int sys_connect(struct lwp *, void *, register_t *); +int sys_shutdown(struct lwp *, void *, register_t *); +int compat_43_sys_recv(struct lwp *, void *, register_t *); +int compat_43_sys_recvfrom(struct lwp *, void *, register_t *); +int compat_43_sys_recvmsg(struct lwp *, void *, register_t *); +int compat_43_sys_send(struct lwp *, void *, register_t *); +int compat_43_sys_sendmsg(struct lwp *, void *, register_t *); +int sys_sendto(struct lwp *, void *, register_t *); +int compat_43_sys_getpeername(struct lwp *, void *, register_t *); +int compat_43_sys_getsockname(struct lwp *, void *, register_t *); +int sys_getsockopt(struct lwp *, void *, register_t *); +int sys_setsockopt(struct lwp *, void *, register_t *); +int sys_ntp_gettime(struct lwp *, void *, register_t *); #if defined(NTP) || !defined(_KERNEL) -int sys_ntp_adjtime(struct proc *, void *, register_t *); +int sys_ntp_adjtime(struct lwp *, void *, register_t *); #else #endif #endif /* _SVR4_SYS__SYSCALLARGS_H_ */ Index: sys/compat/svr4/svr4_syscalls.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_syscalls.c,v retrieving revision 1.67 retrieving revision 1.67.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.67 -r1.67.2.1 --- sys/compat/svr4/svr4_syscalls.c 2001/02/11 01:14:25 1.67 +++ sys/compat/svr4/svr4_syscalls.c 2001/03/05 22:49:31 1.67.2.1 @@ -3,9 +3,9 @@ /* * System call names. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.49 2001/01/27 07:59:58 thorpej Exp + * created from NetBSD: syscalls.master,v 1.50 2001/02/11 01:13:01 eeh Exp */ #if defined(_KERNEL) && !defined(_LKM) #if defined(_KERNEL) && !defined(_LKM) @@ -295,5 +295,11 @@ "ntp_adjtime", /* 249 = ntp_adjtime */ #else "#249 (excluded ntp_adjtime)", /* 249 = excluded ntp_adjtime */ #endif + "#250 (unimplemented lwp_mutex_unlock)", /* 250 = unimplemented lwp_mutex_unlock */ + "#251 (unimplemented lwp_mutex_trylock)", /* 251 = unimplemented lwp_mutex_trylock */ + "#252 (unimplemented lwp_mutex_init)", /* 252 = unimplemented lwp_mutex_init */ + "#253 (unimplemented cladm)", /* 253 = unimplemented cladm */ + "#254 (unimplemented lwp_sigtimedwait)", /* 254 = unimplemented lwp_sigtimedwait */ + "#255 (unimplemented umount2)", /* 255 = unimplemented umount2 */ }; Index: sys/compat/svr4/svr4_sysent.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_sysent.c,v retrieving revision 1.69 retrieving revision 1.69.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.69 -r1.69.2.1 --- sys/compat/svr4/svr4_sysent.c 2001/02/11 01:14:25 1.69 +++ sys/compat/svr4/svr4_sysent.c 2001/03/05 22:49:31 1.69.2.1 @@ -3,9 +3,9 @@ /* * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.49 2001/01/27 07:59:58 thorpej Exp + * created from NetBSD: syscalls.master,v 1.50 2001/02/11 01:13:01 eeh Exp */ #if defined(_KERNEL) && !defined(_LKM) #include "opt_ntp.h" @@ -550,17 +550,17 @@ { 0, 0, 0, sys_nosys }, /* 249 = excluded ntp_adjtime */ #endif { 0, 0, 0, - sys_nosys }, /* 250 = filler */ + sys_nosys }, /* 250 = unimplemented lwp_mutex_unlock */ { 0, 0, 0, - sys_nosys }, /* 251 = filler */ + sys_nosys }, /* 251 = unimplemented lwp_mutex_trylock */ { 0, 0, 0, - sys_nosys }, /* 252 = filler */ + sys_nosys }, /* 252 = unimplemented lwp_mutex_init */ { 0, 0, 0, - sys_nosys }, /* 253 = filler */ + sys_nosys }, /* 253 = unimplemented cladm */ { 0, 0, 0, - sys_nosys }, /* 254 = filler */ + sys_nosys }, /* 254 = unimplemented lwp_sigtimedwait */ { 0, 0, 0, - sys_nosys }, /* 255 = filler */ + sys_nosys }, /* 255 = unimplemented umount2 */ }; Index: sys/compat/svr4/svr4_ucontext.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/compat/svr4/svr4_ucontext.h,v retrieving revision 1.6 retrieving revision 1.6.20.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.6 -r1.6.20.1 --- sys/compat/svr4/svr4_ucontext.h 1999/01/26 18:41:03 1.6 +++ sys/compat/svr4/svr4_ucontext.h 2001/03/05 22:49:31 1.6.20.1 @@ -84,11 +84,13 @@ union svr4_siginfo sf_si; }; -void *svr4_getmcontext __P((struct proc *, struct svr4_mcontext *, u_long *)); -int svr4_setmcontext __P((struct proc *, struct svr4_mcontext *, u_long)); +void *svr4_getmcontext __P((struct lwp *, struct svr4_mcontext *, u_long *)); +int svr4_setmcontext __P((struct lwp *, struct svr4_mcontext *, u_long)); -void svr4_getcontext __P((struct proc *, struct svr4_ucontext *, sigset_t *)); -int svr4_setcontext __P((struct proc *, struct svr4_ucontext *)); +void svr4_getcontext __P((struct lwp *, struct svr4_ucontext *)); +int svr4_setcontext __P((struct lwp *, struct svr4_ucontext *)); #endif /* !_SVR4_UCONTEXT_H_ */ + + Index: sys/conf/files =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/conf/files,v retrieving revision 1.432 retrieving revision 1.427.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.432 -r1.427.2.2 --- sys/conf/files 2001/03/31 00:26:53 1.432 +++ sys/conf/files 2001/04/09 01:55:51 1.427.2.2 @@ -805,14 +805,16 @@ file kern/kern_kthread.c file kern/kern_ktrace.c file kern/kern_lkm.c lkm file kern/kern_lock.c +file kern/kern_lwp.c file kern/kern_malloc.c file kern/kern_ntptime.c file kern/kern_physio.c file kern/kern_proc.c file kern/kern_prot.c file kern/kern_resource.c +file kern/kern_sa.c file kern/kern_sig.c file kern/kern_subr.c file kern/kern_synch.c file kern/kern_sysctl.c Index: sys/conf/param.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/conf/param.c,v retrieving revision 1.37 retrieving revision 1.37.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.37 -r1.37.2.1 --- sys/conf/param.c 2000/11/11 02:24:55 1.37 +++ sys/conf/param.c 2001/03/05 22:49:32 1.37.2.1 @@ -48,8 +48,9 @@ #include #include #include #include +#include #include #include #include #include Index: sys/ddb/db_trap.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ddb/db_trap.c,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.17 -r1.17.2.1 --- sys/ddb/db_trap.c 2000/12/20 15:42:37 1.17 +++ sys/ddb/db_trap.c 2001/03/05 22:49:32 1.17.2.1 @@ -32,8 +32,9 @@ /* * Trap entry point to kernel debugger. */ #include +#include #include #include @@ -72,11 +73,12 @@ db_printf("Breakpoint"); else if (watchpt) db_printf("Watchpoint"); else - db_printf("Stopped"); - db_printf(" in pid %d (%s) at\t", curproc->p_pid, - curproc->p_comm); + if (curproc->l_proc == NULL) + db_printf("Stopped; curproc = %p, curproc->l_proc is NULL at\t", curproc); + else + db_printf("Stopped in %s at\t", curproc->l_proc->p_comm); } else if (bkpt) db_printf("Breakpoint at\t"); else if (watchpt) db_printf("Watchpoint at\t"); Index: sys/ddb/db_xxx.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ddb/db_xxx.c,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.11 -r1.11.2.1 --- sys/ddb/db_xxx.c 2000/11/28 21:44:34 1.11 +++ sys/ddb/db_xxx.c 2001/03/05 22:49:32 1.11.2.1 @@ -42,8 +42,9 @@ #include #include #include +#include #include #include #include @@ -106,20 +107,23 @@ db_expr_t count; char *modif; { int i; + char *mode; - struct proc *p, *pp; + struct proc *p, *pp, *cp; + struct lwp *l, *cl; struct timeval tv[3]; const struct proclist_desc *pd; if (modif[0] == 0) modif[0] = 'n'; /* default == normal mode */ - mode = strchr("mawn", modif[0]); + mode = strchr("mawln", modif[0]); if (mode == NULL || *mode == 'm') { db_printf("usage: show all procs [/a] [/n] [/w]\n"); db_printf("\t/a == show process address info\n"); + db_printf("\t/l == show LWP info\n"); db_printf("\t/n == show normal process info [default]\n"); db_printf("\t/w == show process wait/emul info\n"); return; } @@ -129,11 +133,15 @@ case 'a': db_printf(" PID %10s %18s %18s %18s\n", "COMMAND", "STRUCT PROC *", "UAREA *", "VMSPACE/VM_MAP"); break; + case 'l': + db_printf(" PID %4s S %7s %18s %18s %-12s\n", + "LID", "FLAGS", "STRUCT LWP *", "UAREA *", "WAIT"); + break; case 'n': - db_printf(" PID %10s %10s %10s S %7s %16s %7s\n", - "PPID", "PGRP", "UID", "FLAGS", "COMMAND", "WAIT"); + db_printf(" PID %8s %8s %10s S %7s %4s %16s %7s\n", + "PPID", "PGRP", "UID", "FLAGS", "LWPS", "COMMAND", "WAIT"); break; case 'w': db_printf(" PID %10s %8s %4s %5s %5s %-12s%s\n", "COMMAND", "EMUL", "PRI", "UTIME", "STIME", @@ -142,44 +150,64 @@ } /* XXX LOCKING XXX */ pd = proclists; + cp = curproc ? curproc->l_proc : 0; + cl = curproc; loop: for (p = LIST_FIRST(pd->pd_list); p != NULL; p = LIST_NEXT(p, p_list)) { pp = p->p_pptr; if (p->p_stat) { - - db_printf("%c%-10d", " >"[curproc == p], p->p_pid); + l = LIST_FIRST(&p->p_lwps); + db_printf("%c%-10d", " >"[cp == p], p->p_pid); switch (*mode) { case 'a': db_printf("%10.10s %18p %18p %18p\n", - p->p_comm, p, p->p_addr, p->p_vmspace); + p->p_comm, p, l->l_addr, p->p_vmspace); break; - + case 'l': + do { + db_printf("%c%4d %d %#7x %18p %18p %s\n", + " >"[cl == l], l->l_lid, + l->l_stat, l->l_flag, l, + l->l_addr, + (l->l_wchan && l->l_wmesg) ? + l->l_wmesg : ""); + + l = LIST_NEXT(l, l_sibling); + if (l) + db_printf("%11s",""); + } while (l != NULL); + break; case 'n': - db_printf("%10d %10d %10d %d %#7x %16s %7.7s\n", + db_printf("%8d %8d %10d %d %#7x %4d %16s %7.7s\n", pp ? pp->p_pid : -1, p->p_pgrp->pg_id, p->p_cred->p_ruid, p->p_stat, p->p_flag, - p->p_comm, (p->p_wchan && p->p_wmesg) ? - p->p_wmesg : ""); + p->p_nlwps, p->p_comm, + (p->p_nlwps > 1) ? "*" : ( + (l->l_wchan && l->l_wmesg) ? + l->l_wmesg : "")); break; case 'w': db_printf("%10s %8s %4d", p->p_comm, - p->p_emul->e_name,p->p_priority); + p->p_emul->e_name,l->l_priority); calcru(p, tv+0, tv+1, tv+2); for(i = 0; i < 2; ++i) { db_printf("%4ld.%1ld", (long)tv[i].tv_sec, (long)tv[i].tv_usec/100000); } - if(p->p_wchan && p->p_wmesg) { - db_printf(" %-12s", p->p_wmesg); - db_printsym((db_expr_t)p->p_wchan, + if(p->p_nlwps <= 1) { + if(l->l_wchan && l->l_wmesg) { + db_printf(" %-12s", l->l_wmesg); + db_printsym((db_expr_t)l->l_wchan, DB_STGY_XTRN, db_printf); + } } else { + db_printf(" * "); } db_printf("\n"); break; Index: sys/dev/ccd.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/dev/ccd.c,v retrieving revision 1.71 retrieving revision 1.71.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.71 -r1.71.2.1 --- sys/dev/ccd.c 2001/01/08 02:03:46 1.71 +++ sys/dev/ccd.c 2001/03/05 22:49:33 1.71.2.1 @@ -1246,18 +1246,18 @@ part = DISKPART(dev); omask = cs->sc_dkdev.dk_openmask & (1 << part); lp = cs->sc_dkdev.dk_label; - if (omask == 0 && ccdopen(dev, 0, S_IFBLK, curproc)) + if (omask == 0 && ccdopen(dev, 0, S_IFBLK, curproc->l_proc)) return (-1); if (lp->d_partitions[part].p_fstype != FS_SWAP) size = -1; else size = lp->d_partitions[part].p_size * (lp->d_secsize / DEV_BSIZE); - if (omask == 0 && ccdclose(dev, 0, S_IFBLK, curproc)) + if (omask == 0 && ccdclose(dev, 0, S_IFBLK, curproc->l_proc)) return (-1); return (size); } Index: sys/dev/vnd.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/dev/vnd.c,v retrieving revision 1.71 retrieving revision 1.71.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.71 -r1.71.2.1 --- sys/dev/vnd.c 2001/01/08 02:03:46 1.71 +++ sys/dev/vnd.c 2001/03/05 22:49:33 1.71.2.1 @@ -101,8 +101,9 @@ #include #include #include +#include #include #include #include #include @@ -1026,9 +1027,9 @@ * incoherencies. Also, be careful to write dirty * buffers back to stable storage. */ error = vinvalbuf(vnd->sc_vp, V_SAVE, vnd->sc_cred, - curproc, 0, 0); + curproc->l_proc, 0, 0); } VOP_UNLOCK(vnd->sc_vp, 0); free(tmpbuf, M_TEMP); @@ -1070,9 +1071,9 @@ vndclear(vnd) struct vnd_softc *vnd; { struct vnode *vp = vnd->sc_vp; - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ #ifdef DEBUG if (vnddebug & VDB_FOLLOW) printf("vndclear(%p): vp %p\n", vnd, vp); @@ -1107,18 +1108,18 @@ part = DISKPART(dev); omask = sc->sc_dkdev.dk_openmask & (1 << part); lp = sc->sc_dkdev.dk_label; - if (omask == 0 && vndopen(dev, 0, S_IFBLK, curproc)) + if (omask == 0 && vndopen(dev, 0, S_IFBLK, curproc->l_proc)) return (-1); if (lp->d_partitions[part].p_fstype != FS_SWAP) size = -1; else size = lp->d_partitions[part].p_size * (lp->d_secsize / DEV_BSIZE); - if (omask == 0 && vndclose(dev, 0, S_IFBLK, curproc)) + if (omask == 0 && vndclose(dev, 0, S_IFBLK, curproc->l_proc)) return (-1); return (size); } Index: sys/dev/i2o/iop.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/dev/i2o/iop.c,v retrieving revision 1.13 retrieving revision 1.10.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.13 -r1.10.2.2 --- sys/dev/i2o/iop.c 2001/04/01 15:02:08 1.13 +++ sys/dev/i2o/iop.c 2001/04/09 01:56:00 1.10.2.2 @@ -524,22 +524,24 @@ static void iop_reconf_thread(void *cookie) { struct iop_softc *sc; + struct lwp *l; struct i2o_lct lct; u_int32_t chgind; int rv; sc = cookie; chgind = sc->sc_chgind + 1; + l = curproc; for (;;) { DPRINTF(("%s: async reconfig: requested 0x%08x\n", sc->sc_dv.dv_xname, chgind)); - PHOLD(sc->sc_reconf_proc); + PHOLD(l); rv = iop_lct_get0(sc, &lct, sizeof(lct), chgind); - PRELE(sc->sc_reconf_proc); + PRELE(l); DPRINTF(("%s: async reconfig: notified (0x%08x, %d)\n", sc->sc_dv.dv_xname, le32toh(lct.changeindicator), rv)); Index: sys/dev/i2o/iopsp.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/dev/i2o/iopsp.c,v retrieving revision 1.6 retrieving revision 1.4.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.6 -r1.4.2.2 --- sys/dev/i2o/iopsp.c 2001/04/01 15:02:08 1.6 +++ sys/dev/i2o/iopsp.c 2001/04/09 01:56:02 1.4.2.2 @@ -47,8 +47,9 @@ #include #include #include #include +#include #include #include #include #include Index: sys/dev/ic/an.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/dev/ic/an.c,v retrieving revision 1.11 retrieving revision 1.10.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.11 -r1.10.2.2 --- sys/dev/ic/an.c 2001/03/08 16:33:43 1.11 +++ sys/dev/ic/an.c 2001/04/09 01:56:08 1.10.2.2 @@ -1082,9 +1082,10 @@ } error = copyout(&areq, ifr->ifr_data, sizeof(areq)); break; case SIOCSAIRONET: - if ((error = suser(curproc->p_ucred, &curproc->p_acflag))) + if ((error = suser(curproc->l_proc->p_ucred, + &curproc->l_proc->p_acflag))) goto out; error = copyin(ifr->ifr_data, &areq, sizeof(areq)); if (error) break; @@ -1152,9 +1153,10 @@ nwkey->i_defkid = 1; if (nwkey->i_key[0].i_keydat == NULL) break; /* do not show any keys to non-root user */ - if ((error = suser(curproc->p_ucred, &curproc->p_acflag)) != 0) + if ((error = suser(curproc->l_proc->p_ucred, + &curproc->l_proc->p_acflag)) != 0) break; akey = &sc->an_temp_keys; nwkey->i_key[0].i_keylen = akey->an_key_len; for (i = 1; i < IEEE80211_WEP_NKID; i++) Index: sys/dev/ic/awi_wep.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/dev/ic/awi_wep.c,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.5 -r1.5.2.1 --- sys/dev/ic/awi_wep.c 2001/01/18 20:28:18 1.5 +++ sys/dev/ic/awi_wep.c 2001/03/05 22:49:34 1.5.2.1 @@ -53,8 +53,9 @@ #include #include #include #include +#include #include #include #include #include @@ -190,9 +191,9 @@ /* do not show any keys to non-root user */ #ifdef __FreeBSD__ suerr = suser(curproc); #else - suerr = suser(curproc->p_ucred, &curproc->p_acflag); + suerr = suser(curproc->l_proc->p_ucred, &curproc->l_proc->p_acflag); #endif error = 0; for (i = 0; i < IEEE80211_WEP_NKID; i++) { if (nwkey->i_key[i].i_keydat == NULL) Index: sys/dev/ic/awi_wicfg.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/dev/ic/awi_wicfg.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.3 -r1.3.4.1 --- sys/dev/ic/awi_wicfg.c 2000/07/06 17:22:25 1.3 +++ sys/dev/ic/awi_wicfg.c 2001/03/05 22:49:34 1.3.4.1 @@ -44,8 +44,9 @@ #include #include #include #include +#include #include #include #include #include @@ -109,9 +110,10 @@ case SIOCSWAVELAN: #ifdef __FreeBSD__ error = suser(curproc); #else - error = suser(curproc->p_ucred, &curproc->p_acflag); + error = suser(curproc->l_proc->p_ucred, + &curproc->l_proc->p_acflag); #endif if (error) break; error = awi_cfgset(ifp, cmd, data); @@ -273,9 +275,10 @@ /* do not show keys to non-root user */ #ifdef __FreeBSD__ error = suser(curproc); #else - error = suser(curproc->p_ucred, &curproc->p_acflag); + error = suser(curproc->l_proc->p_ucred, + &curproc->l_proc->p_acflag); #endif if (error) { memset(keys, 0, sizeof(*keys)); error = 0; Index: sys/dev/ic/com.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/dev/ic/com.c,v retrieving revision 1.183 retrieving revision 1.183.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.183 -r1.183.2.1 --- sys/dev/ic/com.c 2001/01/14 23:50:28 1.183 +++ sys/dev/ic/com.c 2001/03/05 22:49:34 1.183.2.1 @@ -2411,8 +2411,10 @@ int rate, frequency; tcflag_t cflag; { int res; + + printf("com_kgdb_attach\n"); if (iot == comconstag && iobase == comconsaddr) return (EBUSY); /* cannot share with console */ Index: sys/dev/ic/midway.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/dev/ic/midway.c,v retrieving revision 1.48 retrieving revision 1.48.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.48 -r1.48.2.1 --- sys/dev/ic/midway.c 2000/12/18 20:23:04 1.48 +++ sys/dev/ic/midway.c 2001/03/05 22:49:35 1.48.2.1 @@ -1295,9 +1295,10 @@ case SIOCSPVCSIF: if (ifp == &sc->enif) { struct ifnet *sifp; - if ((error = suser(curproc->p_ucred, &curproc->p_acflag)) != 0) + if ((error = suser(curproc->l_proc->p_ucred, + &curproc->l_proc->p_acflag)) != 0) break; if ((sifp = en_pvcattach(ifp)) != NULL) { #ifdef __NetBSD__ @@ -1322,9 +1323,10 @@ error = en_pvctxget(sc, (struct pvctxreq *)data); break; case SIOCSPVCTX: - if ((error = suser(curproc->p_ucred, &curproc->p_acflag)) == 0) + if ((error = suser(curproc->l_proc->p_ucred, + &curproc->l_proc->p_acflag)) == 0) error = en_pvctx(sc, (struct pvctxreq *)data); break; #endif /* ATM_PVCEXT */ Index: sys/dev/ic/rrunner.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/dev/ic/rrunner.c,v retrieving revision 1.22 retrieving revision 1.21.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.22 -r1.21.2.2 --- sys/dev/ic/rrunner.c 2001/03/15 06:10:55 1.22 +++ sys/dev/ic/rrunner.c 2001/04/09 01:56:27 1.21.2.2 @@ -56,8 +56,9 @@ #include #include #include #include +#include #include #include #include @@ -998,9 +999,10 @@ dev_t dev; struct uio *uio; int ioflag; { - struct proc *p = curproc; + struct lwp *l = curproc; + struct proc *p = l->l_proc; struct iovec *iovp; struct esh_softc *sc; struct esh_fp_ring_ctl *ring; struct esh_dmainfo *di; @@ -1036,9 +1038,9 @@ goto fpread_done; } } - PHOLD(p); /* Lock process info into memory */ + PHOLD(l); /* Lock process info into memory */ /* Lock down the pages */ for (i = 0; i < uio->uio_iovcnt; i++) { iovp = &uio->uio_iov[i]; @@ -1140,9 +1142,9 @@ iovp = &uio->uio_iov[i]; uvm_vsunlock(p, iovp->iov_base, iovp->iov_len); } - PRELE(p); /* Release process info */ + PRELE(l); /* Release process info */ esh_free_dmainfo(sc, di); fpread_done: #ifdef ESH_PRINTF @@ -1158,9 +1160,10 @@ dev_t dev; struct uio *uio; int ioflag; { - struct proc *p = curproc; + struct lwp *l = curproc; + struct proc *p = l->l_proc; struct iovec *iovp; struct esh_softc *sc; struct esh_send_ring_ctl *ring; struct esh_dmainfo *di; @@ -1196,9 +1199,9 @@ goto fpwrite_done; } } - PHOLD(p); /* Lock process info into memory */ + PHOLD(l); /* Lock process info into memory */ /* Lock down the pages */ for (i = 0; i < uio->uio_iovcnt; i++) { iovp = &uio->uio_iov[i]; @@ -1296,9 +1299,9 @@ iovp = &uio->uio_iov[i]; uvm_vsunlock(p, iovp->iov_base, iovp->iov_len); } - PRELE(p); /* Release process info */ + PRELE(l); /* Release process info */ esh_free_dmainfo(sc, di); fpwrite_done: #ifdef ESH_PRINTF Index: sys/dev/pcmcia/if_cnw.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/dev/pcmcia/if_cnw.c,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.17 -r1.17.2.1 --- sys/dev/pcmcia/if_cnw.c 2000/12/14 06:29:37 1.17 +++ sys/dev/pcmcia/if_cnw.c 2001/03/05 22:49:36 1.17.2.1 @@ -120,8 +120,9 @@ #include #include #include #include +#include #include #include @@ -1043,9 +1044,9 @@ struct cnw_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; int s, error = 0; - struct proc *p = curproc; /*XXX*/ + struct proc *p = curproc->l_proc; /*XXX*/ s = splnet(); switch (cmd) { Index: sys/dev/pcmcia/if_wi.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/dev/pcmcia/if_wi.c,v retrieving revision 1.59 retrieving revision 1.57.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.59 -r1.57.2.2 --- sys/dev/pcmcia/if_wi.c 2001/03/18 21:13:12 1.59 +++ sys/dev/pcmcia/if_wi.c 2001/04/09 01:57:16 1.57.2.2 @@ -83,8 +83,9 @@ #include #include #include #include /* for hz */ +#include #include #if NRND > 0 #include @@ -1401,9 +1402,9 @@ int s, error = 0; struct wi_softc *sc = ifp->if_softc; struct wi_req wreq; struct ifreq *ifr; - struct proc *p = curproc; + struct proc *p = curproc->l_proc; struct ieee80211_nwid nwid; if ((sc->sc_dev.dv_flags & DVF_ACTIVE) == 0) return (ENXIO); @@ -2091,9 +2092,9 @@ nwkey->i_wepon = sc->wi_use_wep; nwkey->i_defkid = sc->wi_tx_key + 1; /* do not show any keys to non-root user */ - error = suser(curproc->p_ucred, &curproc->p_acflag); + error = suser(curproc->l_proc->p_ucred, &curproc->l_proc->p_acflag); for (i = 0; i < IEEE80211_WEP_NKID; i++) { if (nwkey->i_key[i].i_keydat == NULL) continue; /* error holds results of suser() for the first time */ Index: sys/dev/scsipi/scsiconf.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/dev/scsipi/scsiconf.c,v retrieving revision 1.156 retrieving revision 1.156.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.156 -r1.156.2.1 --- sys/dev/scsipi/scsiconf.c 2001/02/26 22:31:27 1.156 +++ sys/dev/scsipi/scsiconf.c 2001/03/05 22:49:36 1.156.2.1 @@ -57,8 +57,9 @@ #include #include #include #include +#include #include #include #include #include @@ -359,9 +360,9 @@ * oppertunity to re-scan it before we do. */ if (sc_link->adapter->scsipi_ioctl != NULL) (*sc_link->adapter->scsipi_ioctl)(sc_link, SCBUSIOLLSCAN, NULL, - 0, curproc); + 0, curproc->l_proc); if ((error = scsipi_adapter_addref(sc_link)) != 0) return (error); for (target = mintarget; target <= maxtarget; target++) { @@ -887,9 +888,10 @@ s.sa_flags |= SC_ACCEL_SYNC; if ((sc_link->quirks & SDEV_NOWIDE) == 0) s.sa_flags |= SC_ACCEL_WIDE; (void) (*sc_link->adapter->scsipi_ioctl) - (sc_link, SCBUSACCEL, (caddr_t)&s, FWRITE, curproc); + (sc_link, SCBUSACCEL, (caddr_t)&s, FWRITE, + curproc->l_proc); } } if ((cf = config_search(scsibussubmatch, (struct device *)scsi, Index: sys/dev/scsipi/scsipiconf.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/dev/scsipi/scsipiconf.c,v retrieving revision 1.12 retrieving revision 1.12.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.12 -r1.12.2.1 --- sys/dev/scsipi/scsipiconf.c 2000/12/31 17:54:29 1.12 +++ sys/dev/scsipi/scsipiconf.c 2001/03/05 22:49:37 1.12.2.1 @@ -57,8 +57,9 @@ #include #include #include #include +#include #include #include Index: sys/dev/wscons/wsdisplay_compat_usl.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/dev/wscons/wsdisplay_compat_usl.c,v retrieving revision 1.15 retrieving revision 1.15.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.15 -r1.15.2.1 --- sys/dev/wscons/wsdisplay_compat_usl.c 2000/09/10 10:43:53 1.15 +++ sys/dev/wscons/wsdisplay_compat_usl.c 2001/03/05 22:49:37 1.15.2.1 @@ -39,8 +39,9 @@ #include #include #include #include +#include #include #include #include #include @@ -436,9 +437,10 @@ case KDDISABIO: #if defined(__i386__) #if defined(COMPAT_10) || defined(COMPAT_11) || defined(COMPAT_FREEBSD) { - struct trapframe *fp = (struct trapframe *)p->p_md.md_regs; + /* XXX NJWLWP */ + struct trapframe *fp = (struct trapframe *)curproc->l_md.md_regs; if (cmd == KDENABIO) fp->tf_eflags |= PSL_IOPL; else fp->tf_eflags &= ~PSL_IOPL; Index: sys/isofs/cd9660/cd9660_vfsops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/isofs/cd9660/cd9660_vfsops.c,v retrieving revision 1.53 retrieving revision 1.52.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.53 -r1.52.2.2 --- sys/isofs/cd9660/cd9660_vfsops.c 2001/03/23 21:10:48 1.53 +++ sys/isofs/cd9660/cd9660_vfsops.c 2001/04/09 01:57:49 1.52.2.2 @@ -46,8 +46,9 @@ #include #include #include +#include #include #include #include #include @@ -114,9 +115,9 @@ int cd9660_mountroot() { struct mount *mp; - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ int error; struct iso_args args; if (root_device->dv_class != DV_DISK) Index: sys/kern/init_main.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/init_main.c,v retrieving revision 1.189 retrieving revision 1.188.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.189 -r1.188.2.2 --- sys/kern/init_main.c 2001/03/15 06:10:55 1.189 +++ sys/kern/init_main.c 2001/04/09 01:57:51 1.188.2.2 @@ -58,8 +58,9 @@ #include #include #include #include +#include #include #include #include #include @@ -118,16 +119,18 @@ /* Components of the first process -- never freed. */ struct session session0; struct pgrp pgrp0; struct proc proc0; +struct lwp lwp0; struct pcred cred0; struct filedesc0 filedesc0; struct cwdinfo cwdi0; struct plimit limit0; +struct pstats pstat0; struct vmspace vmspace0; struct sigacts sigacts0; #ifndef curproc -struct proc *curproc = &proc0; +struct lwp *curproc = &lwp0; #endif struct proc *initproc; int cmask = CMASK; @@ -154,8 +157,9 @@ */ void main(void) { + struct lwp *l; struct proc *p; struct pdevinit *pdev; int i, s, error; rlim_t lim; @@ -172,11 +176,12 @@ /* * Initialize the current process pointer (curproc) before * any possible traps/probes to simplify trap processing. */ - p = &proc0; - curproc = p; - p->p_cpu = curcpu(); + l = &lwp0; + curproc = l; + l->l_cpu = curcpu(); + l->l_proc = &proc0; /* * Attempt to find console and initialize * in case of early panic or other messages. */ @@ -221,11 +226,17 @@ /* * Create process 0 (the swapper). */ + p = &proc0; + LIST_INIT(&p->p_lwps); + LIST_INSERT_HEAD(&p->p_lwps, l, l_sibling); + p->p_nlwps = 1; + s = proclist_lock_write(); LIST_INSERT_HEAD(&allproc, p, p_list); LIST_INSERT_HEAD(PIDHASH(p->p_pid), p, p_hash); + LIST_INSERT_HEAD(&alllwp, l, l_list); proclist_unlock_write(s); p->p_pgrp = &pgrp0; LIST_INSERT_HEAD(PGRPHASH(0), &pgrp0, pg_hash); @@ -241,19 +252,23 @@ * Set P_NOCLDWAIT so that kernel threads are reparented to * init(8) when they exit. init(8) can easily wait them out * for us. */ - p->p_flag = P_INMEM | P_SYSTEM | P_NOCLDWAIT; - p->p_stat = SONPROC; + p->p_flag = P_SYSTEM | P_NOCLDWAIT; + p->p_stat = SACTIVE; p->p_nice = NZERO; p->p_emul = &emul_netbsd; #ifdef __HAVE_SYSCALL_INTERN (*p->p_emul->e_syscall_intern)(p); #endif strncpy(p->p_comm, "swapper", MAXCOMLEN); + l->l_flag = L_INMEM; + l->l_stat = LSONPROC; + + callout_init(&p->p_realit_ch); - callout_init(&p->p_tsleep_ch); + callout_init(&l->l_tsleep_ch); /* Create credentials. */ cred0.p_refcnt = 1; p->p_cred = &cred0; @@ -299,15 +314,11 @@ uvmspace_init(&vmspace0, pmap_kernel(), round_page(VM_MIN_ADDRESS), trunc_page(VM_MAX_ADDRESS), TRUE); p->p_vmspace = &vmspace0; - p->p_addr = proc0paddr; /* XXX */ + l->l_addr = proc0paddr; /* XXX */ - /* - * We continue to place resource usage info in the - * user struct so they're pageable. - */ - p->p_stats = &p->p_addr->u_stats; + p->p_stats = &pstat0; /* * Charge root for one process. */ @@ -387,9 +398,9 @@ * Note that process 1 won't immediately exec init(8), but will * wait for us to inform it that the root file system has been * mounted. */ - if (fork1(p, 0, SIGCHLD, NULL, 0, start_init, NULL, NULL, &initproc)) + if (fork1(l, 0, SIGCHLD, NULL, 0, start_init, NULL, NULL, &initproc)) panic("fork init"); /* * Create any kernel threads who's creation was deferred because @@ -457,10 +468,12 @@ s = splsched(); for (p = LIST_FIRST(&allproc); p != NULL; p = LIST_NEXT(p, p_list)) { p->p_stats->p_start = mono_time = boottime = time; - if (p->p_cpu != NULL) - p->p_cpu->ci_schedstate.spc_runtime = time; + for (l = LIST_FIRST(&p->p_lwps); l != NULL; + l = LIST_NEXT(l, l_sibling)) + if (l->l_cpu != NULL) + l->l_cpu->ci_schedstate.spc_runtime = time; p->p_rtime.tv_sec = p->p_rtime.tv_usec = 0; } splx(s); proclist_unlock_read(); @@ -544,9 +557,10 @@ */ static void start_init(void *arg) { - struct proc *p = arg; + struct lwp *l = arg; + struct proc *p = l->l_proc; vaddr_t addr; struct sys_execve_args /* { syscallarg(const char *) path; syscallarg(char * const *) argp; @@ -657,9 +671,9 @@ /* * Now try to exec the program. If can't for any reason * other than it doesn't exist, complain. */ - error = sys_execve(p, &args, retval); + error = sys_execve(LIST_FIRST(&p->p_lwps), &args, retval); if (error == 0 || error == EJUSTRETURN) { KERNEL_PROC_UNLOCK(p); return; } Index: sys/kern/init_sysent.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/init_sysent.c,v retrieving revision 1.124 retrieving revision 1.124.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.124 -r1.124.2.1 --- sys/kern/init_sysent.c 2001/01/27 07:48:28 1.124 +++ sys/kern/init_sysent.c 2001/03/05 22:49:38 1.124.2.1 @@ -811,25 +811,25 @@ { 0, 0, 0, sys_issetugid }, /* 305 = issetugid */ { 3, s(struct sys_utrace_args), 0, sys_utrace }, /* 306 = utrace */ + { 1, s(struct sys_getcontext_args), 0, + sys_getcontext }, /* 307 = getcontext */ + { 1, s(struct sys_setcontext_args), 0, + sys_setcontext }, /* 308 = setcontext */ + { 3, s(struct sys__lwp_create_args), 0, + sys__lwp_create }, /* 309 = _lwp_create */ + { 0, 0, 0, + sys__lwp_exit }, /* 310 = _lwp_exit */ + { 0, 0, 0, + sys__lwp_self }, /* 311 = _lwp_self */ + { 2, s(struct sys__lwp_wait_args), 0, + sys__lwp_wait }, /* 312 = _lwp_wait */ + { 1, s(struct sys__lwp_suspend_args), 0, + sys__lwp_suspend }, /* 313 = _lwp_suspend */ + { 1, s(struct sys__lwp_continue_args), 0, + sys__lwp_continue }, /* 314 = _lwp_continue */ { 0, 0, 0, - sys_nosys }, /* 307 = unimplemented */ - { 0, 0, 0, - sys_nosys }, /* 308 = unimplemented */ - { 0, 0, 0, - sys_nosys }, /* 309 = unimplemented */ - { 0, 0, 0, - sys_nosys }, /* 310 = unimplemented */ - { 0, 0, 0, - sys_nosys }, /* 311 = unimplemented */ - { 0, 0, 0, - sys_nosys }, /* 312 = unimplemented */ - { 0, 0, 0, - sys_nosys }, /* 313 = unimplemented */ - { 0, 0, 0, - sys_nosys }, /* 314 = unimplemented */ - { 0, 0, 0, sys_nosys }, /* 315 = unimplemented */ { 0, 0, 0, sys_nosys }, /* 316 = unimplemented */ { 0, 0, 0, @@ -857,20 +857,20 @@ { 0, 0, 0, sys_nosys }, /* 328 = unimplemented */ { 0, 0, 0, sys_nosys }, /* 329 = unimplemented */ - { 0, 0, 0, - sys_nosys }, /* 330 = unimplemented */ - { 0, 0, 0, - sys_nosys }, /* 331 = unimplemented */ - { 0, 0, 0, - sys_nosys }, /* 332 = unimplemented */ - { 0, 0, 0, - sys_nosys }, /* 333 = unimplemented */ - { 0, 0, 0, - sys_nosys }, /* 334 = unimplemented */ - { 0, 0, 0, - sys_nosys }, /* 335 = unimplemented */ + { 2, s(struct sys_sa_register_args), 0, + sys_sa_register }, /* 330 = sa_register */ + { 2, s(struct sys_sa_stacks_args), 0, + sys_sa_stacks }, /* 331 = sa_stacks */ + { 0, 0, 0, + sys_sa_enable }, /* 332 = sa_enable */ + { 1, s(struct sys_sa_setconcurrency_args), 0, + sys_sa_setconcurrency }, /* 333 = sa_setconcurrency */ + { 0, 0, 0, + sys_sa_yield }, /* 334 = sa_yield */ + { 1, s(struct sys_sa_preempt_args), 0, + sys_sa_preempt }, /* 335 = sa_preempt */ { 0, 0, 0, sys_nosys }, /* 336 = unimplemented */ { 0, 0, 0, sys_nosys }, /* 337 = unimplemented */ Index: sys/kern/kern_acct.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_acct.c,v retrieving revision 1.49 retrieving revision 1.49.6.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.49 -r1.49.6.1 --- sys/kern/kern_acct.c 2000/05/08 19:06:36 1.49 +++ sys/kern/kern_acct.c 2001/03/05 22:49:38 1.49.6.1 @@ -42,8 +42,9 @@ */ #include #include +#include #include #include #include #include @@ -181,18 +182,19 @@ * Accounting system call. Written based on the specification and * previous implementation done by Mark Tinguely. */ int -sys_acct(p, v, retval) - struct proc *p; +sys_acct(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_acct_args /* { syscallarg(const char *) path; } */ *uap = v; struct nameidata nd; int error; + struct proc *p = l->l_proc; /* Make sure that the caller is root. */ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) return (error); Index: sys/kern/kern_clock.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_clock.c,v retrieving revision 1.74 retrieving revision 1.74.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.74 -r1.74.2.1 --- sys/kern/kern_clock.c 2001/01/17 18:21:41 1.74 +++ sys/kern/kern_clock.c 2001/03/05 22:49:38 1.74.2.1 @@ -83,8 +83,9 @@ #include #include #include #include +#include #include #include #include #include @@ -508,8 +509,9 @@ */ void hardclock(struct clockframe *frame) { + struct lwp *l; struct proc *p; int delta; extern int tickdelta; extern long timedelta; @@ -518,12 +520,12 @@ int time_update; int ltemp; #endif - p = curproc; - if (p) { + l = curproc; + if (l) { struct pstats *pstats; - + p = l->l_proc; /* * Run current process's virtual and profile time, as needed. */ pstats = p->p_stats; @@ -1263,8 +1265,9 @@ intptr_t i; #endif struct cpu_info *ci = curcpu(); struct schedstate_percpu *spc = &ci->ci_schedstate; + struct lwp *l; struct proc *p; /* * Notice changes in divisor frequency, and adjust clock @@ -1278,9 +1281,10 @@ } else { setstatclockrate(profhz); } } - p = curproc; + l = curproc; + p = (l ? l->l_proc : 0); if (CLKF_USERMODE(frame)) { if (p->p_flag & P_PROFIL) addupc_intr(p, CLKF_PC(frame)); if (--spc->spc_pscnt > 0) @@ -1307,11 +1311,11 @@ g->kcount[i]++; } } #endif -#ifdef PROC_PC +#ifdef LWP_PC if (p && p->p_flag & P_PROFIL) - addupc_intr(p, PROC_PC(p)); + addupc_intr(p, LWP_PC(l)); #endif if (--spc->spc_pscnt > 0) return; /* @@ -1337,17 +1341,17 @@ spc->spc_cp_time[CP_IDLE]++; } spc->spc_pscnt = psdiv; - if (p != NULL) { + if (l != NULL) { ++p->p_cpticks; /* * If no separate schedclock is provided, call it here * at ~~12-25 Hz, ~~16 Hz is best */ if (schedhz == 0) if ((++ci->ci_schedstate.spc_schedticks & 3) == 0) - schedclock(p); + schedclock(l); } } Index: sys/kern/kern_descrip.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_descrip.c,v retrieving revision 1.73 retrieving revision 1.72.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.73 -r1.72.2.2 --- sys/kern/kern_descrip.c 2001/04/07 09:00:57 1.73 +++ sys/kern/kern_descrip.c 2001/04/09 01:57:52 1.72.2.2 @@ -44,8 +44,9 @@ #include #include #include #include +#include #include #include #include #include @@ -110,17 +111,19 @@ * Duplicate a file descriptor. */ /* ARGSUSED */ int -sys_dup(struct proc *p, void *v, register_t *retval) +sys_dup(struct lwp *l, void *v, register_t *retval) { struct sys_dup_args /* { syscallarg(int) fd; } */ *uap = v; - struct file *fp; - struct filedesc *fdp; - int old, new, error; - + struct file *fp; + struct filedesc *fdp; + struct proc *p; + int old, new, error; + + p = l->l_proc; fdp = p->p_fd; old = SCARG(uap, fd); if ((u_int)old >= fdp->fd_nfiles || @@ -143,18 +146,20 @@ * Duplicate a file descriptor to a particular value. */ /* ARGSUSED */ int -sys_dup2(struct proc *p, void *v, register_t *retval) +sys_dup2(struct lwp *l, void *v, register_t *retval) { struct sys_dup2_args /* { syscallarg(int) from; syscallarg(int) to; } */ *uap = v; struct file *fp; struct filedesc *fdp; + struct proc *p; int old, new, i, error; + p = l->l_proc; fdp = p->p_fd; old = SCARG(uap, from); new = SCARG(uap, to); @@ -190,21 +195,23 @@ * The file control system call. */ /* ARGSUSED */ int -sys_fcntl(struct proc *p, void *v, register_t *retval) +sys_fcntl(struct lwp *l, void *v, register_t *retval) { struct sys_fcntl_args /* { syscallarg(int) fd; syscallarg(int) cmd; syscallarg(void *) arg; } */ *uap = v; struct filedesc *fdp; struct file *fp; + struct proc *p; struct vnode *vp; int fd, i, tmp, error, flg, cmd, newmin; struct flock fl; + p = l->l_proc; fd = SCARG(uap, fd); fdp = p->p_fd; error = 0; flg = F_POSIX; @@ -446,16 +453,18 @@ * Close a file descriptor. */ /* ARGSUSED */ int -sys_close(struct proc *p, void *v, register_t *retval) +sys_close(struct lwp *l, void *v, register_t *retval) { struct sys_close_args /* { syscallarg(int) fd; } */ *uap = v; int fd; struct filedesc *fdp; + struct proc *p; + p = l->l_proc; fd = SCARG(uap, fd); fdp = p->p_fd; if ((u_int)fd >= fdp->fd_nfiles) return (EBADF); @@ -466,20 +475,22 @@ * Return status information about a file descriptor. */ /* ARGSUSED */ int -sys___fstat13(struct proc *p, void *v, register_t *retval) +sys___fstat13(struct lwp *l, void *v, register_t *retval) { struct sys___fstat13_args /* { syscallarg(int) fd; syscallarg(struct stat *) sb; } */ *uap = v; int fd; struct filedesc *fdp; struct file *fp; + struct proc *p; struct stat ub; int error; + p = l->l_proc; fd = SCARG(uap, fd); fdp = p->p_fd; if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL || @@ -500,20 +511,22 @@ * Return pathconf information about a file descriptor. */ /* ARGSUSED */ int -sys_fpathconf(struct proc *p, void *v, register_t *retval) +sys_fpathconf(struct lwp *l, void *v, register_t *retval) { struct sys_fpathconf_args /* { syscallarg(int) fd; syscallarg(int) name; } */ *uap = v; int fd; struct filedesc *fdp; struct file *fp; + struct proc *p; struct vnode *vp; int error; + p = l->l_proc; fd = SCARG(uap, fd); fdp = p->p_fd; error = 0; @@ -1063,20 +1076,22 @@ * the entire file (l_whence = SEEK_SET, l_start = 0, l_len = 0). */ /* ARGSUSED */ int -sys_flock(struct proc *p, void *v, register_t *retval) +sys_flock(struct lwp *l, void *v, register_t *retval) { struct sys_flock_args /* { syscallarg(int) fd; syscallarg(int) how; } */ *uap = v; int fd, how, error; + struct proc *p; struct filedesc *fdp; struct file *fp; struct vnode *vp; struct flock lf; + p = l->l_proc; fd = SCARG(uap, fd); how = SCARG(uap, how); fdp = p->p_fd; error = 0; Index: sys/kern/kern_exec.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_exec.c,v retrieving revision 1.138 retrieving revision 1.138.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.138 -r1.138.2.1 --- sys/kern/kern_exec.c 2001/02/26 20:43:25 1.138 +++ sys/kern/kern_exec.c 2001/03/05 22:49:39 1.138.2.1 @@ -38,8 +38,9 @@ #include #include #include #include +#include #include #include #include #include @@ -304,9 +305,9 @@ * exec system call */ /* ARGSUSED */ int -sys_execve(struct proc *p, void *v, register_t *retval) +sys_execve(struct lwp *l, void *v, register_t *retval) { struct sys_execve_args /* { syscallarg(const char *) path; syscallarg(char * const *) argp; @@ -315,8 +316,9 @@ int error, i; struct exec_package pack; struct nameidata nid; struct vattr attr; + struct proc *p; struct ucred *cred; char *argp; char * const *cpp; char *dp, *sp; @@ -328,8 +330,9 @@ char **tmpfap; int szsigcode; struct exec_vmcmd *base_vcp; + p = l->l_proc; cred = p->p_ucred; base_vcp = NULL; /* * Init the namei data to point the file user's program name. @@ -463,9 +466,9 @@ * Do whatever is necessary to prepare the address space * for remapping. Note that this might replace the current * vmspace with another! */ - uvmspace_exec(p, pack.ep_vm_minaddr, pack.ep_vm_maxaddr); + uvmspace_exec(l, pack.ep_vm_minaddr, pack.ep_vm_maxaddr); /* Now map address space */ vm = p->p_vmspace; vm->vm_taddr = (char *) pack.ep_taddr; @@ -568,9 +571,14 @@ stopprofclock(p); /* stop profiling */ fdcloseexec(p); /* handle close on exec */ execsigs(p); /* reset catched signals */ - p->p_ctxlink = NULL; /* reset ucontext link */ + + /* XXX NJWLWP the rest of this function probably needs its + * head examined in the context of a multilwp process. + */ + + l->l_ctxlink = NULL; /* reset ucontext link */ /* set command name & other accounting info */ len = min(nid.ni_cnd.cn_namelen, MAXCOMLEN); memcpy(p->p_comm, nid.ni_cnd.cn_nameptr, len); @@ -623,9 +631,9 @@ VOP_CLOSE(pack.ep_vp, FREAD, cred, p); vput(pack.ep_vp); /* setup new registers and do misc. setup. */ - (*pack.ep_es->es_setregs)(p, &pack, (u_long) stack); + (*pack.ep_es->es_setregs)(l, &pack, (u_long) stack); if (p->p_flag & P_TRACED) psignal(p, SIGTRAP); @@ -704,10 +712,10 @@ VOP_CLOSE(pack.ep_vp, FREAD, cred, p); vput(pack.ep_vp); uvm_km_free_wakeup(exec_map, (vaddr_t) argp, NCARGS); free(pack.ep_hdr, M_EXEC); - exit1(p, W_EXITCODE(0, SIGABRT)); - exit1(p, -1); + exit1(l, W_EXITCODE(0, SIGABRT)); + exit1(l, -1); /* NOTREACHED */ return 0; } Index: sys/kern/kern_exit.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_exit.c,v retrieving revision 1.90 retrieving revision 1.89.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.90 -r1.89.2.2 --- sys/kern/kern_exit.c 2001/03/05 20:38:21 1.90 +++ sys/kern/kern_exit.c 2001/04/09 01:57:52 1.89.2.2 @@ -83,8 +83,9 @@ #include #include #include #include +#include #include #include #include #include @@ -109,28 +110,32 @@ #endif #ifdef SYSVSEM #include #endif +#include +#include #include #include #include #include +#define DPRINTF(x) + /* * exit -- * Death of process. */ int -sys_exit(struct proc *p, void *v, register_t *retval) +sys_exit(struct lwp *l, void *v, register_t *retval) { struct sys_exit_args /* { syscallarg(int) rval; } */ *uap = v; - exit1(p, W_EXITCODE(SCARG(uap, rval), 0)); + exit1(l, W_EXITCODE(SCARG(uap, rval), 0)); /* NOTREACHED */ return (0); } @@ -139,16 +144,29 @@ * to zombie, and unlink proc from allproc and parent's lists. Save exit * status and rusage for wait(). Check for child processes and orphan them. */ void -exit1(struct proc *p, int rv) +exit1(struct lwp *l, int rv) { - struct proc *q, *nq; - int s; + struct lwp *l2; + struct proc *p, *q, *nq; + int s, error; + lwpid_t waited; + + p = l->l_proc; if (__predict_false(p == initproc)) panic("init died (signal %d, exit %d)", - WTERMSIG(rv), WEXITSTATUS(rv)); + WTERMSIG(rv), WEXITSTATUS(rv)); + + /* + * Disable scheduler activation upcalls. + * We're trying to get out of here. + */ + if (l->l_flag & L_SA) { + l->l_flag &= ~L_SA; + DPRINTF(("exit1: %d.%d exiting.\n", p->p_pid, l->l_lid)); + } #ifdef PGINPROF vmsizmon(); #endif @@ -168,8 +186,65 @@ sigemptyset(&p->p_sigctx.ps_siglist); p->p_sigctx.ps_sigcheck = 0; callout_stop(&p->p_realit_ch); + /* XXX SMP + * This would be the right place to IPI any LWPs running on + * other processors so that they can notice P_WEXIT. + */ + /* Make SA-cached LWPs normal process runnable LWPs so that they'll + * also self-destruct. + */ + if (p->p_sa && p->p_sa->sa_ncached > 0) { + DPRINTF(("exit1: Placing cached LWPs of %d on run queue: ", + p->p_pid)); + while (!LIST_EMPTY(&p->p_sa->sa_lwpcache)) { + l2 = LIST_FIRST(&p->p_sa->sa_lwpcache); + LIST_REMOVE(l2, l_sibling); + p->p_sa->sa_ncached--; + l2->l_priority = l2->l_usrpri; + l2->l_stat = LSRUN; + SCHED_LOCK(s); + setrunqueue(l2); + SCHED_UNLOCK(s); + + LIST_INSERT_HEAD(&p->p_lwps, l2, l_sibling); + p->p_nlwps++; + p->p_nrlwps++; + DPRINTF(("%d ", l2->l_lid)); + + } + DPRINTF(("\n")); + } + + + /* Interrupt LWPs in interruptable sleep, unsuspend suspended + * LWPs, make detached LWPs undeached (so we can wait for + * them) and then wait for everyone else to finish. + */ + LIST_FOREACH(l2, &p->p_lwps, l_sibling) { + l2->l_flag &= ~(L_DETACHED|L_SA); + if ((l2->l_stat == LSSLEEP && (l2->l_flag & L_SINTR)) || + l2->l_stat == LSSUSPENDED) { + SCHED_LOCK(s); + setrunnable(l2); + SCHED_UNLOCK(s); + p->p_nrlwps++; + DPRINTF(("exit1: Made %d.%d runnable\n", + p->p_pid, l2->l_lid)); + } + } + + + while (p->p_nlwps > 1) { + DPRINTF(("exit1: waiting for %d LWPs (%d runnable, %d zombies)\n", + p->p_nlwps, p->p_nrlwps, p->p_nzlwps)); + error = lwp_wait1(l, 0, &waited, LWPWAIT_EXITCONTROL); + if (error) + panic("exit1: lwp_wait1 failed with error %d\n", + error); + DPRINTF(("exit1: Got LWP %d from lwp_wait1()\n", waited)); + } /* * Close open files and release open-file table. * This may block! */ @@ -222,8 +297,11 @@ /* * NOTE: WE ARE NO LONGER ALLOWED TO SLEEP! */ p->p_stat = SDEAD; + p->p_nrlwps--; + l->l_stat = SDEAD; + /* * Remove proc from pidhash chain so looking it up won't * work. Move it from allproc to zombproc, but do not yet @@ -234,8 +312,10 @@ s = proclist_lock_write(); LIST_REMOVE(p, p_hash); LIST_REMOVE(p, p_list); LIST_INSERT_HEAD(&zombproc, p, p_list); + LIST_REMOVE(l, l_list); + l->l_flag |= L_DETACHED; proclist_unlock_write(s); /* * Give orphaned children to init(8). @@ -298,8 +378,9 @@ * Other substructures are freed from wait(). */ curproc = NULL; limfree(p->p_limit); + pstatsfree(p->p_stats); p->p_limit = NULL; /* * If emulation has process exit hook, call it now. @@ -319,9 +400,10 @@ * * Note that cpu_exit() will end with a call equivalent to * cpu_switch(), finishing our execution (pun intended). */ - cpu_exit(p); + + cpu_exit(l, 1); } /* * We are called from cpu_exit() once it is safe to schedule the @@ -335,16 +417,18 @@ * We lock the deadproc list (a spin lock), place the proc on that * list (using the p_hash member), and wake up the reaper. */ void -exit2(struct proc *p) +exit2(struct lwp *l) { + struct proc *p = l->l_proc; simple_lock(&deadproc_slock); LIST_INSERT_HEAD(&deadproc, p, p_hash); simple_unlock(&deadproc_slock); - wakeup(&deadproc); + /* lwp_exit2() will wake up deadproc for us. */ + lwp_exit2(l); } /* * Process reaper. This is run by a kernel thread to free the resources @@ -354,69 +438,101 @@ void reaper(void *arg) { struct proc *p; + struct lwp *l; KERNEL_PROC_UNLOCK(curproc); for (;;) { simple_lock(&deadproc_slock); p = LIST_FIRST(&deadproc); - if (p == NULL) { + l = LIST_FIRST(&deadlwp); + if (p == NULL && l == NULL) { /* No work for us; go to sleep until someone exits. */ (void) ltsleep(&deadproc, PVM|PNORELOCK, "reaper", 0, &deadproc_slock); continue; } - /* Remove us from the deadproc list. */ - LIST_REMOVE(p, p_hash); - simple_unlock(&deadproc_slock); - KERNEL_PROC_LOCK(curproc); + if (l != NULL ) { + p = l->l_proc; - /* - * Give machine-dependent code a chance to free any - * resources it couldn't free while still running on - * that process's context. This must be done before - * uvm_exit(), in case these resources are in the PCB. - */ - cpu_wait(p); + /* Remove us from the deadlwp list. */ + LIST_REMOVE(l, l_list); + simple_unlock(&deadproc_slock); + KERNEL_PROC_LOCK(curproc); + + /* + * Give machine-dependent code a chance to free any + * resources it couldn't free while still running on + * that process's context. This must be done before + * uvm_lwp_exit(), in case these resources are in the + * PCB. + */ + cpu_wait(l); - /* - * Free the VM resources we're still holding on to. - * We must do this from a valid thread because doing - * so may block. - */ - uvm_exit(p); + /* + * Free the VM resources we're still holding on to. + */ + uvm_lwp_exit(l); - /* Process is now a true zombie. */ - p->p_stat = SZOMB; + l->l_stat = LSZOMB; + if (l->l_flag & L_DETACHED) { + /* Nobody waits for detached LWPs. */ + LIST_REMOVE(l, l_sibling); + p->p_nlwps--; + pool_put(&lwp_pool, l); + } else { + p->p_nzlwps++; + wakeup((caddr_t)&p->p_nlwps); + } + /* XXXNJW where should this be with respect to + * the wakeup() above? */ + KERNEL_PROC_UNLOCK(curproc); + } else { + /* Remove us from the deadproc list. */ + LIST_REMOVE(p, p_hash); + simple_unlock(&deadproc_slock); + KERNEL_PROC_LOCK(curproc); - /* Wake up the parent so it can get exit status. */ - if ((p->p_flag & P_FSTRACE) == 0 && p->p_exitsig != 0) - psignal(p->p_pptr, P_EXITSIG(p)); - KERNEL_PROC_UNLOCK(curproc); - wakeup((caddr_t)p->p_pptr); + /* + * Free the VM resources we're still holding on to. + * We must do this from a valid thread because doing + * so may block. + */ + uvm_proc_exit(p); + + /* Process is now a true zombie. */ + p->p_stat = SZOMB; + + /* Wake up the parent so it can get exit status. */ + if ((p->p_flag & P_FSTRACE) == 0 && p->p_exitsig != 0) + psignal(p->p_pptr, P_EXITSIG(p)); + KERNEL_PROC_UNLOCK(curproc); + wakeup((caddr_t)p->p_pptr); + } } } int -sys_wait4(struct proc *q, void *v, register_t *retval) +sys_wait4(struct lwp *l, void *v, register_t *retval) { struct sys_wait4_args /* { syscallarg(int) pid; syscallarg(int *) status; syscallarg(int) options; syscallarg(struct rusage *) rusage; } */ *uap = v; - struct proc *p, *t; + struct proc *p, *q, *t; int nfound, status, error, s; if (SCARG(uap, pid) == 0) SCARG(uap, pid) = -q->p_pgid; if (SCARG(uap, options) &~ (WUNTRACED|WNOHANG|WALTSIG)) return (EINVAL); + q = l->l_proc; loop: nfound = 0; for (p = q->p_children.lh_first; p != 0; p = p->p_sibling.le_next) { if (SCARG(uap, pid) != WAIT_ANY && @@ -502,8 +618,16 @@ * Release reference to text vnode */ if (p->p_textvp) vrele(p->p_textvp); + + /* + * Release any SA state + */ + if (p->p_sa) { + free(p->p_sa->sa_stacks, M_SA); + pool_put(&sadata_pool, p->p_sa); + } pool_put(&proc_pool, p); nprocs--; return (0); Index: sys/kern/kern_fork.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_fork.c,v retrieving revision 1.84 retrieving revision 1.84.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.84 -r1.84.2.1 --- sys/kern/kern_fork.c 2001/02/26 21:14:20 1.84 +++ sys/kern/kern_fork.c 2001/03/05 22:49:39 1.84.2.1 @@ -50,8 +50,9 @@ #include #include #include #include +#include #include #include #include #include @@ -68,24 +69,24 @@ int nprocs = 1; /* process 0 */ /*ARGSUSED*/ int -sys_fork(struct proc *p, void *v, register_t *retval) +sys_fork(struct lwp *l, void *v, register_t *retval) { - return (fork1(p, 0, SIGCHLD, NULL, 0, NULL, NULL, retval, NULL)); + return (fork1(l, 0, SIGCHLD, NULL, 0, NULL, NULL, retval, NULL)); } /* * vfork(2) system call compatible with 4.4BSD (i.e. BSD with Mach VM). * Address space is not shared, but parent is blocked until child exit. */ /*ARGSUSED*/ int -sys_vfork(struct proc *p, void *v, register_t *retval) +sys_vfork(struct lwp *l, void *v, register_t *retval) { - return (fork1(p, FORK_PPWAIT, SIGCHLD, NULL, 0, NULL, NULL, + return (fork1(l, FORK_PPWAIT, SIGCHLD, NULL, 0, NULL, NULL, retval, NULL)); } /* @@ -93,22 +94,23 @@ * semantics. Address space is shared, and parent is blocked until child exit. */ /*ARGSUSED*/ int -sys___vfork14(struct proc *p, void *v, register_t *retval) +sys___vfork14(struct lwp *l, void *v, register_t *retval) { - return (fork1(p, FORK_PPWAIT|FORK_SHAREVM, SIGCHLD, NULL, 0, + return (fork1(l, FORK_PPWAIT|FORK_SHAREVM, SIGCHLD, NULL, 0, NULL, NULL, retval, NULL)); } int -fork1(struct proc *p1, int flags, int exitsig, void *stack, size_t stacksize, +fork1(struct lwp *l1, int flags, int exitsig, void *stack, size_t stacksize, void (*func)(void *), void *arg, register_t *retval, struct proc **rnewprocp) { - struct proc *p2, *tp; + struct proc *p1, *p2, *tp; uid_t uid; + struct lwp *l2; int count, s; vaddr_t uaddr; static int nextpid, pidchecked; @@ -118,8 +120,9 @@ * a nonprivileged user to use the last process; don't let root * exceed the limit. The variable nprocs is the current number of * processes, maxproc is the limit. */ + p1 = l1->l_proc; uid = p1->p_cred->p_ruid; if (__predict_false((nprocs >= maxproc - 1 && uid != 0) || nprocs >= maxproc)) { tablefull("proc", "increase kern.maxproc or NPROC"); @@ -174,30 +177,17 @@ (unsigned) ((caddr_t)&p2->p_endzero - (caddr_t)&p2->p_startzero)); memcpy(&p2->p_startcopy, &p1->p_startcopy, (unsigned) ((caddr_t)&p2->p_endcopy - (caddr_t)&p2->p_startcopy)); -#if !defined(MULTIPROCESSOR) - /* - * In the single-processor case, all processes will always run - * on the same CPU. So, initialize the child's CPU to the parent's - * now. In the multiprocessor case, the child's CPU will be - * initialized in the low-level context switch code when the - * process runs. - */ - p2->p_cpu = p1->p_cpu; -#else - /* - * zero child's cpu pointer so we don't get trash. - */ - p2->p_cpu = NULL; -#endif /* ! MULTIPROCESSOR */ + simple_lock_init(&p2->p_lwplock); + LIST_INIT(&p2->p_lwps); /* * Duplicate sub-structures as needed. * Increase reference counts on shared objects. * The p_stats and p_sigacts substructs are set in uvm_fork(). */ - p2->p_flag = P_INMEM | (p1->p_flag & P_SUGID); + p2->p_flag = p1->p_flag & (P_SUGID); p2->p_emul = p1->p_emul; if (p1->p_flag & P_PROFIL) startprofclock(p2); @@ -205,8 +195,9 @@ memcpy(p2->p_cred, p1->p_cred, sizeof(*p2->p_cred)); p2->p_cred->p_refcnt = 1; crhold(p1->p_ucred); + /* bump references to the text vnode (for procfs) */ p2->p_textvp = p1->p_textvp; if (p2->p_textvp) VREF(p2->p_textvp); @@ -243,9 +234,8 @@ LIST_INSERT_HEAD(&p1->p_children, p2, p_sibling); LIST_INIT(&p2->p_children); callout_init(&p2->p_realit_ch); - callout_init(&p2->p_tsleep_ch); #ifdef KTRACE /* * Copy traceflag and tracefile if enabled. @@ -269,8 +259,14 @@ */ sigactsinit(p2, p1, flags & FORK_SHARESIGS); /* + * p_stats. + * Copy parts of p_stats, and zero out the rest. + */ + p2->p_stats = pstatscopy(p1->p_stats); + + /* * If emulation has process fork hook, call it now. */ if (p2->p_emul->e_proc_fork) (*p2->p_emul->e_proc_fork)(p2, p1); @@ -278,20 +274,20 @@ /* * This begins the section where we must prevent the parent * from being swapped. */ - PHOLD(p1); + PHOLD(l1); /* * Finish creating the child process. It will return through a * different path later. */ - p2->p_addr = (struct user *)uaddr; - uvm_fork(p1, p2, (flags & FORK_SHAREVM) ? TRUE : FALSE, - stack, stacksize, - (func != NULL) ? func : child_return, - (arg != NULL) ? arg : p2); + newlwp(l1, p2, uaddr, 0, stack, stacksize, + (func != NULL) ? func : child_return, + arg, &l2); + uvm_proc_fork(p1, p2, (flags & FORK_SHAREVM) ? TRUE : FALSE); + /* * BEGIN PID ALLOCATION. */ s = proclist_lock_write(); @@ -362,9 +358,8 @@ * so that waiters won't grab it as soon as we unlock. */ p2->p_stat = SIDL; /* protect against others */ - p2->p_forw = p2->p_back = NULL; /* shouldn't be necessary */ LIST_INSERT_HEAD(&allproc, p2, p_list); LIST_INSERT_HEAD(PIDHASH(p2->p_pid), p2, p_hash); @@ -372,23 +367,24 @@ /* * END PID ALLOCATION. */ proclist_unlock_write(s); - /* * Make child runnable, set start time, and add to run queue. */ SCHED_LOCK(s); p2->p_stats->p_start = time; p2->p_acflag = AFORK; - p2->p_stat = SRUN; - setrunqueue(p2); + p2->p_stat = SACTIVE; + p2->p_nrlwps = 1; + l2->l_stat = LSRUN; + setrunqueue(l2); SCHED_UNLOCK(s); /* * Now can be swapped. */ - PRELE(p1); + PRELE(l1); /* * Update stats now that we know the fork was successful. */ Index: sys/kern/kern_kthread.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_kthread.c,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.11 -r1.11.2.1 --- sys/kern/kern_kthread.c 2000/07/14 07:15:05 1.11 +++ sys/kern/kern_kthread.c 2001/03/05 22:49:40 1.11.2.1 @@ -40,8 +40,9 @@ #include #include #include #include +#include #include #include #include #include @@ -67,9 +68,9 @@ int error; va_list ap; /* First, create the new process. */ - error = fork1(&proc0, FORK_SHAREVM | FORK_SHARECWD | FORK_SHAREFILES | + error = fork1(&lwp0, FORK_SHAREVM | FORK_SHARECWD | FORK_SHAREFILES | FORK_SHARESIGS, SIGCHLD, NULL, 0, func, arg, NULL, &p2); if (__predict_false(error != 0)) return (error); @@ -78,9 +79,10 @@ * swapping. Set P_NOCLDWAIT so that children are reparented * to init(8) when they exit. init(8) can easily wait them * out for us. */ - p2->p_flag |= P_INMEM | P_SYSTEM | P_NOCLDWAIT; /* XXX */ + p2->p_flag |= P_SYSTEM | P_NOCLDWAIT; /* XXX */ + LIST_FIRST(&p2->p_lwps)->l_flag |= L_INMEM; /* Name it as specified. */ va_start(ap, fmt); vsnprintf(p2->p_comm, MAXCOMLEN, fmt, ap); @@ -106,9 +108,9 @@ * XXX it. */ if (ecode != 0) printf("WARNING: thread `%s' (%d) exits with status %d\n", - curproc->p_comm, curproc->p_pid, ecode); + curproc->l_proc->p_comm, curproc->l_proc->p_pid, ecode); exit1(curproc, W_EXITCODE(ecode, 0)); /* Index: sys/kern/kern_ktrace.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_ktrace.c,v retrieving revision 1.53 retrieving revision 1.53.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.53 -r1.53.2.1 --- sys/kern/kern_ktrace.c 2001/01/05 22:25:26 1.53 +++ sys/kern/kern_ktrace.c 2001/03/05 22:49:40 1.53.2.1 @@ -38,8 +38,9 @@ #include "opt_ktrace.h" #include #include +#include #include #include #include #include @@ -210,11 +211,14 @@ cp = (caddr_t)((char *)ktp + sizeof(struct ktr_genio)); buflen -= sizeof(struct ktr_genio); while (resid > 0) { +#if 0 /* XXX NJWLWP */ KDASSERT(p->p_cpu != NULL); KDASSERT(p->p_cpu == curcpu()); - if (p->p_cpu->ci_schedstate.spc_flags & SPCF_SHOULDYIELD) +#endif + /* XXX NJWLWP */ + if (curcpu()->ci_schedstate.spc_flags & SPCF_SHOULDYIELD) preempt(NULL); cnt = min(iov->iov_len, buflen); if (cnt > resid) @@ -406,16 +410,17 @@ * ktrace system call */ /* ARGSUSED */ int -sys_fktrace(struct proc *curp, void *v, register_t *retval) +sys_fktrace(struct lwp *l, void *v, register_t *retval) { struct sys_fktrace_args /* { syscallarg(int) fd; syscallarg(int) ops; syscallarg(int) facs; syscallarg(int) pid; } */ *uap = v; + struct proc *curp = l->l_proc; struct file *fp = NULL; struct filedesc *fdp = curp->p_fd; if (((u_int)SCARG(uap, fd)) >= fdp->fd_nfiles || @@ -431,16 +436,17 @@ * ktrace system call */ /* ARGSUSED */ int -sys_ktrace(struct proc *curp, void *v, register_t *retval) +sys_ktrace(struct lwp *l, void *v, register_t *retval) { struct sys_ktrace_args /* { syscallarg(const char *) fname; syscallarg(int) ops; syscallarg(int) facs; syscallarg(int) pid; } */ *uap = v; + struct proc *curp = l->l_proc; struct vnode *vp = NULL; struct file *fp = NULL; int fd; int ops = SCARG(uap, ops); @@ -657,10 +663,10 @@ /* * Put user defined entry to ktrace records. */ int -sys_utrace(p, v, retval) - struct proc *p; +sys_utrace(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #ifdef KTRACE @@ -668,9 +674,9 @@ syscallarg(const char *) label; syscallarg(void *) addr; syscallarg(size_t) len; } */ *uap = v; - + struct proc *p = l->l_proc; if (!KTRPOINT(p, KTR_USER)) return (0); if (SCARG(uap, len) > KTR_USER_MAXLEN) Index: sys/kern/kern_lkm.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_lkm.c,v retrieving revision 1.55 retrieving revision 1.55.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.55 -r1.55.2.1 --- sys/kern/kern_lkm.c 2001/02/24 10:16:46 1.55 +++ sys/kern/kern_lkm.c 2001/03/05 22:49:40 1.55.2.1 @@ -557,15 +557,15 @@ * * Place holder for system call slots reserved for loadable modules. */ int -sys_lkmnosys(p, v, retval) - struct proc *p; +sys_lkmnosys(l, v, retval) + struct lwp *l; void *v; register_t *retval; { - return (sys_nosys(p, v, retval)); + return (sys_nosys(l, v, retval)); } /* * Acts like "enodev", but can be identified in cdevsw and bdevsw for Index: sys/kern/kern_lock.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_lock.c,v retrieving revision 1.51 retrieving revision 1.51.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.51 -r1.51.2.1 --- sys/kern/kern_lock.c 2000/12/24 23:56:24 1.51 +++ sys/kern/kern_lock.c 2001/03/05 22:49:40 1.51.2.1 @@ -83,8 +83,9 @@ #include "opt_lockdebug.h" #include "opt_ddb.h" #include +#include #include #include #include #include @@ -451,9 +452,10 @@ int error; pid_t pid; int extflags; cpuid_t cpu_id; - struct proc *p = curproc; + struct lwp *l = curproc; + struct proc *p = (l == NULL) ? NULL : l->l_proc; int lock_shutdown_noblock = 0; int s; error = 0; Index: sys/kern/kern_lwp.c =================================================================== RCS file: kern_lwp.c diff -N kern_lwp.c --- /dev/null Tue Apr 24 13:41:34 2001 +++ /tmp/cvsfIhJBWEq2q Tue Apr 24 17:08:00 2001 @@ -0,0 +1,446 @@ +/* $NetBSD: kern_lwp.c,v 1.1.2.1 2001/03/05 22:49:40 nathanw Exp $ */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +struct lwplist alllwp; +struct lwplist deadlwp; +struct lwplist zomblwp; + +#define DPRINTF(x) + +/* ARGSUSED */ +int +sys__lwp_create(struct lwp *l, void *v, register_t *retval) +{ + struct sys__lwp_create_args /* { + syscallarg(const ucontext_t *) ucp; + syscallarg(u_long) flags; + syscallarg(lwpid_t *) new_lwp; + } */ *uap = v; + struct proc *p = l->l_proc; + struct lwp *l2; + vaddr_t uaddr; + ucontext_t *newuc; + int s, error; + + newuc = pool_get(&lwp_uc_pool, PR_WAITOK); + + error = copyin(SCARG(uap, ucp), newuc, sizeof(*newuc)); + if (error) + return (error); + + /* XXX check against resource limits */ + + uaddr = uvm_km_valloc(kernel_map, USPACE); + if (__predict_false(uaddr == 0)) { + return (ENOMEM); + } + + /* XXX flags: + * __LWP_ASLWP is probably needed for Solaris compat. + */ + + newlwp(l, p, uaddr, + SCARG(uap, flags) & LWP_DETACHED, + NULL, NULL, startlwp, newuc, &l2); + + if ((SCARG(uap, flags) & LWP_SUSPENDED) == 0) { + SCHED_LOCK(s); + l2->l_stat = LSRUN; + setrunqueue(l2); + SCHED_UNLOCK(s); + simple_lock(&p->p_lwplock); + p->p_nrlwps++; + simple_unlock(&p->p_lwplock); + } else { + l2->l_stat = LSSUSPENDED; + } + + error = copyout(&l2->l_lid, SCARG(uap, new_lwp), + sizeof(l2->l_lid)); + if (error) + return (error); + + return (0); +} + + +int +sys__lwp_exit(struct lwp *l, void *v, register_t *retval) +{ + + lwp_exit(l); + /* NOTREACHED */ + return (0); +} + + +int +sys__lwp_self(struct lwp *l, void *v, register_t *retval) +{ + + *retval = l->l_lid; + + return (0); +} + + +int +sys__lwp_suspend(struct lwp *l, void *v, register_t *retval) +{ + struct sys__lwp_suspend_args /* { + syscallarg(lwpid_t) target; + } */ *uap = v; + int target_lid; + struct proc *p = l->l_proc; + struct lwp *t, *t2; + int s; + + target_lid = SCARG(uap, target); + + LIST_FOREACH(t, &p->p_lwps, l_sibling) + if (t->l_lid == target_lid) + break; + + if (t == NULL) + return (ESRCH); + + if (t == l) { + /* + * Check for deadlock, which is only possible + * when we're suspending ourself. + */ + LIST_FOREACH(t2, &p->p_lwps, l_sibling) { + if ((t2 != l) && (t2->l_stat != LSSUSPENDED)) + break; + } + + if (t2 == NULL) /* All other LWPs are suspended */ + return (EDEADLK); + + SCHED_LOCK(s); + l->l_stat = LSSUSPENDED; + /* XXX NJWLWP check if this makes sense here: */ + l->l_proc->p_stats->p_ru.ru_nvcsw++; + mi_switch(l, NULL); + SCHED_ASSERT_UNLOCKED(); + } else { + switch (t->l_stat) { + case LSSUSPENDED: + return (0); /* _lwp_suspend() is idempotent */ + case LSRUN: + SCHED_LOCK(s); + remrunqueue(t); + SCHED_UNLOCK(s); + t->l_stat = LSSUSPENDED; + simple_lock(&p->p_lwplock); + p->p_nrlwps--; + simple_unlock(&p->p_lwplock); + break; + case LSSLEEP: + t->l_stat = LSSUSPENDED; + break; + case LSIDL: + case LSDEAD: + case LSZOMB: + return (EINTR); /* It's what Solaris does..... */ + case LSSTOP: + panic("_lwp_suspend: Stopped LWP in running process!"); + break; + case LSONPROC: + panic("XXX multiprocessor LWPs? Implement me!"); + break; + } + } + + return (0); +} + + +int +sys__lwp_continue(struct lwp *l, void *v, register_t *retval) +{ + struct sys__lwp_continue_args /* { + syscallarg(lwpid_t) target; + } */ *uap = v; + int target_lid; + struct proc *p = l->l_proc; + struct lwp *t; + int s; + + target_lid = SCARG(uap, target); + + LIST_FOREACH(t, &p->p_lwps, l_sibling) + if (t->l_lid == target_lid) + break; + + if (t == NULL) + return (ESRCH); + + if (t->l_stat != LSSUSPENDED) + return (0); + + if (t->l_wchan == 0) { + /* LWP was runnable before being suspended. */ + SCHED_LOCK(s); + setrunnable(t); + simple_lock(&p->p_lwplock); + p->p_nrlwps++; + simple_unlock(&p->p_lwplock); + SCHED_UNLOCK(s); + } else { + /* LWP was sleeping before being suspended */ + t->l_stat = LSSLEEP; + } + + return (0); +} + + +int +sys__lwp_wait(struct lwp *l, void *v, register_t *retval) +{ + struct sys__lwp_wait_args /* { + syscallarg(lwpid_t) wait_for; + syscallarg(lwpid_t *) departed; + } */ *uap = v; + int error; + lwpid_t dep; + + error = lwp_wait1(l, SCARG(uap, wait_for), &dep, 0); + if (error) + return (error); + + if (SCARG(uap, departed)) { + error = copyout(&dep, SCARG(uap, departed), + sizeof(dep)); + if (error) + return (error); + } + + return (0); +} + + +int +lwp_wait1(struct lwp *l, lwpid_t lid, lwpid_t *departed, int flags) +{ + + struct proc *p = l->l_proc; + struct lwp *l2, *l3; + int nfound, error, s, wpri; + static char waitstr1[] = "lwpwait"; + static char waitstr2[] = "lwpwait2"; + + DPRINTF(("lwp_wait1: %d.%d waiting for %d.\n", + p->p_pid, l->l_lid, lid)); + + if (lid == l->l_lid) + return (EDEADLK); /* Waiting for ourselves makes no sense. */ + + wpri = PWAIT | PCATCH | + ((flags & LWPWAIT_EXITCONTROL) ? PNOEXITERR : 0); + loop: + nfound = 0; + LIST_FOREACH(l2, &p->p_lwps, l_sibling) { + if ((l2 == l) || (l2->l_flag & L_DETACHED) || + ((lid != 0) && (lid != l2->l_lid))) + continue; + + nfound++; + if (l2->l_stat == LSZOMB) { + if (departed) + *departed = l2->l_lid; + + s = proclist_lock_write(); + LIST_REMOVE(l2, l_zlist); /* off zomblwp */ + proclist_unlock_write(s); + + simple_lock(&p->p_lwplock); + LIST_REMOVE(l2, l_sibling); + p->p_nlwps--; + p->p_nzlwps--; + simple_unlock(&p->p_lwplock); + /* XXX decrement limits */ + + pool_put(&lwp_pool, l2); + + return (0); + } else if (l2->l_stat == LSSLEEP || + l2->l_stat == LSSUSPENDED) { + /* Deadlock checks. + * 1. If all other LWPs are waiting for exits + * or suspended, we would deadlock. + */ + + LIST_FOREACH(l3, &p->p_lwps, l_sibling) { + if (l3 != l && (l3->l_stat != LSSUSPENDED) && + !(l3->l_stat == LSSLEEP && + l3->l_wchan == (caddr_t) &p->p_nlwps)) + break; + } + if (l3 == NULL) /* Everyone else is waiting. */ + return (EDEADLK); + + /* XXX we'd like to check for a cycle of waiting + * LWPs (specific LID waits, not any-LWP waits) + * and detect that sort of deadlock, but we don't + * have a good place to store the lwp that is + * being waited for. wchan is already filled with + * &p->p_nlwps, and putting the lwp address in + * there for deadlock tracing would require + * exiting LWPs to call wakeup on both their + * own address and &p->p_nlwps, to get threads + * sleeping on any LWP exiting. + * + * Revisit later. Maybe another auxillary + * storage location associated with sleeping + * is in order. + */ + } + } + + if (nfound == 0) + return (ESRCH); + + if ((error = tsleep((caddr_t) &p->p_nlwps, wpri, + (lid != 0) ? waitstr1 : waitstr2, 0)) != 0) + return (error); + + goto loop; +} + + +int +newlwp(struct lwp *l1, struct proc *p2, vaddr_t uaddr, + int flags, void *stack, size_t stacksize, + void (*func)(void *), void *arg, struct lwp **rnewlwpp) +{ + struct lwp *l2; + int s; + + l2 = pool_get(&lwp_pool, PR_WAITOK); + + l2->l_stat = LSIDL; + l2->l_forw = l2->l_back = NULL; + l2->l_proc = p2; + + + memset(&l2->l_startzero, 0, + (unsigned) ((caddr_t)&l2->l_endzero - + (caddr_t)&l2->l_startzero)); + memcpy(&l2->l_startcopy, &l1->l_startcopy, + (unsigned) ((caddr_t)&l2->l_endcopy - + (caddr_t)&l2->l_startcopy)); + +#if !defined(MULTIPROCESSOR) + /* + * In the single-processor case, all processes will always run + * on the same CPU. So, initialize the child's CPU to the parent's + * now. In the multiprocessor case, the child's CPU will be + * initialized in the low-level context switch code when the + * process runs. + */ + l2->l_cpu = l1->l_cpu; +#else + /* + * zero child's cpu pointer so we don't get trash. + */ + l2->l_cpu = NULL; +#endif /* ! MULTIPROCESSOR */ + + l2->l_flag = L_INMEM; + l2->l_flag |= (flags & LWP_DETACHED) ? L_DETACHED : 0; + + callout_init(&l2->l_tsleep_ch); + + if (rnewlwpp != NULL) + *rnewlwpp = l2; + + l2->l_addr = (struct user *)uaddr; + uvm_lwp_fork(l1, l2, stack, stacksize, func, + (arg != NULL) ? arg : l2); + + + simple_lock(&p2->p_lwplock); + l2->l_lid = ++p2->p_nlwpid; + LIST_INSERT_HEAD(&p2->p_lwps, l2, l_sibling); + p2->p_nlwps++; + simple_unlock(&p2->p_lwplock); + + /* XXX should be locked differently... */ + s = proclist_lock_write(); + LIST_INSERT_HEAD(&alllwp, l2, l_list); + proclist_unlock_write(s); + + return (0); +} + + +/* + * Quit the process. This will call cpu_exit, which will call cpu_switch, + * so this can only be used meaningfully if you're willing to switch away. + * Calling with l!=curproc would be weird. + */ +void +lwp_exit(struct lwp *l) +{ + struct proc *p = l->l_proc; + int s; + + DPRINTF(("lwp_exit: %d.%d exiting.\n", p->p_pid, l->l_lid)); + /* + * If we are the last live LWP in a process, we need to exit + * the entire process (if that's not already going on). We do + * so with an exit status of zero, because it's a "controlled" + * exit, and because that's what Solaris does. + */ + if (((p->p_nlwps - p->p_nzlwps) == 1) && ((p->p_flag & P_WEXIT) == 0)) { + DPRINTF(("lwp_exit: %d.%d calling exit1()\n", + p->p_pid, l->l_lid)); + exit1(l, 0); + } + + s = proclist_lock_write(); + LIST_REMOVE(l, l_list); + if ((l->l_flag & L_DETACHED) == 0) { + DPRINTF(("lwp_exit: %d.%d going on zombie list\n", p->p_pid, + l->l_lid)); + LIST_INSERT_HEAD(&zomblwp, l, l_zlist); + } + proclist_unlock_write(s); + + simple_lock(&p->p_lwplock); + p->p_nrlwps--; + simple_unlock(&p->p_lwplock); + + l->l_stat = LSDEAD; + + /* cpu_exit() will not return */ + cpu_exit(l, 0); + +} + + +void +lwp_exit2(struct lwp *l) +{ + + simple_lock(&deadproc_slock); + LIST_INSERT_HEAD(&deadlwp, l, l_list); + simple_unlock(&deadproc_slock); + + wakeup(&deadproc); +} Index: sys/kern/kern_ntptime.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_ntptime.c,v retrieving revision 1.13 retrieving revision 1.13.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.13 -r1.13.2.1 --- sys/kern/kern_ntptime.c 2000/08/07 18:10:21 1.13 +++ sys/kern/kern_ntptime.c 2001/03/05 22:49:41 1.13.2.1 @@ -53,8 +53,9 @@ #include #include #include #include +#include #include #include #include @@ -103,10 +104,10 @@ /* * ntp_gettime() - NTP user application interface */ int -sys_ntp_gettime(p, v, retval) - struct proc *p; +sys_ntp_gettime(l, v, retval) + struct lwp *l; void *v; register_t *retval; { @@ -190,16 +191,17 @@ /* * ntp_adjtime() - NTP daemon application interface */ int -sys_ntp_adjtime(p, v, retval) - struct proc *p; +sys_ntp_adjtime(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_ntp_adjtime_args /* { syscallarg(struct timex *) tp; } */ *uap = v; + struct proc *p = l->l_proc; struct timex ntv; int error = 0; int modes; int s; @@ -374,10 +376,10 @@ /* For some reason, raising SIGSYS (as sys_nosys would) is problematic. */ int -sys_ntp_gettime(p, v, retval) - struct proc *p; +sys_ntp_gettime(l, v, retval) + struct lwp *l; void *v; register_t *retval; { return(ENOSYS); Index: sys/kern/kern_physio.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_physio.c,v retrieving revision 1.47 retrieving revision 1.46.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.47 -r1.46.2.2 --- sys/kern/kern_physio.c 2001/03/15 06:10:55 1.47 +++ sys/kern/kern_physio.c 2001/04/09 01:57:53 1.46.2.2 @@ -44,8 +44,9 @@ #include #include #include #include +#include #include #include @@ -78,9 +79,10 @@ void (*minphys) __P((struct buf *)); struct uio *uio; { struct iovec *iovp; - struct proc *p = curproc; + struct lwp *l = curproc; + struct proc *p = l->l_proc; int error, done, i, nobuf, s; long todo; error = 0; @@ -163,9 +165,9 @@ * Beware vmapbuf(); it clobbers b_data and * saves it in b_saveaddr. However, vunmapbuf() * restores it. */ - PHOLD(p); + PHOLD(l); error = uvm_vslock(p, bp->b_data, todo, (flags & B_READ) ? VM_PROT_READ | VM_PROT_WRITE : VM_PROT_READ); @@ -205,9 +207,9 @@ */ vunmapbuf(bp, todo); uvm_vsunlock(p, bp->b_data, todo); after_vsunlock: - PRELE(p); + PRELE(l); /* remember error value (save a splbio/splx pair) */ if (bp->b_flags & B_ERROR) error = (bp->b_error ? bp->b_error : EIO); Index: sys/kern/kern_proc.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_proc.c,v retrieving revision 1.44 retrieving revision 1.44.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.44 -r1.44.2.1 --- sys/kern/kern_proc.c 2001/02/04 22:32:24 1.44 +++ sys/kern/kern_proc.c 2001/03/05 22:49:41 1.44.2.1 @@ -76,8 +76,9 @@ #include #include #include #include +#include #include #include #include #include @@ -89,8 +90,10 @@ #include #include #include #include +#include +#include /* * Structure associated with user cacheing. */ @@ -113,8 +116,9 @@ struct proclist allproc; struct proclist zombproc; /* resources have been freed */ + /* * Process list locking: * * We have two types of locks on the proclists: read locks and write @@ -141,12 +145,16 @@ struct simplelock deadproc_slock; struct proclist deadproc; /* dead, but not yet undead */ struct pool proc_pool; +struct pool lwp_pool; +struct pool lwp_uc_pool; struct pool pcred_pool; struct pool plimit_pool; +struct pool pstats_pool; struct pool pgrp_pool; struct pool rusage_pool; +struct pool sadata_pool; /* * The process list descriptors, used during pid allocation and * by sysctl. No locking on this data structure is needed since @@ -178,8 +186,12 @@ LIST_INIT(&deadproc); simple_lock_init(&deadproc_slock); + LIST_INIT(&alllwp); + LIST_INIT(&deadlwp); + LIST_INIT(&zomblwp); + pidhashtbl = hashinit(maxproc / 4, HASH_LIST, M_PROC, M_WAITOK, &pidhash); pgrphashtbl = hashinit(maxproc / 4, HASH_LIST, M_PROC, M_WAITOK, &pgrphash); @@ -187,16 +199,25 @@ hashinit(maxproc / 16, HASH_LIST, M_PROC, M_WAITOK, &uihash); pool_init(&proc_pool, sizeof(struct proc), 0, 0, 0, "procpl", 0, pool_page_alloc_nointr, pool_page_free_nointr, M_PROC); + pool_init(&lwp_pool, sizeof(struct lwp), 0, 0, 0, "lwppl", + 0, pool_page_alloc_nointr, pool_page_free_nointr, M_ZOMBIE); + pool_init(&lwp_uc_pool, sizeof(ucontext_t), 0, 0, 0, "lwpucpl", + 0, pool_page_alloc_nointr, pool_page_free_nointr, M_ZOMBIE); pool_init(&pgrp_pool, sizeof(struct pgrp), 0, 0, 0, "pgrppl", 0, pool_page_alloc_nointr, pool_page_free_nointr, M_PGRP); pool_init(&pcred_pool, sizeof(struct pcred), 0, 0, 0, "pcredpl", 0, pool_page_alloc_nointr, pool_page_free_nointr, M_SUBPROC); pool_init(&plimit_pool, sizeof(struct plimit), 0, 0, 0, "plimitpl", 0, pool_page_alloc_nointr, pool_page_free_nointr, M_SUBPROC); + pool_init(&pstats_pool, sizeof(struct pstats), 0, 0, 0, "pstatspl", + 0, pool_page_alloc_nointr, pool_page_free_nointr, M_SUBPROC); pool_init(&rusage_pool, sizeof(struct rusage), 0, 0, 0, "rusgepl", 0, pool_page_alloc_nointr, pool_page_free_nointr, M_ZOMBIE); + pool_init(&sadata_pool, sizeof(struct sadata), 0, 0, 0, "sadatapl", + 0, pool_page_alloc_nointr, pool_page_free_nointr, M_ZOMBIE); + } /* * Acquire a read lock on the proclist. @@ -385,9 +406,9 @@ sizeof(sess->s_login)); p->p_flag &= ~P_CONTROLT; pgrp->pg_session = sess; #ifdef DIAGNOSTIC - if (__predict_false(p != curproc)) + if (__predict_false(p != curproc->l_proc)) panic("enterpgrp: mksession and p != curproc"); #endif } else { pgrp->pg_session = p->p_session; Index: sys/kern/kern_prot.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_prot.c,v retrieving revision 1.63 retrieving revision 1.63.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.63 -r1.63.2.1 --- sys/kern/kern_prot.c 2000/12/09 07:17:32 1.63 +++ sys/kern/kern_prot.c 2001/03/05 22:49:41 1.63.2.1 @@ -49,67 +49,72 @@ #include #include #include #include +#include #include #include #include #include #include #include -int sys_getpid(struct proc *, void *, register_t *); -int sys_getpid_with_ppid(struct proc *, void *, register_t *); -int sys_getuid(struct proc *, void *, register_t *); -int sys_getuid_with_euid(struct proc *, void *, register_t *); -int sys_getgid(struct proc *, void *, register_t *); -int sys_getgid_with_egid(struct proc *, void *, register_t *); +int sys_getpid(struct lwp *, void *, register_t *); +int sys_getpid_with_ppid(struct lwp *, void *, register_t *); +int sys_getuid(struct lwp *, void *, register_t *); +int sys_getuid_with_euid(struct lwp *, void *, register_t *); +int sys_getgid(struct lwp *, void *, register_t *); +int sys_getgid_with_egid(struct lwp *, void *, register_t *); /* ARGSUSED */ int -sys_getpid(p, v, retval) - struct proc *p; +sys_getpid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { + struct proc *p = l->l_proc; *retval = p->p_pid; return (0); } /* ARGSUSED */ int -sys_getpid_with_ppid(p, v, retval) - struct proc *p; +sys_getpid_with_ppid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { + struct proc *p = l->l_proc; retval[0] = p->p_pid; retval[1] = p->p_pptr->p_pid; return (0); } /* ARGSUSED */ int -sys_getppid(p, v, retval) - struct proc *p; +sys_getppid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { + struct proc *p = l->l_proc; *retval = p->p_pptr->p_pid; return (0); } /* Get process group ID; note that POSIX getpgrp takes no parameter */ int -sys_getpgrp(p, v, retval) - struct proc *p; +sys_getpgrp(l, v, retval) + struct lwp *l; void *v; register_t *retval; { + struct proc *p = l->l_proc; *retval = p->p_pgrp->pg_id; return (0); } @@ -118,16 +123,17 @@ * Return the process group ID of the session leader (session ID) * for the specified process. */ int -sys_getsid(p, v, retval) - struct proc *p; +sys_getsid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_getsid_args /* { syscalldarg(pid_t) pid; } */ *uap = v; + struct proc *p = l->l_proc; if (SCARG(uap, pid) == 0) goto found; if ((p = pfind(SCARG(uap, pid))) == 0) @@ -137,16 +143,17 @@ return (0); } int -sys_getpgid(p, v, retval) - struct proc *p; +sys_getpgid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_getpgid_args /* { syscallarg(pid_t) pid; } */ *uap = v; + struct proc *p = l->l_proc; if (SCARG(uap, pid) == 0) goto found; if ((p = pfind(SCARG(uap, pid))) == 0) @@ -157,62 +164,67 @@ } /* ARGSUSED */ int -sys_getuid(p, v, retval) - struct proc *p; +sys_getuid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { + struct proc *p = l->l_proc; *retval = p->p_cred->p_ruid; return (0); } /* ARGSUSED */ int -sys_getuid_with_euid(p, v, retval) - struct proc *p; +sys_getuid_with_euid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { + struct proc *p = l->l_proc; retval[0] = p->p_cred->p_ruid; retval[1] = p->p_ucred->cr_uid; return (0); } /* ARGSUSED */ int -sys_geteuid(p, v, retval) - struct proc *p; +sys_geteuid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { + struct proc *p = l->l_proc; *retval = p->p_ucred->cr_uid; return (0); } /* ARGSUSED */ int -sys_getgid(p, v, retval) - struct proc *p; +sys_getgid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { + struct proc *p = l->l_proc; *retval = p->p_cred->p_rgid; return (0); } /* ARGSUSED */ int -sys_getgid_with_egid(p, v, retval) - struct proc *p; +sys_getgid_with_egid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { + struct proc *p = l->l_proc; retval[0] = p->p_cred->p_rgid; retval[1] = p->p_ucred->cr_gid; return (0); @@ -224,28 +236,29 @@ * correctly in a library function. */ /* ARGSUSED */ int -sys_getegid(p, v, retval) - struct proc *p; +sys_getegid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { - + struct proc *p = l->l_proc; *retval = p->p_ucred->cr_gid; return (0); } int -sys_getgroups(p, v, retval) - struct proc *p; +sys_getgroups(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_getgroups_args /* { syscallarg(int) gidsetsize; syscallarg(gid_t *) gidset; } */ *uap = v; + struct proc *p = l->l_proc; struct pcred *pc = p->p_cred; int ngrp; int error; @@ -266,13 +279,14 @@ } /* ARGSUSED */ int -sys_setsid(p, v, retval) - struct proc *p; +sys_setsid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { + struct proc *p = l->l_proc; if (p->p_pgid == p->p_pid || pgfind(p->p_pid)) { return (EPERM); } else { @@ -297,17 +311,18 @@ * pid must not be session leader (EPERM) */ /* ARGSUSED */ int -sys_setpgid(curp, v, retval) - struct proc *curp; +sys_setpgid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_setpgid_args /* { syscallarg(int) pid; syscallarg(int) pgid; } */ *uap = v; + struct proc *curp = l->l_proc; struct proc *targp; /* target process */ struct pgrp *pgrp; /* target pgrp */ if (SCARG(uap, pgid) < 0) @@ -335,16 +350,17 @@ } /* ARGSUSED */ int -sys_setuid(p, v, retval) - struct proc *p; +sys_setuid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_setuid_args /* { syscallarg(uid_t) uid; } */ *uap = v; + struct proc *p = l->l_proc; struct pcred *pc = p->p_cred; uid_t uid; int error; @@ -374,16 +390,17 @@ } /* ARGSUSED */ int -sys_seteuid(p, v, retval) - struct proc *p; +sys_seteuid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_seteuid_args /* { syscallarg(uid_t) euid; } */ *uap = v; + struct proc *p = l->l_proc; struct pcred *pc = p->p_cred; uid_t euid; int error; @@ -407,17 +424,18 @@ return (0); } int -sys_setreuid(p, v, retval) - struct proc *p; +sys_setreuid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_setreuid_args /* { syscallarg(uid_t) ruid; syscallarg(uid_t) euid; } */ *uap = v; + struct proc *p = l->l_proc; struct pcred *pc = p->p_cred; uid_t ruid, euid; int error, changed = 0; @@ -456,16 +474,17 @@ } /* ARGSUSED */ int -sys_setgid(p, v, retval) - struct proc *p; +sys_setgid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_setgid_args /* { syscallarg(gid_t) gid; } */ *uap = v; + struct proc *p = l->l_proc; struct pcred *pc = p->p_cred; gid_t gid; int error; @@ -489,16 +508,17 @@ } /* ARGSUSED */ int -sys_setegid(p, v, retval) - struct proc *p; +sys_setegid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_setegid_args /* { syscallarg(gid_t) egid; } */ *uap = v; + struct proc *p = l->l_proc; struct pcred *pc = p->p_cred; gid_t egid; int error; @@ -518,17 +538,18 @@ return (0); } int -sys_setregid(p, v, retval) - struct proc *p; +sys_setregid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_setregid_args /* { syscallarg(gid_t) rgid; syscallarg(gid_t) egid; } */ *uap = v; + struct proc *p = l->l_proc; struct pcred *pc = p->p_cred; gid_t rgid, egid; int error, changed = 0; @@ -564,13 +585,14 @@ return (0); } int -sys_issetugid(p, v, retval) - struct proc *p; +sys_issetugid(l, v, retval) + struct lwp *l; void *v; register_t *retval; { + struct proc *p = l->l_proc; /* * Note: OpenBSD sets a P_SUGIDEXEC flag set at execve() time, * we use P_SUGID because we consider changing the owners as * "tainting" as well. @@ -583,17 +605,18 @@ } /* ARGSUSED */ int -sys_setgroups(p, v, retval) - struct proc *p; +sys_setgroups(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_setgroups_args /* { syscallarg(int) gidsetsize; syscallarg(const gid_t *) gidset; } */ *uap = v; + struct proc *p = l->l_proc; struct pcred *pc = p->p_cred; int ngrp; int error; gid_t grp[NGROUPS]; @@ -728,17 +751,18 @@ * Get login name, if available. */ /* ARGSUSED */ int -sys___getlogin(p, v, retval) - struct proc *p; +sys___getlogin(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys___getlogin_args /* { syscallarg(char *) namebuf; syscallarg(size_t) namelen; } */ *uap = v; + struct proc *p = l->l_proc; if (SCARG(uap, namelen) > sizeof(p->p_pgrp->pg_session->s_login)) SCARG(uap, namelen) = sizeof(p->p_pgrp->pg_session->s_login); return (copyout((caddr_t) p->p_pgrp->pg_session->s_login, @@ -749,16 +773,17 @@ * Set login name. */ /* ARGSUSED */ int -sys_setlogin(p, v, retval) - struct proc *p; +sys_setlogin(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_setlogin_args /* { syscallarg(const char *) namebuf; } */ *uap = v; + struct proc *p = l->l_proc; int error; if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) return (error); Index: sys/kern/kern_resource.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_resource.c,v retrieving revision 1.60 retrieving revision 1.60.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.60 -r1.60.2.1 --- sys/kern/kern_resource.c 2001/02/06 19:54:43 1.60 +++ sys/kern/kern_resource.c 2001/03/05 22:49:41 1.60.2.1 @@ -46,8 +46,9 @@ #include #include #include #include +#include #include #include #include @@ -67,18 +68,18 @@ * Resource controls and accounting. */ int -sys_getpriority(curp, v, retval) - struct proc *curp; +sys_getpriority(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_getpriority_args /* { syscallarg(int) which; syscallarg(int) who; } */ *uap = v; - struct proc *p; + struct proc *curp = l->l_proc, *p; int low = NZERO + PRIO_MAX + 1; switch (SCARG(uap, which)) { @@ -128,19 +129,19 @@ } /* ARGSUSED */ int -sys_setpriority(curp, v, retval) - struct proc *curp; +sys_setpriority(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_setpriority_args /* { syscallarg(int) which; syscallarg(int) who; syscallarg(int) prio; } */ *uap = v; - struct proc *p; + struct proc *curp = l->l_proc, *p; int found = 0, error = 0; switch (SCARG(uap, which)) { @@ -210,24 +211,25 @@ if (n < chgp->p_nice && suser(pcred->pc_ucred, &curp->p_acflag)) return (EACCES); chgp->p_nice = n; SCHED_LOCK(s); - (void)resetpriority(chgp); + (void)resetprocpriority(chgp); SCHED_UNLOCK(s); return (0); } /* ARGSUSED */ int -sys_setrlimit(p, v, retval) - struct proc *p; +sys_setrlimit(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_setrlimit_args /* { syscallarg(int) which; syscallarg(const struct rlimit *) rlp; } */ *uap = v; + struct proc *p = l->l_proc; int which = SCARG(uap, which); struct rlimit alim; int error; @@ -339,17 +341,18 @@ } /* ARGSUSED */ int -sys_getrlimit(p, v, retval) - struct proc *p; +sys_getrlimit(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_getrlimit_args /* { syscallarg(int) which; syscallarg(struct rlimit *) rlp; } */ *uap = v; + struct proc *p = l->l_proc; int which = SCARG(uap, which); if ((u_int)which >= RLIM_NLIMITS) return (EINVAL); @@ -371,8 +374,9 @@ u_quad_t u, st, ut, it, tot; long sec, usec; int s; struct timeval tv; + struct lwp *l; s = splstatclock(); st = p->p_sticks; ut = p->p_uticks; @@ -389,22 +393,29 @@ } sec = p->p_rtime.tv_sec; usec = p->p_rtime.tv_usec; - if (p->p_stat == SONPROC) { - struct schedstate_percpu *spc; - - KDASSERT(p->p_cpu != NULL); - spc = &p->p_cpu->ci_schedstate; - - /* - * Adjust for the current time slice. This is actually fairly - * important since the error here is on the order of a time - * quantum, which is much greater than the sampling error. - */ - microtime(&tv); - sec += tv.tv_sec - spc->spc_runtime.tv_sec; - usec += tv.tv_usec - spc->spc_runtime.tv_usec; + for (l = LIST_FIRST(&p->p_lwps); l != NULL; + l = LIST_NEXT(l, l_sibling)) { + if (l->l_stat == LSONPROC) { + struct schedstate_percpu *spc; + + KDASSERT(l->l_cpu != NULL); + spc = &l->l_cpu->ci_schedstate; + + /* + * Adjust for the current time slice. This is + * actually fairly important since the error + * here is on the order of a time quantum, + * which is much greater than the sampling + * error. + */ + microtime(&tv); + sec += tv.tv_sec - spc->spc_runtime.tv_sec; + usec += tv.tv_usec - spc->spc_runtime.tv_usec; + + break; + } } u = (u_quad_t) sec * 1000000 + usec; st = (u * st) / tot; sp->tv_sec = st / 1000000; @@ -420,18 +431,19 @@ } /* ARGSUSED */ int -sys_getrusage(p, v, retval) - struct proc *p; +sys_getrusage(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_getrusage_args /* { syscallarg(int) who; syscallarg(struct rusage *) rusage; } */ *uap = v; struct rusage *rup; + struct proc *p = l->l_proc; switch (SCARG(uap, who)) { case RUSAGE_SELF: @@ -504,5 +516,33 @@ #endif if (lim->pl_corename != defcorename) free(lim->pl_corename, M_TEMP); pool_put(&plimit_pool, lim); +} + +struct pstats * +pstatscopy(ps) + struct pstats *ps; +{ + + struct pstats *newps; + + newps = pool_get(&pstats_pool, PR_WAITOK); + + memset(&newps->pstat_startzero, 0, + (unsigned) ((caddr_t)&newps->pstat_endzero - + (caddr_t)&newps->pstat_startzero)); + memcpy(&newps->pstat_startcopy, &ps->pstat_startcopy, + ((caddr_t)&newps->pstat_endcopy - + (caddr_t)&newps->pstat_startcopy)); + + return (newps); + +} + +void +pstatsfree(ps) + struct pstats *ps; +{ + + pool_put(&pstats_pool, ps); } Index: sys/kern/kern_sa.c =================================================================== RCS file: kern_sa.c diff -N kern_sa.c --- /dev/null Tue Apr 24 13:41:34 2001 +++ /tmp/cvsVxLh9nEIJY Tue Apr 24 17:08:00 2001 @@ -0,0 +1,394 @@ +/* $NetBSD: kern_sa.c,v 1.1.2.1 2001/03/05 22:49:41 nathanw Exp $ */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +static int sa_newcachelwp(struct lwp *); + +#define SA_DEBUG + +#ifdef SA_DEBUG +#define DPRINTF(x) if (sadebug) printf x +#define DPRINTFN(n,x) if (sadebug>(n)) printf x +int sadebug = 0; +#else +#define DPRINTF(x) +#define DPRINTFN(n,x) +#endif + + +int +sys_sa_register(struct lwp *l, void *v, register_t *retval) +{ + struct sys_sa_register_args /* { + syscallarg(sa_upcall_t) new; + syscallarg(sa_upcall_t *) old; + } */ *uap = v; + struct proc *p = l->l_proc; + struct sadata *s; + sa_upcall_t prev; + int error; + + if (p->p_sa == NULL) { + /* Allocate scheduler activations data structure */ + s = pool_get(&sadata_pool, PR_WAITOK); + /* Initialize. */ + memset(s, 0, sizeof(*s)); + simple_lock_init(&s->sa_lock); + s->sa_concurrency = 1; + s->sa_stacks = malloc(sizeof(stack_t) * SA_NUMSTACKS, + M_SA, M_WAITOK); + s->sa_nstackentries = SA_NUMSTACKS; + LIST_INIT(&s->sa_lwpcache); + p->p_sa = s; + sa_newcachelwp(l); + } + + prev = p->p_sa->sa_upcall; + p->p_sa->sa_upcall = SCARG(uap, new); + if (SCARG(uap, old)) { + error = copyout(&prev, SCARG(uap, old), + sizeof(prev)); + if (error) + return (error); + } + + return (0); +} + + +int +sys_sa_stacks(struct lwp *l, void *v, register_t *retval) +{ + struct sys_sa_stacks_args /* { + syscallarg(int) num; + syscallarg(stack_t *) stacks; + } */ *uap = v; + struct sadata *s = l->l_proc->p_sa; + int error, count; + + /* We have to be using scheduler activations */ + if (s == NULL) + return (EINVAL); + + count = SCARG(uap, num); + if (count < 0) + return (EINVAL); + count = min(count, s->sa_nstackentries - s->sa_nstacks); + + error = copyin(SCARG(uap, stacks), s->sa_stacks + s->sa_nstacks, + sizeof(stack_t) * count); + if (error) + return (error); + s->sa_nstacks += count; + + *retval = count; + return (0); +} + + +int +sys_sa_enable(struct lwp *l, void *v, register_t *retval) +{ + struct proc *p = l->l_proc; + struct sadata *s = p->p_sa; + int error; + + DPRINTF(("sys_sa_enable(pid: %d lid: %d)\n", l->l_proc->p_pid, l->l_lid)); + + /* We have to be using scheduler activations */ + if (s == NULL) + return (EINVAL); + + if (p->p_flag & P_SA) /* Already running! */ + return (EBUSY); + + error = sa_upcall(l, SA_UPCALL_NEWPROC, l, NULL, 0, 0); + if (error) + return (error); + + p->p_flag |= P_SA; + l->l_flag |= L_SA; /* We are now an activation LWP */ + + /* This will not return to the place in user space it came from. */ + return (0); +} + + +int +sys_sa_setconcurrency(struct lwp *l, void *v, register_t *retval) +{ + struct sys_sa_setconcurrency_args /* { + syscallarg(int) concurrency; + } */ *uap = v; + struct sadata *s = l->l_proc->p_sa; + + DPRINTF(("sys_sa_concurrency(pid: %d lid: %d)\n", l->l_proc->p_pid, l->l_lid)); + + /* We have to be using scheduler activations */ + if (s == NULL) + return (EINVAL); + + if (SCARG(uap, concurrency) < 1) + return (EINVAL); + + *retval = s->sa_concurrency; + /* + * Concurrency greater than the number of physical CPUs does + * not make sense. + * XXX Should we ever support hot-plug CPUs, this will need + * adjustment. + */ + s->sa_concurrency = min(SCARG(uap, concurrency), 1 /* XXX ncpus */); + + return (0); +} + + +int +sys_sa_yield(struct lwp *l, void *v, register_t *retval) +{ + struct proc *p = l->l_proc; + struct sadata *s = p->p_sa; + + if (s == NULL || !(p->p_flag & P_SA)) + return (EINVAL); + + lwp_exit(l); + + return (0); +} + + +int +sys_sa_preempt(struct lwp *l, void *v, register_t *retval) +{ + + /* XXX Implement me. */ + return (ENOSYS); +} + +/* + * Set up the user-level stack and trapframe to do an upcall. + */ + +int +sa_upcall(struct lwp *l, int type, struct lwp *event, struct lwp *interrupted, + int sig, u_long code) +{ + struct proc *p = l->l_proc; + struct sadata *sd = p->p_sa; + + stack_t st; + struct sa_t self_sa, e_sa, int_sa; + struct sa_t *list[3]; + int nsas = 1, eflag = 0, intflag = 0; + + DPRINTFN(2, ("sa_upcall(type: %d pid: %d.%d)", type, p->p_pid, l->l_lid)); + + /* Grab a stack */ + if (!sd->sa_nstacks) + return (ENOMEM); + + st = sd->sa_stacks[--sd->sa_nstacks]; + self_sa.sa_id = l->l_lid; + self_sa.sa_cpu = 0; /* XXX l->l_cpu; */ + self_sa.sa_sig = sig; + self_sa.sa_code = code; + + list[0] = &self_sa; + + if (event) { + DPRINTFN(2, (" (event: .%d)", event->l_lid)); + e_sa.sa_context = cpu_stashcontext(event); + e_sa.sa_id = event->l_lid; + e_sa.sa_cpu = 0; /* XXX event ->l_cpu; */ + e_sa.sa_sig = 0; + e_sa.sa_code = 0; + list[nsas++] = &e_sa; + eflag = 1; + } + + if (interrupted) { + DPRINTFN(2, (" (interrupted: .%d)", interrupted->l_lid)); + int_sa.sa_context = cpu_stashcontext(interrupted); + int_sa.sa_id = interrupted->l_lid; + int_sa.sa_cpu = 0; /* XXX interrupted->l_cpu; */ + int_sa.sa_sig = 0; + int_sa.sa_code = 0; + list[nsas++] = &int_sa; + intflag=1; + } + DPRINTFN(2, ("\n")); + PHOLD(l); + cpu_upcall(l, &st, type, eflag, intflag, list); + PRELE(l); + + return (0); +} + +/* + * Called by tsleep(). Block current LWP and switch to another. + */ +void +sa_switch(struct lwp *l, int type) +{ + struct proc *p = l->l_proc; + struct sadata *sa = p->p_sa; + struct lwp *l2; + int s, error; + + DPRINTF(("sa_switch(type: %d pid: %d.%d)\n", type, p->p_pid, l->l_lid)); + + /* Get an LWP */ + /* The process of allocating a new LWP could cause + * sleeps. We're called from inside sleep, so that would be + * Bad. Therefore, we must use a cached new LWP. The first + * thing that this new LWP must do is allocate another LWP for + * the cache. + */ + if (sa->sa_ncached == 0) { + /* XXXSMP */ + /* No upcall for you! */ + /* XXX The consequences of this are more subtle and + * XXX the recovery from this situation deserves + * XXX more thought. + */ + mi_switch(l, NULL); + return; + } + + /* XXX lock sadata */ + sa->sa_ncached--; + l2 = LIST_FIRST(&sa->sa_lwpcache); + LIST_REMOVE(l2, l_sibling); + /* XXX unlock */ + + PHOLD(l2); + cpu_setfunc(l2, sa_switchcall, l); + error = sa_upcall(l2, SA_UPCALL_BLOCKED, l, NULL, 0, 0); + PRELE(l2); + if (error) { + /* Put the lwp back */ + /* XXX lock sadata */ + LIST_INSERT_HEAD(&sa->sa_lwpcache, l2, l_sibling); + sa->sa_ncached++; + /* XXX unlock */ + mi_switch(l, NULL); + return; + } + LIST_INSERT_HEAD(&p->p_lwps, l2, l_sibling); + p->p_nlwps++; + p->p_nrlwps++; + + SCHED_LOCK(s); + l2->l_priority = l2->l_usrpri; + l2->l_stat = LSRUN; + setrunqueue(l2); + SCHED_UNLOCK(s); + + KDASSERT(l2 != l); + KDASSERT(l2->l_wchan == 0); + + DPRINTF(("sa_switch: pid %d switching from %d to %d.\n", + p->p_pid, l->l_lid, l2->l_lid)); + + mi_switch(l, l2); + + DPRINTF(("sa_switch: pid %d returned to %d.\n", p->p_pid, + l->l_lid)); + KDASSERT(l->l_wchan == 0); + + /* + * Okay, now we've been woken up. This means that it's time + * for a SA_UNBLOCKED upcall when we get back to userlevel. + */ + + /* + * ... unless we're trying to exit. In this case, the last thing + * we want to do is put something back on the cache list. + * It's also not useful to make the upcall at all, so just punt. + */ + + if (p->p_flag & P_WEXIT) + return; + + /* Find the interrupted LWP */ + LIST_FOREACH(l2, &p->p_lwps, l_sibling) + if (l2->l_stat == LSRUN) + break; + if (l2) { + SCHED_LOCK(s); + remrunqueue(l2); + l2->l_stat = LSSUSPENDED; + SCHED_UNLOCK(s); + p->p_nlwps--; + p->p_nrlwps--; + LIST_REMOVE(l2, l_sibling); + /* XXX lock sadata */ + LIST_INSERT_HEAD(&sa->sa_lwpcache, l2, l_sibling); + sa->sa_ncached++; + /* XXX unlock */ + } + + sa_upcall(l, SA_UPCALL_UNBLOCKED, l, l2, 0, 0); +} + +void +sa_switchcall(void *arg) +{ + struct lwp *l = curproc; + struct proc *p = l->l_proc; + struct sadata *sa = p->p_sa; + + DPRINTF(("sa_switchcall(pid: %d.%d)\n", p->p_pid, l->l_lid)); + + if (LIST_EMPTY(&sa->sa_lwpcache)) { + /* Allocate the next cache LWP */ + sa_newcachelwp(l); + } + upcallret(NULL); +} + +static int +sa_newcachelwp(struct lwp *l) +{ + struct proc *p = l->l_proc; + struct sadata *sa = p->p_sa; + + vaddr_t uaddr; + struct lwp *l2; + + uaddr = uvm_km_valloc(kernel_map, USPACE); + if (__predict_false(uaddr == 0)) { + return (ENOMEM); + } else { + newlwp(l, p, uaddr, 0, NULL, NULL, child_return, 0, &l2); + /* We don't want this LWP on the process's main LWP list, but + * newlwp helpfully puts it there. Unclear if newlwp should + * be tweaked. + */ + LIST_REMOVE(l2, l_sibling); + p->p_nlwps--; + l2->l_stat = LSSUSPENDED; + l2->l_flag |= (L_DETACHED | L_SA); + /* XXX lock sadata */ + LIST_INSERT_HEAD(&sa->sa_lwpcache, l2, l_sibling); + sa->sa_ncached++; + /* XXX unlock */ + } + + return (0); +} Index: sys/kern/kern_sig.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_sig.c,v retrieving revision 1.112 retrieving revision 1.112.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.112 -r1.112.2.1 --- sys/kern/kern_sig.c 2001/02/26 21:58:30 1.112 +++ sys/kern/kern_sig.c 2001/03/05 22:49:42 1.112.2.1 @@ -49,8 +49,9 @@ #include #include #include #include +#include #include #include #include #include @@ -66,8 +67,9 @@ #include #include #include #include +#include #include #include @@ -246,23 +248,25 @@ } /* ARGSUSED */ int -sys___sigaction14(struct proc *p, void *v, register_t *retval) +sys___sigaction14(struct lwp *l, void *v, register_t *retval) { struct sys___sigaction14_args /* { syscallarg(int) signum; syscallarg(const struct sigaction *) nsa; syscallarg(struct sigaction *) osa; } */ *uap = v; + struct proc *p; struct sigaction nsa, osa; int error; if (SCARG(uap, nsa)) { error = copyin(SCARG(uap, nsa), &nsa, sizeof(nsa)); if (error) return (error); } + p = l->l_proc; error = sigaction1(p, SCARG(uap, signum), SCARG(uap, nsa) ? &nsa : 0, SCARG(uap, osa) ? &osa : 0); if (error) return (error); @@ -394,23 +398,25 @@ * and return old mask as return value; * the library stub does the rest. */ int -sys___sigprocmask14(struct proc *p, void *v, register_t *retval) +sys___sigprocmask14(struct lwp *l, void *v, register_t *retval) { struct sys___sigprocmask14_args /* { syscallarg(int) how; syscallarg(const sigset_t *) set; syscallarg(sigset_t *) oset; } */ *uap = v; + struct proc *p; sigset_t nss, oss; int error; if (SCARG(uap, set)) { error = copyin(SCARG(uap, set), &nss, sizeof(nss)); if (error) return (error); } + p = l->l_proc; error = sigprocmask1(p, SCARG(uap, how), SCARG(uap, set) ? &nss : 0, SCARG(uap, oset) ? &oss : 0); if (error) return (error); @@ -431,15 +437,17 @@ } /* ARGSUSED */ int -sys___sigpending14(struct proc *p, void *v, register_t *retval) +sys___sigpending14(struct lwp *l, void *v, register_t *retval) { struct sys___sigpending14_args /* { syscallarg(sigset_t *) set; } */ *uap = v; - sigset_t ss; + struct proc *p; + sigset_t ss; + p = l->l_proc; sigpending1(p, &ss); return (copyout(&ss, SCARG(uap, set), sizeof(ss))); } @@ -478,13 +486,14 @@ * libc stub passes mask, not pointer, to save a copyin. */ /* ARGSUSED */ int -sys___sigsuspend14(struct proc *p, void *v, register_t *retval) +sys___sigsuspend14(struct lwp *l, void *v, register_t *retval) { struct sys___sigsuspend14_args /* { syscallarg(const sigset_t *) set; } */ *uap = v; + struct proc *p; sigset_t ss; int error; if (SCARG(uap, set)) { @@ -492,8 +501,9 @@ if (error) return (error); } + p = l->l_proc; return (sigsuspend1(p, SCARG(uap, set) ? &ss : 0)); } int @@ -522,22 +532,24 @@ } /* ARGSUSED */ int -sys___sigaltstack14(struct proc *p, void *v, register_t *retval) +sys___sigaltstack14(struct lwp *l, void *v, register_t *retval) { struct sys___sigaltstack14_args /* { syscallarg(const struct sigaltstack *) nss; syscallarg(struct sigaltstack *) oss; } */ *uap = v; + struct proc *p; struct sigaltstack nss, oss; int error; if (SCARG(uap, nss)) { error = copyin(SCARG(uap, nss), &nss, sizeof(nss)); if (error) return (error); } + p = l->l_proc; error = sigaltstack1(p, SCARG(uap, nss) ? &nss : 0, SCARG(uap, oss) ? &oss : 0); if (error) return (error); @@ -550,17 +562,18 @@ } /* ARGSUSED */ int -sys_kill(struct proc *cp, void *v, register_t *retval) +sys_kill(struct lwp *l, void *v, register_t *retval) { struct sys_kill_args /* { syscallarg(int) pid; syscallarg(int) signum; } */ *uap = v; - struct proc *p; + struct proc *cp, *p; struct pcred *pc; + cp = l->l_proc; pc = cp->p_cred; if ((u_int)SCARG(uap, signum) >= NSIG) return (EINVAL); if (SCARG(uap, pid) > 0) { @@ -670,12 +683,14 @@ * If it will be caught immediately, deliver it with correct code. * Otherwise, post it normally. */ void -trapsignal(struct proc *p, int signum, u_long code) +trapsignal(struct lwp *l, int signum, u_long code) { - struct sigacts *ps; + struct proc *p; + struct sigacts *ps; + p = l->l_proc; ps = p->p_sigacts; if ((p->p_flag & P_TRACED) == 0 && sigismember(&p->p_sigctx.ps_sigcatch, signum) && !sigismember(&p->p_sigctx.ps_sigmask, signum)) { @@ -723,10 +738,12 @@ void psignal1(struct proc *p, int signum, int dolock) /* XXXSMP: works, but icky */ { - int s, prop; - sig_t action; + struct lwp *l; + + int s, prop; + sig_t action; #ifdef DIAGNOSTIC if (signum <= 0 || signum >= NSIG) panic("psignal signal number"); @@ -791,173 +808,177 @@ * except that stopped processes must be continued by SIGCONT. */ if (action == SIG_HOLD && ((prop & SA_CONT) == 0 || p->p_stat != SSTOP)) return; - /* XXXSMP: works, but icky */ if (dolock) SCHED_LOCK(s); - - switch (p->p_stat) { - case SSLEEP: - /* - * If process is sleeping uninterruptibly - * we can't interrupt the sleep... the signal will - * be noticed when the process returns through - * trap() or syscall(). - */ - if ((p->p_flag & P_SINTR) == 0) - goto out; - /* - * Process is sleeping and traced... make it runnable - * so it can discover the signal in issignal() and stop - * for the parent. - */ - if (p->p_flag & P_TRACED) - goto run; - /* - * If SIGCONT is default (or ignored) and process is - * asleep, we are finished; the process should not - * be awakened. - */ - if ((prop & SA_CONT) && action == SIG_DFL) { - sigdelset(&p->p_sigctx.ps_siglist, signum); - goto out; + + if (p->p_nrlwps > 0) { + /* An LWP is running. */ +#ifdef __HAVE_AST_PERPROC + if ((curproc->l_stat == LSONPROC) || + (curproc->l_stat == LSRUN) || + (curproc->l_stat == LSIDL)) { + /* + * LSONPROC: We're running, notice the signal when + * we return back to userspace. + * + * LSRUN, LSIDL: Notice the signal when we run again + * and return to back to userspace. + */ +#else /* ! __HAVE_AST_PERPROC */ + if (curproc->l_stat == LSONPROC) { /* XXX SMP */ + /* + * We're running; notice the signal. + */ +#endif /* __HAVE_AST_PERPROC */ + signotify(p); } - /* - * When a sleeping process receives a stop - * signal, process immediately if possible. + /* + * The signal will be noticed very soon. */ - if ((prop & SA_STOP) && action == SIG_DFL) { + goto out; + } else { + /* Process is sleeping or stopped */ + /* Find out if any of the sleeps are interruptable */ + for (l = LIST_FIRST(&p->p_lwps); + l != NULL; + l = LIST_NEXT(l, l_sibling)) + if (l->l_stat == LSSLEEP && + l->l_flag & L_SINTR) + break; + if (p->p_stat == SACTIVE) { + /* All LWPs must be sleeping */ + + if (l == NULL) + /* None of them were interruptable */ + goto out; + + if (p->p_flag & P_TRACED) + goto run; + /* - * If a child holding parent blocked, - * stopping could cause deadlock. + * If SIGCONT is default (or ignored) and process is + * asleep, we are finished; the process should not + * be awakened. */ - if (p->p_flag & P_PPWAIT) + if ((prop & SA_CONT) && action == SIG_DFL) { + sigdelset(&p->p_sigctx.ps_siglist, signum); goto out; - sigdelset(&p->p_sigctx.ps_siglist, signum); - p->p_xstat = signum; - if ((p->p_pptr->p_flag & P_NOCLDSTOP) == 0) { + } + + /* + * When a sleeping process receives a stop + * signal, process immediately if possible. + */ + if ((prop & SA_STOP) && action == SIG_DFL) { /* - * XXXSMP: recursive call; don't lock - * the second time around. + * If a child holding parent blocked, + * stopping could cause deadlock. */ - sched_psignal(p->p_pptr, SIGCHLD); + if (p->p_flag & P_PPWAIT) + goto out; + sigdelset(&p->p_sigctx.ps_siglist, signum); + p->p_xstat = signum; + if ((p->p_pptr->p_flag & P_NOCLDSTOP) == 0) { + /* + * XXXSMP: recursive call; don't lock + * the second time around. + */ + sched_psignal(p->p_pptr, SIGCHLD); + } + proc_stop(p); /* XXXSMP: recurse? */ + goto out; } - proc_stop(p); /* XXXSMP: recurse? */ - goto out; - } - /* - * All other (caught or default) signals - * cause the process to run. - */ - goto runfast; - /*NOTREACHED*/ - - case SSTOP: - /* - * If traced process is already stopped, - * then no further action is necessary. - */ - if (p->p_flag & P_TRACED) - goto out; - - /* - * Kill signal always sets processes running. - */ - if (signum == SIGKILL) + /* + * All other (caught or default) signals + * cause the process to run. + */ goto runfast; + /*NOTREACHED*/ + } else if (p->p_stat == SSTOP) { + /* Process is stopped */ + /* + * If traced process is already stopped, + * then no further action is necessary. + */ + if (p->p_flag & P_TRACED) + goto out; - if (prop & SA_CONT) { /* - * If SIGCONT is default (or ignored), we continue the - * process but don't leave the signal in p_sigctx.ps_siglist, as - * it has no further action. If SIGCONT is held, we - * continue the process and leave the signal in - * p_sigctx.ps_siglist. If the process catches SIGCONT, let it - * handle the signal itself. If it isn't waiting on - * an event, then it goes back to run state. - * Otherwise, process goes back to sleep state. + * Kill signal always sets processes running. */ - if (action == SIG_DFL) - sigdelset(&p->p_sigctx.ps_siglist, signum); - if (action == SIG_CATCH) + if (signum == SIGKILL) goto runfast; - if (p->p_wchan == 0) - goto run; - p->p_stat = SSLEEP; - goto out; - } + + if (prop & SA_CONT) { + /* + * If SIGCONT is default (or ignored), + * we continue the process but don't + * leave the signal in ps_siglist, as + * it has no further action. If + * SIGCONT is held, we continue the + * process and leave the signal in + * ps_siglist. If the process catches + * SIGCONT, let it handle the signal + * itself. If it isn't waiting on an + * event, then it goes back to run + * state. Otherwise, process goes + * back to sleep state. + */ + if (action == SIG_DFL) + sigdelset(&p->p_sigctx.ps_siglist, + signum); + l = proc_unstop(p); + if (l && (action == SIG_CATCH)) + goto runfast; + if (l) + goto run; + goto out; + } + + if (prop & SA_STOP) { + /* + * Already stopped, don't need to stop again. + * (If we did the shell could get confused.) + */ + sigdelset(&p->p_sigctx.ps_siglist, signum); + goto out; + } - if (prop & SA_STOP) { /* - * Already stopped, don't need to stop again. - * (If we did the shell could get confused.) + * If process is sleeping interruptibly, then + * simulate a wakeup so that when it is + * continued, it will be made runnable and can + * look at the signal. But don't make the + * process runnable, leave it stopped. */ - sigdelset(&p->p_sigctx.ps_siglist, signum); + if (l) + unsleep(l); goto out; + } else { + /* Else what? */ + panic("psignal: Invalid process state."); } - - /* - * If process is sleeping interruptibly, then simulate a - * wakeup so that when it is continued, it will be made - * runnable and can look at the signal. But don't make - * the process runnable, leave it stopped. - */ - if (p->p_wchan && p->p_flag & P_SINTR) - unsleep(p); - goto out; -#ifdef __HAVE_AST_PERPROC - case SONPROC: - case SRUN: - case SIDL: - /* - * SONPROC: We're running, notice the signal when - * we return back to userspace. - * - * SRUN, SIDL: Notice the signal when we run again - * and return to back to userspace. - */ - signotify(p); - goto out; - - default: - /* - * SDEAD, SZOMB: The signal will never be noticed. - */ - goto out; -#else /* ! __HAVE_AST_PERPROC */ - case SONPROC: - /* - * We're running; notice the signal. - */ - signotify(p); - goto out; - - default: - /* - * SRUN, SIDL, SDEAD, SZOMB do nothing with the signal. - * It will either never be noticed, or noticed very soon. - */ - goto out; -#endif /* __HAVE_AST_PERPROC */ } /*NOTREACHED*/ runfast: /* * Raise priority to at least PUSER. */ - if (p->p_priority > PUSER) - p->p_priority = PUSER; + if (l->l_priority > PUSER) + l->l_priority = PUSER; run: - setrunnable(p); /* XXXSMP: recurse? */ + setrunnable(l); /* XXXSMP: recurse? */ out: /* XXXSMP: works, but icky */ if (dolock) SCHED_UNLOCK(s); } + static __inline int firstsig(const sigset_t *); static __inline int firstsig(const sigset_t *ss) @@ -997,13 +1018,15 @@ * while (signum = CURSIG(curproc)) * postsig(signum); */ int -issignal(struct proc *p) +issignal(struct lwp *l) { + struct proc *p; int s, signum, prop; sigset_t ss; + p = l->l_proc; for (;;) { sigpending1(p, &ss); if (p->p_flag & P_PPWAIT) sigminusset(&stopsigmask, &ss); @@ -1033,9 +1056,9 @@ psignal(p->p_pptr, SIGCHLD); do { SCHED_LOCK(s); proc_stop(p); - mi_switch(p); + mi_switch(l, NULL); SCHED_ASSERT_UNLOCKED(); splx(s); } while (!trace_req(p) && p->p_flag & P_TRACED); @@ -1101,9 +1124,9 @@ if ((p->p_pptr->p_flag & P_NOCLDSTOP) == 0) psignal(p->p_pptr, SIGCHLD); SCHED_LOCK(s); proc_stop(p); - mi_switch(p); + mi_switch(l, NULL); SCHED_ASSERT_UNLOCKED(); splx(s); break; } else if (prop & SA_IGNORE) { @@ -1151,30 +1174,118 @@ */ static void proc_stop(struct proc *p) { + struct lwp *l; SCHED_ASSERT_LOCKED(); + /* XXX lock process LWP state */ p->p_stat = SSTOP; p->p_flag &= ~P_WAITED; + + + /* + * Put as many LWP's as possible in stopped state. + * Any in uninterruptable sleep will notice the stopped state as + * they try to return. + */ + + for (l = LIST_FIRST(&p->p_lwps); l != NULL; + l = LIST_NEXT(l, l_sibling)) { + if (l->l_stat == LSONPROC) { + /* XXX SMP this assumes that a LWP that is LSONPROC + * is curproc and hence is about to be mi_switched + * away; the only callers of proc_stop() are: + * - psignal + * - issignal() + * For the former, proc_stop() is only called when + * no processes are running, so we don't worry. + * For the latter, proc_stop() is called right + * before mi_switch(). + */ + l->l_stat = LSSTOP; + p->p_nrlwps--; + } else if (l->l_stat == LSRUN) { + /* Remove LWP from the run queue */ + remrunqueue(l); + l->l_stat = LSSTOP; + p->p_nrlwps--; + } else if (l->l_stat == LSSLEEP) { + /* Note: this puts all sleeping LWPs into LSSTOP. + * Formerly, uninterruptably sleeping procs were + * left to discover the STOP signal on their + * way back to userspace, but that's harder + * with multiple LWPs. + * XXX This shou;d be okay, but..... + */ + l->l_stat = LSSTOP; + } else if ((l->l_stat == LSSUSPENDED) || + (l->l_stat == LSZOMB) || + (l->l_stat == LSDEAD)) { + /* Don't do anything. These guys aren't going anywhere. + */ + } +#ifdef DIAGNOSTIC + else { + panic("proc_stop: process %d lwp %d " + "in unstoppable state %d.\n", + p->p_pid, l->l_lid, l->l_stat); + } +#endif + } + /* XXX unlock process LWP state */ + sched_wakeup((caddr_t)p->p_pptr); } +struct lwp * +proc_unstop(p) + struct proc *p; +{ + struct lwp *l, *lr = NULL; + + SCHED_ASSERT_LOCKED(); + + /* Our caller will want to invoke setrunnable() on whatever we return. + * XXX what if everyone was asleep when the process was stopped? + * Yuck. + */ + + p->p_stat = SACTIVE; + for (l = LIST_FIRST(&p->p_lwps); l != NULL; + l = LIST_NEXT(l, l_sibling)) + if (l->l_stat == LSSTOP) { + if (l->l_wchan == 0) { + p->p_nrlwps++; + if (lr == NULL) + lr = l; + else + setrunnable(l); + } + else + l->l_stat = LSSLEEP; + } + + return lr; +} + /* * Take the action for the specified signal * from the current set of pending signals. */ void postsig(int signum) { + struct lwp *l; struct proc *p; struct sigacts *ps; sig_t action; u_long code; sigset_t *returnmask; - p = curproc; + l = curproc; + p = l->l_proc; ps = p->p_sigacts; #ifdef DIAGNOSTIC if (signum == 0) panic("postsig"); @@ -1194,9 +1305,9 @@ /* * Default action, where the default is to kill * the process. (Other cases were ignored above.) */ - sigexit(p, signum); + sigexit(l, signum); /* NOTREACHED */ } else { /* * If we get here, the signal must be caught. @@ -1276,17 +1387,19 @@ static const char lognocoredump[] = "pid %d (%s), uid %d: exited on signal %d (core not dumped, err = %d)\n"; void -sigexit(struct proc *p, int signum) +sigexit(struct lwp *l, int signum) { - int error, exitsig; + struct proc *p; + int error, exitsig; + p = l->l_proc; exitsig = signum; p->p_acflag |= AXSIG; if (sigprop[signum] & SA_CORE) { p->p_sigctx.ps_sig = signum; - if ((error = coredump(p)) == 0) + if ((error = coredump(l)) == 0) exitsig |= WCOREFLAG; if (kern_logsigexit) { int uid = p->p_cred && p->p_ucred ? @@ -1301,28 +1414,30 @@ } } - exit1(p, W_EXITCODE(0, exitsig)); + exit1(l, W_EXITCODE(0, exitsig)); /* NOTREACHED */ } /* * Dump core, into a file named "progname.core" or "core" (depending on the * value of shortcorename), unless the process was setuid/setgid. */ int -coredump(struct proc *p) +coredump(struct lwp *l) { struct vnode *vp; + struct proc *p; struct vmspace *vm; struct ucred *cred; struct nameidata nd; struct vattr vattr; int error, error1; char name[MAXPATHLEN]; struct core core; + p = l->l_proc; vm = p->p_vmspace; cred = p->p_cred->pc_ucred; /* @@ -1353,8 +1468,13 @@ error = build_corename(p, name); if (error) return error; + /* We don't want to switch away from crashing. */ + /* XXX multiprocessor: stop LWPs on other processors. */ + if (l->l_flag & L_SA) + l->l_flag &= ~L_SA; + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, p); error = vn_open(&nd, O_CREAT | FWRITE | FNOSYMLINK, S_IRUSR | S_IWUSR); if (error) return (error); @@ -1396,9 +1516,9 @@ core.c_cpusize = 0; core.c_tsize = (u_long)ctob(vm->vm_tsize); core.c_dsize = (u_long)ctob(vm->vm_dsize); core.c_ssize = (u_long)round_page(ctob(vm->vm_ssize)); - error = cpu_coredump(p, vp, cred, &core); + error = cpu_coredump(l, vp, cred, &core); if (error) goto out; /* * uvm_coredump() spits out all appropriate segments. @@ -1480,11 +1600,13 @@ * Flag error in case process won't see signal immediately (blocked or ignored). */ /* ARGSUSED */ int -sys_nosys(struct proc *p, void *v, register_t *retval) +sys_nosys(struct lwp *l, void *v, register_t *retval) { + struct proc *p; + p = l->l_proc; psignal(p, SIGSYS); return (ENOSYS); } @@ -1525,11 +1647,96 @@ if (d >= end) return (ENAMETOOLONG); } *d = '\0'; - return (0); + return 0; } +void +getucontext(struct lwp *l, ucontext_t *ucp) +{ + struct proc *p; + + p = l->l_proc; + + ucp->uc_flags = 0; + ucp->uc_link = l->l_ctxlink; + + (void)sigprocmask1(p, 0, NULL, &ucp->uc_sigmask); + ucp->uc_flags |= _UC_SIGMASK; + + /* + * The (unsupplied) definition of the `current execution stack' + * in the System V Interface Definition appears to allow returning + * the main context stack. + */ + if ((p->p_sigctx.ps_sigstk.ss_flags & SS_ONSTACK) == 0) { + ucp->uc_stack.ss_sp = (void *)USRSTACK; + ucp->uc_stack.ss_size = ctob(p->p_vmspace->vm_ssize); + ucp->uc_stack.ss_flags = 0; /* XXX, def. is Very Fishy */ + } else { + /* Simply copy alternate signal execution stack. */ + ucp->uc_stack = p->p_sigctx.ps_sigstk; + } + ucp->uc_flags |= _UC_STACK; + + cpu_getmcontext(l, &ucp->uc_mcontext, &ucp->uc_flags); +} + +/* ARGSUSED */ +int +sys_getcontext(struct lwp *l, void *v, register_t *retval) +{ + struct sys_getcontext_args /* { + syscallarg(struct __ucontext *) ucp; + } */ *uap = v; + ucontext_t uc; + + getucontext(l, &uc); + + return (copyout(&uc, SCARG(uap, ucp), sizeof (*SCARG(uap, ucp)))); +} + +int +setucontext(struct lwp *l, const ucontext_t *ucp) +{ + struct proc *p; + int error; + + p = l->l_proc; + if ((error = cpu_setmcontext(l, &ucp->uc_mcontext, ucp->uc_flags)) != 0) + return (error); + l->l_ctxlink = ucp->uc_link; + /* + * We might want to take care of the stack portion here but currently + * don't; see the comment in getucontext(). + */ + if ((ucp->uc_flags & _UC_SIGMASK) != 0) + sigprocmask1(p, SIG_SETMASK, &ucp->uc_sigmask, NULL); + + return 0; +} + +/* ARGSUSED */ +int +sys_setcontext(struct lwp *l, void *v, register_t *retval) +{ + struct sys_setcontext_args /* { + syscallarg(const ucontext_t *) ucp; + } */ *uap = v; + ucontext_t uc; + int error; + + if (SCARG(uap, ucp) == NULL) /* i.e. end of uc_link chain */ + exit1(l, W_EXITCODE(0, 0)); + else if ((error = copyin(SCARG(uap, ucp), &uc, sizeof (uc))) != 0 || + (error = setucontext(l, &uc)) != 0) + return (error); + + return (EJUSTRETURN); +} + + /* * Returns true if signal is ignored or masked for passed process. */ int @@ -1538,4 +1745,5 @@ return sigismember(&p->p_sigctx.ps_sigignore, SIGTTOU) || sigismember(&p->p_sigctx.ps_sigmask, SIGTTOU); } + Index: sys/kern/kern_subr.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_subr.c,v retrieving revision 1.75 retrieving revision 1.75.2.3 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.75 -r1.75.2.3 --- sys/kern/kern_subr.c 2001/01/12 22:55:10 1.75 +++ sys/kern/kern_subr.c 2001/03/19 17:45:02 1.75.2.3 @@ -92,8 +92,9 @@ #include "opt_md.h" #include #include +#include #include #include #include #include @@ -122,14 +123,16 @@ struct iovec *iov; u_int cnt; int error = 0; char *cp = buf; +#ifdef DIAGNOSTIC struct proc *p = uio->uio_procp; +#endif #ifdef DIAGNOSTIC if (uio->uio_rw != UIO_READ && uio->uio_rw != UIO_WRITE) panic("uiomove: mode"); - if (uio->uio_segflg == UIO_USERSPACE && p != curproc) + if (uio->uio_segflg == UIO_USERSPACE && p != curproc->l_proc) panic("uiomove proc"); #endif while (n > 0 && uio->uio_resid) { iov = uio->uio_iov; @@ -143,11 +146,13 @@ cnt = n; switch (uio->uio_segflg) { case UIO_USERSPACE: +#if 0 /* XXX NJWLWP */ KDASSERT(p->p_cpu != NULL); KDASSERT(p->p_cpu == curcpu()); - if (p->p_cpu->ci_schedstate.spc_flags & +#endif + if (curcpu()->ci_schedstate.spc_flags & SPCF_SHOULDYIELD) preempt(NULL); if (uio->uio_rw == UIO_READ) error = copyout(cp, iov->iov_base, cnt); Index: sys/kern/kern_synch.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_synch.c,v retrieving revision 1.101 retrieving revision 1.101.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.101 -r1.101.2.2 --- sys/kern/kern_synch.c 2001/01/14 22:31:59 1.101 +++ sys/kern/kern_synch.c 2001/04/08 20:53:05 1.101.2.2 @@ -85,13 +85,16 @@ #include #include #include #include +#include #include #include #include #include #include +#include +#include #include #ifdef KTRACE @@ -115,15 +118,17 @@ struct lock kernel_lock; #endif void schedcpu(void *); -void updatepri(struct proc *); +void updatepri(struct lwp *); void endtsleep(void *); -__inline void awaken(struct proc *); +__inline void awaken(struct lwp *); struct callout schedcpu_ch = CALLOUT_INITIALIZER; + + /* * Force switch among equal priority processes every 100ms. * Called from hardclock every hz/10 == rrticks hardclock ticks. */ @@ -241,29 +246,32 @@ void schedcpu(void *arg) { fixpt_t loadfac = loadfactor(averunnable.ldavg[0]); + struct lwp *l; struct proc *p; int s, s1; unsigned int newcpu; int clkhz; proclist_lock_read(); - for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) { + for (l = LIST_FIRST(&alllwp); l != NULL; l = LIST_NEXT(l,l_list)) { /* * Increment time in/out of memory and sleep time * (if sleeping). We ignore overflow; with 16-bit int's * (remember them?) overflow takes 45 days. */ - p->p_swtime++; - if (p->p_stat == SSLEEP || p->p_stat == SSTOP) - p->p_slptime++; + p = l->l_proc; + l->l_swtime++; + if (l->l_stat == LSSLEEP || l->l_stat == LSSTOP || + l->l_stat == LSSUSPENDED) + l->l_slptime++; p->p_pctcpu = (p->p_pctcpu * ccpu) >> FSHIFT; /* * If the process has slept the entire second, * stop recalculating its priority until it wakes up. */ - if (p->p_slptime > 1) + if (l->l_slptime > 1) continue; s = splstatclock(); /* prevent state changes */ /* * p_pctcpu is only for ps. @@ -274,25 +282,25 @@ ((fixpt_t) p->p_cpticks) << (FSHIFT - CCPU_SHIFT): 100 * (((fixpt_t) p->p_cpticks) << (FSHIFT - CCPU_SHIFT)) / clkhz; #else - p->p_pctcpu += ((FSCALE - ccpu) * + l->l_pctcpu += ((FSCALE - ccpu) * (p->p_cpticks * FSCALE / clkhz)) >> FSHIFT; #endif p->p_cpticks = 0; newcpu = (u_int)decay_cpu(loadfac, p->p_estcpu); p->p_estcpu = newcpu; SCHED_LOCK(s1); - resetpriority(p); - if (p->p_priority >= PUSER) { - if (p->p_stat == SRUN && - (p->p_flag & P_INMEM) && - (p->p_priority / PPQ) != (p->p_usrpri / PPQ)) { - remrunqueue(p); - p->p_priority = p->p_usrpri; - setrunqueue(p); + resetpriority(l); + if (l->l_priority >= PUSER) { + if (l->l_stat == LSRUN && + (l->l_flag & L_INMEM) && + (l->l_priority / PPQ) != (l->l_usrpri / PPQ)) { + remrunqueue(l); + l->l_priority = l->l_usrpri; + setrunqueue(l); } else - p->p_priority = p->p_usrpri; + l->l_priority = l->l_usrpri; } SCHED_UNLOCK(s1); splx(s); } @@ -307,27 +315,28 @@ * For all load averages >= 1 and max p_estcpu of 255, sleeping for at * least six times the loadfactor will decay p_estcpu to zero. */ void -updatepri(struct proc *p) +updatepri(struct lwp *l) { + struct proc *p = l->l_proc; unsigned int newcpu; fixpt_t loadfac; SCHED_ASSERT_LOCKED(); newcpu = p->p_estcpu; loadfac = loadfactor(averunnable.ldavg[0]); - if (p->p_slptime > 5 * loadfac) - p->p_estcpu = 0; + if (l->l_slptime > 5 * loadfac) + p->p_estcpu = 0; /* XXX NJWLWP */ else { - p->p_slptime--; /* the first time was done in schedcpu */ - while (newcpu && --p->p_slptime) + l->l_slptime--; /* the first time was done in schedcpu */ + while (newcpu && --l->l_slptime) newcpu = (int) decay_cpu(loadfac, newcpu); p->p_estcpu = newcpu; } - resetpriority(p); + resetpriority(l); } /* * During autoconfiguration or after a panic, a sleep will simply @@ -359,13 +368,15 @@ int ltsleep(void *ident, int priority, const char *wmesg, int timo, __volatile struct simplelock *interlock) { - struct proc *p = curproc; + struct lwp *l = curproc; + struct proc *p = l->l_proc; struct slpque *qp; int sig, s; int catch = priority & PCATCH; int relock = (priority & PNORELOCK) == 0; + int exiterr = (priority & PNOEXITERR) == 0; /* * XXXSMP * This is probably bogus. Figure out what the right @@ -373,9 +384,9 @@ * Note that not sleeping if ltsleep is called with curproc == NULL * in the shutdown case is disgusting but partly necessary given * how shutdown (barely) works. */ - if (cold || (doing_shutdown && (panicstr || (p == NULL)))) { + if (cold || (doing_shutdown && (panicstr || (l == NULL)))) { /* * After a panic, or during autoconfiguration, * just give interrupts a chance, then just return; * don't run any other procs or panic below, @@ -399,28 +410,29 @@ #ifdef DIAGNOSTIC if (ident == NULL) panic("ltsleep: ident == NULL"); - if (p->p_stat != SONPROC) - panic("ltsleep: p_stat %d != SONPROC", p->p_stat); - if (p->p_back != NULL) + if (l->l_stat != LSONPROC) + panic("ltsleep: l_stat %d != LSONPROC", l->l_stat); + if (l->l_back != NULL) panic("ltsleep: p_back != NULL"); #endif - p->p_wchan = ident; - p->p_wmesg = wmesg; - p->p_slptime = 0; - p->p_priority = priority & PRIMASK; + l->l_wchan = ident; + l->l_wmesg = wmesg; + l->l_slptime = 0; + l->l_priority = priority & PRIMASK; qp = SLPQUE(ident); if (qp->sq_head == 0) - qp->sq_head = p; - else - *qp->sq_tailp = p; - *(qp->sq_tailp = &p->p_forw) = 0; + qp->sq_head = l; + else { + *qp->sq_tailp = l; + } + *(qp->sq_tailp = &l->l_forw) = 0; if (timo) - callout_reset(&p->p_tsleep_ch, timo, endtsleep, p); + callout_reset(&l->l_tsleep_ch, timo, endtsleep, l); /* * We can now release the interlock; the scheduler_slock * is held, so a thread can't get in to do wakeup() before @@ -442,28 +454,31 @@ * when CURSIG is called. If the wakeup happens while we're * stopped, p->p_wchan will be 0 upon return from CURSIG. */ if (catch) { - p->p_flag |= P_SINTR; - if ((sig = CURSIG(p)) != 0) { - if (p->p_wchan != NULL) - unsleep(p); - p->p_stat = SONPROC; + l->l_flag |= L_SINTR; + if ((sig = CURSIG(l)) != 0) { + if (l->l_wchan != NULL) + unsleep(l); + l->l_stat = LSONPROC; SCHED_UNLOCK(s); goto resume; } - if (p->p_wchan == NULL) { + if (l->l_wchan == NULL) { catch = 0; SCHED_UNLOCK(s); goto resume; } } else sig = 0; - p->p_stat = SSLEEP; + l->l_stat = LSSLEEP; + p->p_nrlwps--; p->p_stats->p_ru.ru_nvcsw++; - SCHED_ASSERT_LOCKED(); - mi_switch(p); + if (l->l_flag & L_SA) + sa_switch(l, SA_UPCALL_BLOCKED); + else + mi_switch(l, NULL); #ifdef DDB /* handy breakpoint location after process "wakes" */ asm(".globl bpendtsleep ; bpendtsleep:"); @@ -472,15 +487,16 @@ SCHED_ASSERT_UNLOCKED(); splx(s); resume: - KDASSERT(p->p_cpu != NULL); - KDASSERT(p->p_cpu == curcpu()); - p->p_cpu->ci_schedstate.spc_curpriority = p->p_usrpri; - - p->p_flag &= ~P_SINTR; - if (p->p_flag & P_TIMEOUT) { - p->p_flag &= ~P_TIMEOUT; + KDASSERT(l->l_cpu != NULL); + KDASSERT(l->l_cpu == curcpu()); + l->l_cpu->ci_schedstate.spc_curpriority = l->l_usrpri; + p->p_nrlwps++; + + l->l_flag &= ~L_SINTR; + if (l->l_flag & L_TIMEOUT) { + l->l_flag &= ~L_TIMEOUT; if (sig == 0) { #ifdef KTRACE if (KTRPOINT(p, KTR_CSW)) ktrcsw(p, 0, 0); @@ -489,10 +505,10 @@ simple_lock(interlock); return (EWOULDBLOCK); } } else if (timo) - callout_stop(&p->p_tsleep_ch); - if (catch && (sig != 0 || (sig = CURSIG(p)) != 0)) { + callout_stop(&l->l_tsleep_ch); + if (catch && (sig != 0 || (sig = CURSIG(l)) != 0)) { #ifdef KTRACE if (KTRPOINT(p, KTR_CSW)) ktrcsw(p, 0, 0); #endif @@ -501,8 +517,15 @@ if ((SIGACTION(p, sig).sa_flags & SA_RESTART) == 0) return (EINTR); return (ERESTART); } + /* XXXNJW this is very much a kluge. + * revisit. a better way of preventing looping/hanging syscalls like + * wait4() and _lwp_wait() from wedging an exiting process + * would be preferred. + */ + if (catch && ((p->p_flag & P_WEXIT) && exiterr)) + return (EINTR); #ifdef KTRACE if (KTRPOINT(p, KTR_CSW)) ktrcsw(p, 0, 0); #endif @@ -519,68 +542,67 @@ */ void endtsleep(void *arg) { - struct proc *p; + struct lwp *l; int s; - p = (struct proc *)arg; - + l = (struct lwp *)arg; SCHED_LOCK(s); - if (p->p_wchan) { - if (p->p_stat == SSLEEP) - setrunnable(p); + if (l->l_wchan) { + if (l->l_stat == LSSLEEP) + setrunnable(l); else - unsleep(p); - p->p_flag |= P_TIMEOUT; + unsleep(l); + l->l_flag |= L_TIMEOUT; } SCHED_UNLOCK(s); } /* * Remove a process from its wait queue */ void -unsleep(struct proc *p) +unsleep(struct lwp *l) { struct slpque *qp; - struct proc **hp; + struct lwp **hp; SCHED_ASSERT_LOCKED(); - if (p->p_wchan) { - hp = &(qp = SLPQUE(p->p_wchan))->sq_head; - while (*hp != p) - hp = &(*hp)->p_forw; - *hp = p->p_forw; - if (qp->sq_tailp == &p->p_forw) + if (l->l_wchan) { + hp = &(qp = SLPQUE(l->l_wchan))->sq_head; + while (*hp != l) + hp = &(*hp)->l_forw; + *hp = l->l_forw; + if (qp->sq_tailp == &l->l_forw) qp->sq_tailp = hp; - p->p_wchan = 0; + l->l_wchan = 0; } } /* * Optimized-for-wakeup() version of setrunnable(). */ __inline void -awaken(struct proc *p) +awaken(struct lwp *l) { SCHED_ASSERT_LOCKED(); - - if (p->p_slptime > 1) - updatepri(p); - p->p_slptime = 0; - p->p_stat = SRUN; + + if (l->l_slptime > 1) + updatepri(l); + l->l_slptime = 0; + l->l_stat = LSRUN; /* * Since curpriority is a user priority, p->p_priority * is always better than curpriority. */ - if (p->p_flag & P_INMEM) { - setrunqueue(p); - KASSERT(p->p_cpu != NULL); - need_resched(p->p_cpu); + if (l->l_flag & L_INMEM) { + setrunqueue(l); + KASSERT(l->l_cpu != NULL); + need_resched(l->l_cpu); } else sched_wakeup(&proc0); } @@ -619,30 +641,31 @@ void sched_wakeup(void *ident) { struct slpque *qp; - struct proc *p, **q; + struct lwp *l, **q; SCHED_ASSERT_LOCKED(); qp = SLPQUE(ident); restart: - for (q = &qp->sq_head; (p = *q) != NULL; ) { + for (q = &qp->sq_head; (l = *q) != NULL; ) { #ifdef DIAGNOSTIC - if (p->p_back || (p->p_stat != SSLEEP && p->p_stat != SSTOP)) + if (l->l_back || (l->l_stat != LSSLEEP && + l->l_stat != LSSTOP && l->l_stat != LSSUSPENDED)) panic("wakeup"); #endif - if (p->p_wchan == ident) { - p->p_wchan = 0; - *q = p->p_forw; - if (qp->sq_tailp == &p->p_forw) + if (l->l_wchan == ident) { + l->l_wchan = 0; + *q = l->l_forw; + if (qp->sq_tailp == &l->l_forw) qp->sq_tailp = q; - if (p->p_stat == SSLEEP) { - awaken(p); + if (l->l_stat == LSSLEEP) { + awaken(l); goto restart; } } else - q = &p->p_forw; + q = &l->l_forw; } } /* @@ -652,11 +675,11 @@ void wakeup_one(void *ident) { struct slpque *qp; - struct proc *p, **q; - struct proc *best_sleepp, **best_sleepq; - struct proc *best_stopp, **best_stopq; + struct lwp *l, **q; + struct lwp *best_sleepp, **best_sleepq; + struct lwp *best_stopp, **best_stopq; int s; best_sleepp = best_stopp = NULL; best_sleepq = best_stopq = NULL; @@ -664,24 +687,25 @@ SCHED_LOCK(s); qp = SLPQUE(ident); - for (q = &qp->sq_head; (p = *q) != NULL; q = &p->p_forw) { + for (q = &qp->sq_head; (l = *q) != NULL; q = &l->l_forw) { #ifdef DIAGNOSTIC - if (p->p_back || (p->p_stat != SSLEEP && p->p_stat != SSTOP)) + if (l->l_back || (l->l_stat != LSSLEEP && + l->l_stat != LSSTOP && l->l_stat != LSSUSPENDED)) panic("wakeup_one"); #endif - if (p->p_wchan == ident) { - if (p->p_stat == SSLEEP) { + if (l->l_wchan == ident) { + if (l->l_stat == LSSLEEP) { if (best_sleepp == NULL || - p->p_priority < best_sleepp->p_priority) { - best_sleepp = p; + l->l_priority < best_sleepp->l_priority) { + best_sleepp = l; best_sleepq = q; } } else { if (best_stopp == NULL || - p->p_priority < best_stopp->p_priority) { - best_stopp = p; + l->l_priority < best_stopp->l_priority) { + best_stopp = l; best_stopq = q; } } } @@ -691,22 +715,22 @@ * Consider any SSLEEP process higher than the highest priority SSTOP * process. */ if (best_sleepp != NULL) { - p = best_sleepp; + l = best_sleepp; q = best_sleepq; } else { - p = best_stopp; + l = best_stopp; q = best_stopq; } - if (p != NULL) { - p->p_wchan = NULL; - *q = p->p_forw; - if (qp->sq_tailp == &p->p_forw) + if (l != NULL) { + l->l_wchan = NULL; + *q = l->l_forw; + if (qp->sq_tailp == &l->l_forw) qp->sq_tailp = q; - if (p->p_stat == SSLEEP) - awaken(p); + if (l->l_stat == LSSLEEP) + awaken(l); } SCHED_UNLOCK(s); } @@ -716,17 +740,17 @@ */ void yield(void) { - struct proc *p = curproc; + struct lwp *l = curproc; int s; SCHED_LOCK(s); - p->p_priority = p->p_usrpri; - p->p_stat = SRUN; - setrunqueue(p); - p->p_stats->p_ru.ru_nvcsw++; - mi_switch(p); + l->l_priority = l->l_usrpri; + l->l_stat = LSRUN; + setrunqueue(l); + l->l_proc->p_stats->p_ru.ru_nvcsw++; + mi_switch(l, NULL); SCHED_ASSERT_UNLOCKED(); splx(s); } @@ -735,45 +759,48 @@ * and performs an involuntary context switch. If a process is supplied, * we switch to that process. Otherwise, we use the normal process selection * criteria. */ + void -preempt(struct proc *newp) +preempt(struct lwp *newl) { - struct proc *p = curproc; - int s; + struct lwp *l = curproc; + int r, s; - /* - * XXX Switching to a specific process is not supported yet. - */ - if (newp != NULL) - panic("preempt: cpu_preempt not yet implemented"); - SCHED_LOCK(s); - p->p_priority = p->p_usrpri; - p->p_stat = SRUN; - setrunqueue(p); - p->p_stats->p_ru.ru_nivcsw++; - mi_switch(p); + l->l_priority = l->l_usrpri; + l->l_stat = LSRUN; + setrunqueue(l); + l->l_proc->p_stats->p_ru.ru_nivcsw++; + r = mi_switch(l, newl); + if (r && (l->l_flag & L_SA)) + sa_upcall(l, SA_UPCALL_PREEMPTED, l, NULL, 0, 0); SCHED_ASSERT_UNLOCKED(); splx(s); } /* * The machine independent parts of context switch. * Must be called at splsched() (no higher!) and with * the sched_lock held. + * Switch to "new" if non-NULL, otherwise let cpu_switch choose + * the next lwp. + * + * Returns 1 if another process was actually run. */ -void -mi_switch(struct proc *p) +int +mi_switch(struct lwp *l, struct lwp *new) { struct schedstate_percpu *spc; struct rlimit *rlim; long s, u; struct timeval tv; #if defined(MULTIPROCESSOR) int hold_count; #endif + struct proc *p = l->l_proc; + int retval; SCHED_ASSERT_LOCKED(); #if defined(MULTIPROCESSOR) @@ -785,12 +812,12 @@ if (p->p_flag & P_BIGLOCK) hold_count = spinlock_release_all(&kernel_lock); #endif - KDASSERT(p->p_cpu != NULL); - KDASSERT(p->p_cpu == curcpu()); + KDASSERT(l->l_cpu != NULL); + KDASSERT(l->l_cpu == curcpu()); - spc = &p->p_cpu->ci_schedstate; + spc = &l->l_cpu->ci_schedstate; #if defined(LOCKDEBUG) || defined(DIAGNOSTIC) spinlock_switchcheck(); #endif @@ -802,9 +829,10 @@ * Compute the amount of time during which the current * process was running, and add that to its total so far. */ microtime(&tv); - u = p->p_rtime.tv_usec + (tv.tv_usec - spc->spc_runtime.tv_usec); + u = p->p_rtime.tv_usec + + (tv.tv_usec - spc->spc_runtime.tv_usec); s = p->p_rtime.tv_sec + (tv.tv_sec - spc->spc_runtime.tv_sec); if (u < 0) { u += 1000000; s--; @@ -836,9 +864,9 @@ } if (autonicetime && s > autonicetime && p->p_ucred->cr_uid && p->p_nice == NZERO) { p->p_nice = autoniceval + NZERO; - resetpriority(p); + resetpriority(l); } /* * Process is about to yield the CPU; clear the appropriate @@ -850,9 +878,14 @@ * Pick a new current process and switch to it. When we * run again, we'll return back here. */ uvmexp.swtch++; - cpu_switch(p); + if (new == NULL) { + retval = cpu_switch(l); + } else { + cpu_preempt(l, new); + retval = 0; + } /* * Make sure that MD code released the scheduler lock before * resuming us. @@ -863,11 +896,11 @@ * We're running again; record our new start time. We might * be running on a new CPU now, so don't use the cache'd * schedstate_percpu pointer. */ - KDASSERT(p->p_cpu != NULL); - KDASSERT(p->p_cpu == curcpu()); - microtime(&p->p_cpu->ci_schedstate.spc_runtime); + KDASSERT(l->l_cpu != NULL); + KDASSERT(l->l_cpu == curcpu()); + microtime(&l->l_cpu->ci_schedstate.spc_runtime); #if defined(MULTIPROCESSOR) /* * Reacquire the kernel_lock now. We do this after we've @@ -876,8 +909,10 @@ */ if (p->p_flag & P_BIGLOCK) spinlock_acquire_count(&kernel_lock, hold_count); #endif + + return retval; } /* * Initialize the (doubly-linked) run queues @@ -889,56 +924,59 @@ int i; for (i = 0; i < RUNQUE_NQS; i++) sched_qs[i].ph_link = sched_qs[i].ph_rlink = - (struct proc *)&sched_qs[i]; + (struct lwp *)&sched_qs[i]; } /* * Change process state to be runnable, * placing it on the run queue if it is in memory, * and awakening the swapper if it isn't in memory. */ void -setrunnable(struct proc *p) +setrunnable(struct lwp *l) { + struct proc *p = l->l_proc; SCHED_ASSERT_LOCKED(); - switch (p->p_stat) { + switch (l->l_stat) { case 0: - case SRUN: - case SONPROC: - case SZOMB: - case SDEAD: + case LSRUN: + case LSONPROC: + case LSZOMB: + case LSDEAD: default: panic("setrunnable"); - case SSTOP: + case LSSTOP: /* * If we're being traced (possibly because someone attached us * while we were stopped), check for a signal from the debugger. */ if ((p->p_flag & P_TRACED) != 0 && p->p_xstat != 0) { sigaddset(&p->p_sigctx.ps_siglist, p->p_xstat); CHECKSIGS(p); } - case SSLEEP: - unsleep(p); /* e.g. when sending signals */ + case LSSLEEP: + unsleep(l); /* e.g. when sending signals */ break; - case SIDL: + case LSIDL: + break; + case LSSUSPENDED: break; } - p->p_stat = SRUN; - if (p->p_flag & P_INMEM) - setrunqueue(p); - - if (p->p_slptime > 1) - updatepri(p); - p->p_slptime = 0; - if ((p->p_flag & P_INMEM) == 0) - sched_wakeup((caddr_t)&proc0); - else if (p->p_priority < curcpu()->ci_schedstate.spc_curpriority) { + l->l_stat = LSRUN; + if (l->l_flag & L_INMEM) + setrunqueue(l); + + if (l->l_slptime > 1) + updatepri(l); + l->l_slptime = 0; + if ((l->l_flag & L_INMEM) == 0) + wakeup((caddr_t)&proc0); + else if (l->l_priority < curcpu()->ci_schedstate.spc_curpriority) { /* * XXXSMP * This is not exactly right. Since p->p_cpu persists * across a context switch, this gives us some sort @@ -955,17 +993,19 @@ * Arrange to reschedule if the resulting priority is better * than that of the current process. */ void -resetpriority(struct proc *p) +resetpriority(struct lwp *l) { unsigned int newpriority; + struct proc *p = l->l_proc; SCHED_ASSERT_LOCKED(); - newpriority = PUSER + p->p_estcpu + NICE_WEIGHT * (p->p_nice - NZERO); + newpriority = PUSER + p->p_estcpu + + NICE_WEIGHT * (p->p_nice - NZERO); newpriority = min(newpriority, MAXPRI); - p->p_usrpri = newpriority; + l->l_usrpri = newpriority; if (newpriority < curcpu()->ci_schedstate.spc_curpriority) { /* * XXXSMP * Same applies as in setrunnable() above. @@ -973,8 +1013,20 @@ need_resched((p->p_cpu != NULL) ? p->p_cpu : curcpu()); } } +/* + * Recompute priority for all LWPs in a process. + */ +void +resetprocpriority(struct proc *p) +{ + struct lwp *l; + + LIST_FOREACH(l, &p->p_lwps, l_list) + resetpriority(l); +} + /* * We adjust the priority of the current process. The priority of a process * gets worse as it accumulates CPU time. The cpu usage estimator (p_estcpu) * is increased here. The formula for computing priorities (in kern_synch.c) @@ -989,45 +1041,47 @@ * processes. */ void -schedclock(struct proc *p) +schedclock(struct lwp *l) { + struct proc *p = l->l_proc; int s; p->p_estcpu = ESTCPULIM(p->p_estcpu + 1); - SCHED_LOCK(s); - resetpriority(p); + resetpriority(l); SCHED_UNLOCK(s); - - if (p->p_priority >= PUSER) - p->p_priority = p->p_usrpri; + + if (l->l_priority >= PUSER) + l->l_priority = l->l_usrpri; } void suspendsched() { - struct proc *p; + struct lwp *l; int s; /* - * Convert all non-P_SYSTEM SSLEEP or SRUN processes to SSTOP. + * Convert all non-P_SYSTEM LSSLEEP or LSRUN processes to + * LSSUSPENDED. */ proclist_lock_read(); SCHED_LOCK(s); - for (p = LIST_FIRST(&allproc); p != NULL; p = LIST_NEXT(p, p_list)) { - if ((p->p_flag & P_SYSTEM) != 0) + for (l = LIST_FIRST(&alllwp); l != NULL; l = LIST_NEXT(l, l_list)) { + if ((l->l_proc->p_flag & P_SYSTEM) != 0) continue; - switch (p->p_stat) { - case SRUN: - if ((p->p_flag & P_INMEM) != 0) - remrunqueue(p); + + switch (l->l_stat) { + case LSRUN: + if ((l->l_flag & L_INMEM) != 0) + remrunqueue(l); /* FALLTHROUGH */ - case SSLEEP: - p->p_stat = SSTOP; + case LSSLEEP: + l->l_stat = LSSUSPENDED; break; - case SONPROC: + case LSONPROC: /* * XXX SMP: we need to deal with processes on * others CPU ! */ @@ -1038,4 +1092,6 @@ } SCHED_UNLOCK(s); proclist_unlock_read(); } + + Index: sys/kern/kern_sysctl.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_sysctl.c,v retrieving revision 1.87 retrieving revision 1.86.2.3 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.87 -r1.86.2.3 --- sys/kern/kern_sysctl.c 2001/03/15 06:10:55 1.87 +++ sys/kern/kern_sysctl.c 2001/04/09 01:57:54 1.86.2.3 @@ -61,8 +61,9 @@ #include #include #include #include +#include #include #include #include #include @@ -109,8 +110,10 @@ #if NPTY > 0 static int sysctl_pty __P((void *, size_t *, void *, size_t)); #endif +static struct lwp *proc_representative_lwp(struct proc *); + /* * The `sysctl_memlock' is intended to keep too many processes from * locking down memory by doing sysctls at once. Whether or not this * is really a good idea to worry about it probably a subject of some @@ -125,10 +128,10 @@ lockinit(&sysctl_memlock, PRIBIO|PCATCH, "sysctl", 0, 0); } int -sys___sysctl(p, v, retval) - struct proc *p; +sys___sysctl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys___sysctl_args /* { @@ -138,8 +141,9 @@ syscallarg(size_t *) oldlenp; syscallarg(void *) new; syscallarg(size_t) newlen; } */ *uap = v; + struct proc *p = l->l_proc; int error; size_t savelen = 0, oldlen = 0; sysctlfn *fn; int name[CTL_MAXNAME]; @@ -1496,8 +1500,9 @@ struct proc *p; struct eproc *ep; { struct tty *tp; + struct lwp *l; ep->e_paddr = p; ep->e_sess = p->p_session; ep->e_pcred = *p->p_cred; @@ -1514,8 +1519,14 @@ ep->e_vm.vm_rssize = vm_resident_count(vm); ep->e_vm.vm_tsize = vm->vm_tsize; ep->e_vm.vm_dsize = vm->vm_dsize; ep->e_vm.vm_ssize = vm->vm_ssize; + + /* Pick a "representative" LWP */ + l = proc_representative_lwp(p); + + if (l->l_wmesg) + strncpy(ep->e_wmesg, l->l_wmesg, WMESGLEN); } if (p->p_pptr) ep->e_ppid = p->p_pptr->p_pid; else @@ -1529,10 +1540,9 @@ ep->e_tpgid = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID; ep->e_tsess = tp->t_session; } else ep->e_tdev = NODEV; - if (p->p_wmesg) - strncpy(ep->e_wmesg, p->p_wmesg, WMESGLEN); + ep->e_xsize = ep->e_xrssize = 0; ep->e_xccount = ep->e_xswrss = 0; ep->e_flag = ep->e_sess->s_ttyvp ? EPROC_CTTY : 0; if (SESS_LEADER(p)) @@ -1548,16 +1558,16 @@ struct proc *p; struct kinfo_proc2 *ki; { struct tty *tp; - + struct lwp *l; memset(ki, 0, sizeof(*ki)); - ki->p_forw = PTRTOINT64(p->p_forw); - ki->p_back = PTRTOINT64(p->p_back); + /* XXX NJWLWP + * These are likely not what the caller was looking for. + * The perils of playing with the kernel data structures... + */ ki->p_paddr = PTRTOINT64(p); - - ki->p_addr = PTRTOINT64(p->p_addr); ki->p_fd = PTRTOINT64(p->p_fd); ki->p_cwdi = PTRTOINT64(p->p_cwdi); ki->p_stats = PTRTOINT64(p->p_stats); ki->p_limit = PTRTOINT64(p->p_limit); @@ -1603,45 +1613,31 @@ ki->p_rtime_sec = p->p_rtime.tv_sec; ki->p_rtime_usec = p->p_rtime.tv_usec; ki->p_cpticks = p->p_cpticks; ki->p_pctcpu = p->p_pctcpu; - ki->p_swtime = p->p_swtime; - ki->p_slptime = p->p_slptime; - if (p->p_stat == SONPROC) { - KDASSERT(p->p_cpu != NULL); - ki->p_schedflags = p->p_cpu->ci_schedstate.spc_flags; - } else - ki->p_schedflags = 0; ki->p_uticks = p->p_uticks; ki->p_sticks = p->p_sticks; ki->p_iticks = p->p_iticks; ki->p_tracep = PTRTOINT64(p->p_tracep); ki->p_traceflag = p->p_traceflag; - ki->p_holdcnt = p->p_holdcnt; memcpy(&ki->p_siglist, &p->p_sigctx.ps_siglist, sizeof(ki_sigset_t)); memcpy(&ki->p_sigmask, &p->p_sigctx.ps_sigmask, sizeof(ki_sigset_t)); memcpy(&ki->p_sigignore, &p->p_sigctx.ps_sigignore,sizeof(ki_sigset_t)); memcpy(&ki->p_sigcatch, &p->p_sigctx.ps_sigcatch, sizeof(ki_sigset_t)); ki->p_stat = p->p_stat; - ki->p_priority = p->p_priority; - ki->p_usrpri = p->p_usrpri; ki->p_nice = p->p_nice; ki->p_xstat = p->p_xstat; ki->p_acflag = p->p_acflag; strncpy(ki->p_comm, p->p_comm, min(sizeof(ki->p_comm), sizeof(p->p_comm))); - if (p->p_wmesg) - strncpy(ki->p_wmesg, p->p_wmesg, sizeof(ki->p_wmesg)); - ki->p_wchan = PTRTOINT64(p->p_wchan); - strncpy(ki->p_login, p->p_session->s_login, sizeof(ki->p_login)); if (p->p_stat == SIDL || P_ZOMBIE(p)) { ki->p_vm_rssize = 0; @@ -1654,17 +1650,37 @@ ki->p_vm_rssize = vm_resident_count(vm); ki->p_vm_tsize = vm->vm_tsize; ki->p_vm_dsize = vm->vm_dsize; ki->p_vm_ssize = vm->vm_ssize; + + /* Pick a "representative" LWP */ + l = proc_representative_lwp(p); + ki->p_forw = PTRTOINT64(l->l_forw); + ki->p_back = PTRTOINT64(l->l_back); + ki->p_addr = PTRTOINT64(l->l_addr); + ki->p_swtime = l->l_swtime; + ki->p_slptime = l->l_slptime; + if (l->l_stat == LSONPROC) { + KDASSERT(l->l_cpu != NULL); + ki->p_schedflags = l->l_cpu->ci_schedstate.spc_flags; + } else + ki->p_schedflags = 0; + ki->p_holdcnt = l->l_holdcnt; + ki->p_priority = l->l_priority; + ki->p_usrpri = l->l_usrpri; + if (l->l_wmesg) + strncpy(ki->p_wmesg, l->l_wmesg, sizeof(ki->p_wmesg)); + ki->p_wchan = PTRTOINT64(l->l_wchan); + } if (p->p_session->s_ttyvp) ki->p_eflag |= EPROC_CTTY; if (SESS_LEADER(p)) ki->p_eflag |= EPROC_SLEADER; /* XXX Is this double check necessary? */ - if ((p->p_flag & P_INMEM) == 0 || P_ZOMBIE(p)) { + if (P_ZOMBIE(p)) { ki->p_uvalid = 0; } else { ki->p_uvalid = 1; @@ -1701,10 +1717,69 @@ ki->p_cpuid = p->p_cpu->ci_cpuid; else #endif ki->p_cpuid = KI_NOCPU; + } + +/* + * Pick a LWP to represent the process for those operations which + * want information about a "process" that is actually associated + * with a LWP. + */ +static struct lwp *proc_representative_lwp(p) + struct proc *p; +{ + struct lwp *l = NULL; + + /* Trivial case: only one LWP */ + if (p->p_nrlwps == 1) + return (LIST_FIRST(&p->p_lwps)); + + switch (p->p_stat) { + case SSTOP: + /* Pick the first stopped LWP */ + LIST_FOREACH(l, &p->p_lwps, l_sibling) { + if (l->l_stat == LSSTOP) + return (l); + } + /* NOTREACHED */ + break; + case SACTIVE: + /* Pick the first live LWP */ + LIST_FOREACH(l, &p->p_lwps, l_sibling) { + if (l->l_stat == LSRUN || + l->l_stat == LSSLEEP || + l->l_stat == LSONPROC) + return (l); + } + break; + case SDEAD: + case SZOMB: + /* Doesn't really matter... */ + l = LIST_FIRST(&p->p_lwps); + break; +#ifdef DIAGNOSTIC + case SIDL: + /* We have more than one LWP and we're in SIDL? + * How'd that happen? + */ + panic("Too many LWPs (%d) in SIDL process %d (%s)", + p->p_nrlwps, p->p_pid, p->p_comm); + default: + panic("Process %d (%s) in unknown state %d", + p->p_pid, p->p_comm, p->p_stat); +#endif + } + + panic("proc_representative_lwp: couldn't find a lwp for process" + " %d (%s)", p->p_pid, p->p_comm); + /* NOTREACHED */ + return NULL; +} + + int sysctl_procargs(name, namelen, where, sizep, up) int *name; u_int namelen; @@ -1774,8 +1849,9 @@ */ /* XXXCDC: how should locking work here? */ if ((p->p_flag & P_WEXIT) || (p->p_vmspace->vm_refcnt < 1)) return (EFAULT); + p->p_vmspace->vm_refcnt++; /* XXX */ /* * Allocate a temporary buffer to hold the arguments. Index: sys/kern/kern_time.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_time.c,v retrieving revision 1.54 retrieving revision 1.54.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.54 -r1.54.2.1 --- sys/kern/kern_time.c 2000/09/19 23:26:25 1.54 +++ sys/kern/kern_time.c 2001/03/05 22:49:43 1.54.2.1 @@ -78,8 +78,9 @@ #include #include #include #include +#include #include #include #include #include @@ -146,10 +147,10 @@ } /* ARGSUSED */ int -sys_clock_gettime(p, v, retval) - struct proc *p; +sys_clock_gettime(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_clock_gettime_args /* { @@ -171,17 +172,18 @@ } /* ARGSUSED */ int -sys_clock_settime(p, v, retval) - struct proc *p; +sys_clock_settime(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_clock_settime_args /* { syscallarg(clockid_t) clock_id; syscallarg(const struct timespec *) tp; } */ *uap = v; + struct proc *p = l->l_proc; clockid_t clock_id; struct timeval atv; struct timespec ats; int error; @@ -203,10 +205,10 @@ return 0; } int -sys_clock_getres(p, v, retval) - struct proc *p; +sys_clock_getres(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_clock_getres_args /* { @@ -232,10 +234,10 @@ } /* ARGSUSED */ int -sys_nanosleep(p, v, retval) - struct proc *p; +sys_nanosleep(l, v, retval) + struct lwp *l; void *v; register_t *retval; { static int nanowait; @@ -295,10 +297,10 @@ } /* ARGSUSED */ int -sys_gettimeofday(p, v, retval) - struct proc *p; +sys_gettimeofday(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_gettimeofday_args /* { @@ -328,17 +330,18 @@ } /* ARGSUSED */ int -sys_settimeofday(p, v, retval) - struct proc *p; +sys_settimeofday(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_settimeofday_args /* { syscallarg(const struct timeval *) tv; syscallarg(const struct timezone *) tzp; } */ *uap = v; + struct proc *p = l->l_proc; struct timeval atv; struct timezone atz; int error; @@ -370,17 +373,18 @@ long bigadj = 1000000; /* use 10x skew above bigadj us. */ /* ARGSUSED */ int -sys_adjtime(p, v, retval) - struct proc *p; +sys_adjtime(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_adjtime_args /* { syscallarg(const struct timeval *) delta; syscallarg(struct timeval *) olddelta; } */ *uap = v; + struct proc *p = l->l_proc; struct timeval atv; long ndelta, ntickdelta, odelta; int s, error; @@ -454,17 +458,18 @@ * absolute time the timer should go off. */ /* ARGSUSED */ int -sys_getitimer(p, v, retval) - struct proc *p; +sys_getitimer(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_getitimer_args /* { syscallarg(int) which; syscallarg(struct itimerval *) itv; } */ *uap = v; + struct proc *p = l->l_proc; int which = SCARG(uap, which); struct itimerval aitv; int s; @@ -492,18 +497,19 @@ } /* ARGSUSED */ int -sys_setitimer(p, v, retval) - struct proc *p; +sys_setitimer(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_setitimer_args /* { syscallarg(int) which; syscallarg(const struct itimerval *) itv; syscallarg(struct itimerval *) oitv; } */ *uap = v; + struct proc *p = l->l_proc; int which = SCARG(uap, which); struct sys_getitimer_args getargs; struct itimerval aitv; const struct itimerval *itvp; @@ -516,9 +522,9 @@ return (error); if (SCARG(uap, oitv) != NULL) { SCARG(&getargs, which) = which; SCARG(&getargs, itv) = SCARG(uap, oitv); - if ((error = sys_getitimer(p, &getargs, retval)) != 0) + if ((error = sys_getitimer(l, &getargs, retval)) != 0) return (error); } if (itvp == 0) return (0); Index: sys/kern/kern_xxx.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kern_xxx.c,v retrieving revision 1.45 retrieving revision 1.45.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.45 -r1.45.2.1 --- sys/kern/kern_xxx.c 2000/11/21 00:37:56 1.45 +++ sys/kern/kern_xxx.c 2001/03/05 22:49:43 1.45.2.1 @@ -39,8 +39,9 @@ #include #include #include +#include #include #include #include #include @@ -48,17 +49,18 @@ #include /* ARGSUSED */ int -sys_reboot(p, v, retval) - struct proc *p; +sys_reboot(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_reboot_args /* { syscallarg(int) opt; syscallarg(char *) bootstr; } */ *uap = v; + struct proc *p = l->l_proc; int error; char *bootstr, bs[128]; if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) @@ -91,12 +93,13 @@ int scdebug = SCDEBUG_CALLS|SCDEBUG_RETURNS|SCDEBUG_SHOWARGS|SCDEBUG_ALL; #endif void -scdebug_call(p, code, args) - struct proc *p; +scdebug_call(l, code, args) + struct lwp *l; register_t code, args[]; { + struct proc *p = l->l_proc const struct sysent *sy; const struct emul *em; int i; @@ -126,14 +129,15 @@ printf("\n"); } void -scdebug_ret(p, code, error, retval) - struct proc *p; +scdebug_ret(l, code, error, retval) + struct lwp *l; register_t code; int error; register_t retval[]; { + struct proc *p = l->l_proc; const struct sysent *sy; const struct emul *em; if (!(scdebug & SCDEBUG_RETURNS)) Index: sys/kern/kgdb_stub.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/kgdb_stub.c,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.7 -r1.7.2.1 --- sys/kern/kgdb_stub.c 2000/07/18 21:49:08 1.7 +++ sys/kern/kgdb_stub.c 2001/03/05 22:49:43 1.7.2.1 @@ -51,10 +51,16 @@ #include #include #include -/* #define DEBUG_KGDB XXX */ +#undef DEBUG_KGDB +#ifdef DEBUG_KGDB +#define DPRINTF(x) printf x +#else +#define DPRINTF(x) +#endif + /* XXX: Maybe these should be in the MD files? */ #ifndef KGDBDEV #define KGDBDEV -1 #endif @@ -232,11 +238,9 @@ { u_char *p; u_char csum, c; -#ifdef DEBUG_KGDB - printf("kgdb_send: %s\n", bp); -#endif + DPRINTF(("kgdb_send: %s\n", bp)); do { p = bp; PUTC(KGDB_START); for (csum = 0; (c = *p); p++) { @@ -257,50 +261,61 @@ u_char *bp; int maxlen; { u_char *p; - int c, csum; + int c, csum, tmpcsum; int len; + DPRINTF(("kgdb_recv: ")); do { p = bp; csum = len = 0; while ((c = GETC()) != KGDB_START) - ; + DPRINTF(("%c",c)); + DPRINTF(("%c Start ",c)); while ((c = GETC()) != KGDB_END && len < maxlen) { + DPRINTF(("%c",c)); c &= 0x7f; csum += c; *p++ = c; len++; } csum &= 0xff; *p = '\0'; + DPRINTF(("%c End ", c)); if (len >= maxlen) { + DPRINTF(("Long- ")); PUTC(KGDB_BADP); continue; } + tmpcsum = csum; - csum -= digit2i(GETC()) * 16; - csum -= digit2i(GETC()); + c = GETC(); + DPRINTF(("%c",c)); + csum -= digit2i(c) * 16; + c = GETC(); + DPRINTF(("%c",c)); + csum -= digit2i(c); if (csum == 0) { + DPRINTF(("Good+ ")); PUTC(KGDB_GOODP); /* Sequence present? */ if (bp[2] == ':') { + DPRINTF(("Seq %c%c ", bp[0], bp[1])); PUTC(bp[0]); PUTC(bp[1]); len -= 3; kgdb_copy(bp + 3, bp, len); } break; } + DPRINTF((" Bad(wanted %x, off by %d)- ", tmpcsum, csum)); PUTC(KGDB_BADP); } while (1); -#ifdef DEBUG_KGDB - printf("kgdb_recv: %s\n", bp); -#endif + DPRINTF(("kgdb_recv: %s\n", bp)); return (len); } /* @@ -333,8 +348,10 @@ vaddr_t addr; size_t len; u_char *p; + printf("kgdb_trap 1\n"); + if (kgdb_dev < 0 || kgdb_getc == NULL) { /* not debugging */ return (0); } @@ -504,9 +521,16 @@ kgdb_send("E0B"); continue; } PC_REGS(regs) = addr; + DPRINTF(("kgdb: continuing at %08lx\n", addr)) + + } else { + DPRINTF(( + "kgdb: continuing at old address %08lx\n", + PC_REGS(regs))); } + db_clear_single_step(regs); goto out; case KGDB_STEP: Index: sys/kern/makesyscalls.sh =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/makesyscalls.sh,v retrieving revision 1.46 retrieving revision 1.45.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.46 -r1.45.2.2 --- sys/kern/makesyscalls.sh 2001/03/30 16:56:36 1.46 +++ sys/kern/makesyscalls.sh 2001/04/09 01:57:55 1.45.2.2 @@ -374,9 +374,9 @@ # output syscall declaration for switch table. INDIR functions # get none, since they always have sys_nosys() for their table # entries. if (nodefs != "INDIR") { - prototype = "(struct proc *, void *, register_t *)" + prototype = "(struct lwp *, void *, register_t *)" if (compatwrap == "") printf("int\t%s%s;\n", funcname, prototype) > sysprotos else Index: sys/kern/subr_prf.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/subr_prf.c,v retrieving revision 1.77 retrieving revision 1.76.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.77 -r1.76.2.2 --- sys/kern/subr_prf.c 2001/03/09 13:35:50 1.77 +++ sys/kern/subr_prf.c 2001/04/09 01:57:55 1.76.2.2 @@ -48,8 +48,9 @@ #include #include #include #include +#include #include #include #include #include @@ -444,9 +445,9 @@ char *fmt; va_dcl #endif { - struct proc *p = curproc; + struct proc *p = curproc->l_proc; va_list ap; if (p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) { /* No mutex needed; going to process TTY. */ Index: sys/kern/subr_prof.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/subr_prof.c,v retrieving revision 1.22 retrieving revision 1.22.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.22 -r1.22.2.1 --- sys/kern/subr_prof.c 2000/12/10 19:29:31 1.22 +++ sys/kern/subr_prof.c 2001/03/05 22:49:44 1.22.2.1 @@ -37,8 +37,9 @@ #include #include #include +#include #include #include #include #include @@ -155,10 +156,10 @@ * 1.0 is represented as 0x10000. A scale factor of 0 turns off profiling. */ /* ARGSUSED */ int -sys_profil(p, v, retval) - struct proc *p; +sys_profil(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_profil_args /* { @@ -166,8 +167,9 @@ syscallarg(u_int) size; syscallarg(u_int) offset; syscallarg(u_int) scale; } */ *uap = v; + struct proc *p = l->l_proc; struct uprof *upp; int s; if (SCARG(uap, scale) > (1 << 16)) Index: sys/kern/sys_generic.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/sys_generic.c,v retrieving revision 1.54 retrieving revision 1.54.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.54 -r1.54.2.1 --- sys/kern/sys_generic.c 2001/02/27 04:44:51 1.54 +++ sys/kern/sys_generic.c 2001/03/05 22:49:44 1.54.2.1 @@ -46,8 +46,9 @@ #include #include #include #include +#include #include #include #include #include @@ -69,20 +70,22 @@ * Read system call. */ /* ARGSUSED */ int -sys_read(struct proc *p, void *v, register_t *retval) +sys_read(struct lwp *l, void *v, register_t *retval) { struct sys_read_args /* { syscallarg(int) fd; syscallarg(void *) buf; syscallarg(size_t) nbyte; } */ *uap = v; int fd; struct file *fp; + struct proc *p; struct filedesc *fdp; fd = SCARG(uap, fd); + p = l->l_proc; fdp = p->p_fd; if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL || (fp->f_iflags & FIF_WANTCLOSE) != 0 || @@ -154,20 +157,22 @@ /* * Scatter read system call. */ int -sys_readv(struct proc *p, void *v, register_t *retval) +sys_readv(struct lwp *l, void *v, register_t *retval) { struct sys_readv_args /* { syscallarg(int) fd; syscallarg(const struct iovec *) iovp; syscallarg(int) iovcnt; } */ *uap = v; int fd; struct file *fp; + struct proc *p; struct filedesc *fdp; fd = SCARG(uap, fd); + p = l->l_proc; fdp = p->p_fd; if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL || (fp->f_iflags & FIF_WANTCLOSE) != 0 || @@ -271,20 +276,22 @@ /* * Write system call */ int -sys_write(struct proc *p, void *v, register_t *retval) +sys_write(struct lwp *l, void *v, register_t *retval) { struct sys_write_args /* { syscallarg(int) fd; syscallarg(const void *) buf; syscallarg(size_t) nbyte; } */ *uap = v; int fd; struct file *fp; + struct proc *p; struct filedesc *fdp; fd = SCARG(uap, fd); + p = l->l_proc; fdp = p->p_fd; if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL || (fp->f_iflags & FIF_WANTCLOSE) != 0 || @@ -359,20 +366,22 @@ /* * Gather write system call */ int -sys_writev(struct proc *p, void *v, register_t *retval) +sys_writev(struct lwp *l, void *v, register_t *retval) { struct sys_writev_args /* { syscallarg(int) fd; syscallarg(const struct iovec *) iovp; syscallarg(int) iovcnt; } */ *uap = v; int fd; struct file *fp; + struct proc *p; struct filedesc *fdp; fd = SCARG(uap, fd); + p = l->l_proc; fdp = p->p_fd; if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL || (fp->f_iflags & FIF_WANTCLOSE) != 0 || @@ -478,16 +487,17 @@ * Ioctl system call */ /* ARGSUSED */ int -sys_ioctl(struct proc *p, void *v, register_t *retval) +sys_ioctl(struct lwp *l, void *v, register_t *retval) { struct sys_ioctl_args /* { syscallarg(int) fd; syscallarg(u_long) com; syscallarg(caddr_t) data; } */ *uap = v; struct file *fp; + struct proc *p; struct filedesc *fdp; u_long com; int error; u_int size; @@ -496,8 +506,9 @@ #define STK_PARAMS 128 u_long stkbuf[STK_PARAMS/sizeof(u_long)]; error = 0; + p = l->l_proc; fdp = p->p_fd; if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL || (fp->f_iflags & FIF_WANTCLOSE) != 0) @@ -625,25 +636,27 @@ /* * Select system call. */ int -sys_select(struct proc *p, void *v, register_t *retval) +sys_select(struct lwp *l, void *v, register_t *retval) { struct sys_select_args /* { syscallarg(int) nd; syscallarg(fd_set *) in; syscallarg(fd_set *) ou; syscallarg(fd_set *) ex; syscallarg(struct timeval *) tv; } */ *uap = v; + struct proc *p; caddr_t bits; char smallbits[howmany(FD_SETSIZE, NFDBITS) * sizeof(fd_mask) * 6]; struct timeval atv; int s, ncoll, error, timo; size_t ni; error = 0; + p = l->l_proc; if (SCARG(uap, nd) < 0) return (EINVAL); if (SCARG(uap, nd) > p->p_fd->fd_nfiles) { /* forgiving; slightly wrong */ @@ -682,9 +695,9 @@ } else timo = 0; retry: ncoll = nselcoll; - p->p_flag |= P_SELECT; + l->l_flag |= L_SELECT; error = selscan(p, (fd_mask *)(bits + ni * 0), (fd_mask *)(bits + ni * 3), SCARG(uap, nd), retval); if (error || *retval) goto done; @@ -696,19 +709,19 @@ if (timo <= 0) goto done; } s = splsched(); - if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) { + if ((l->l_flag & L_SELECT) == 0 || nselcoll != ncoll) { splx(s); goto retry; } - p->p_flag &= ~P_SELECT; + l->l_flag &= ~L_SELECT; error = tsleep((caddr_t)&selwait, PSOCK | PCATCH, "select", timo); splx(s); if (error == 0) goto retry; done: - p->p_flag &= ~P_SELECT; + l->l_flag &= ~L_SELECT; /* select is not restarted after signals... */ if (error == ERESTART) error = EINTR; if (error == EWOULDBLOCK) @@ -773,22 +786,24 @@ /* * Poll system call. */ int -sys_poll(struct proc *p, void *v, register_t *retval) +sys_poll(struct lwp *l, void *v, register_t *retval) { struct sys_poll_args /* { syscallarg(struct pollfd *) fds; syscallarg(u_int) nfds; syscallarg(int) timeout; } */ *uap = v; + struct proc *p; caddr_t bits; char smallbits[32 * sizeof(struct pollfd)]; struct timeval atv; int s, ncoll, error, timo; size_t ni; error = 0; + p = l->l_proc; if (SCARG(uap, nfds) > p->p_fd->fd_nfiles) { /* forgiving; slightly wrong */ SCARG(uap, nfds) = p->p_fd->fd_nfiles; } @@ -815,9 +830,9 @@ } else timo = 0; retry: ncoll = nselcoll; - p->p_flag |= P_SELECT; + l->l_flag |= L_SELECT; error = pollscan(p, (struct pollfd *)bits, SCARG(uap, nfds), retval); if (error || *retval) goto done; if (SCARG(uap, timeout) != INFTIM) { @@ -828,19 +843,19 @@ if (timo <= 0) goto done; } s = splsched(); - if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) { + if ((l->l_flag & L_SELECT) == 0 || nselcoll != ncoll) { splx(s); goto retry; } - p->p_flag &= ~P_SELECT; + l->l_flag &= ~L_SELECT; error = tsleep((caddr_t)&selwait, PSOCK | PCATCH, "select", timo); splx(s); if (error == 0) goto retry; done: - p->p_flag &= ~P_SELECT; + l->l_flag &= ~L_SELECT; /* poll is not restarted after signals... */ if (error == ERESTART) error = EINTR; if (error == EWOULDBLOCK) @@ -902,18 +917,22 @@ */ void selrecord(struct proc *selector, struct selinfo *sip) { + struct lwp *l; struct proc *p; pid_t mypid; mypid = selector->p_pid; if (sip->si_pid == mypid) return; - if (sip->si_pid && (p = pfind(sip->si_pid)) && - p->p_wchan == (caddr_t)&selwait) - sip->si_flags |= SI_COLL; - else + if (sip->si_pid && (p = pfind(sip->si_pid))) { + for (l = LIST_FIRST(&p->p_lwps); l != NULL; + l = LIST_NEXT(l, l_sibling)) { + if (l->l_wchan == (caddr_t)&selwait) + sip->si_flags |= SI_COLL; + } + } else sip->si_pid = mypid; } /* @@ -922,8 +941,9 @@ void selwakeup(sip) struct selinfo *sip; { + struct lwp *l; struct proc *p; int s; if (sip->si_pid == 0) @@ -935,15 +955,18 @@ } p = pfind(sip->si_pid); sip->si_pid = 0; if (p != NULL) { - SCHED_LOCK(s); - if (p->p_wchan == (caddr_t)&selwait) { - if (p->p_stat == SSLEEP) - setrunnable(p); - else - unsleep(p); - } else if (p->p_flag & P_SELECT) - p->p_flag &= ~P_SELECT; - SCHED_UNLOCK(s); + for (l = LIST_FIRST(&p->p_lwps); l != NULL; + l = LIST_NEXT(l, l_sibling)) { + SCHED_LOCK(s); + if (l->l_wchan == (caddr_t)&selwait) { + if (l->l_stat == LSSLEEP) + setrunnable(l); + else + unsleep(l); + } else if (l->l_flag & L_SELECT) + l->l_flag &= ~L_SELECT; + SCHED_UNLOCK(s); + } } } Index: sys/kern/sys_process.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/sys_process.c,v retrieving revision 1.67 retrieving revision 1.66.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.67 -r1.66.2.2 --- sys/kern/sys_process.c 2001/03/17 09:38:36 1.67 +++ sys/kern/sys_process.c 2001/04/09 01:57:56 1.66.2.2 @@ -53,8 +53,9 @@ */ #include #include +#include #include #include #include #include @@ -77,10 +78,10 @@ /* * Process debugging system call. */ int -sys_ptrace(p, v, retval) - struct proc *p; +sys_ptrace(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_ptrace_args /* { @@ -88,8 +89,10 @@ syscallarg(pid_t) pid; syscallarg(caddr_t) addr; syscallarg(int) data; } */ *uap = v; + struct proc *p = l->l_proc; + struct lwp *lt; struct proc *t; /* target process */ struct uio uio; struct iovec iov; int s, error, write, tmp; @@ -211,8 +214,19 @@ /* Do single-step fixup if needed. */ FIX_SSTEP(t); + /* XXX NJWLWP + * The entire ptrace interface needs work to be useful to + * a process with multiple LWPs. For the moment, we'll + * just kluge this and fail on others. + */ + + if (p->p_nlwps > 1) + return (ENOSYS); + + lt = LIST_FIRST(&t->p_lwps); + /* Now do the operation. */ write = 0; *retval = 0; tmp = 0; @@ -239,9 +253,9 @@ uio.uio_resid = sizeof(tmp); uio.uio_segflg = UIO_SYSSPACE; uio.uio_rw = write ? UIO_WRITE : UIO_READ; uio.uio_procp = p; - error = procfs_domem(p, t, NULL, &uio); + error = procfs_domem(p, lt, NULL, &uio); if (!write) *retval = tmp; return (error); @@ -271,25 +285,25 @@ /* Check that the data is a valid signal number or zero. */ if (SCARG(uap, data) < 0 || SCARG(uap, data) >= NSIG) return (EINVAL); - PHOLD(t); + PHOLD(lt); #ifdef PT_STEP /* * Arrange for a single-step, if that's requested and possible. */ - error = process_sstep(t, SCARG(uap, req) == PT_STEP); + error = process_sstep(lt, SCARG(uap, req) == PT_STEP); if (error) goto relebad; #endif /* If the address parameter is not (int *)1, set the pc. */ if ((int *)SCARG(uap, addr) != (int *)1) - if ((error = process_set_pc(t, SCARG(uap, addr))) != 0) + if ((error = process_set_pc(lt, SCARG(uap, addr))) != 0) goto relebad; - PRELE(t); + PRELE(lt); if (SCARG(uap, req) == PT_DETACH) { /* give process back to original parent or init */ if (t->p_oppid != t->p_pptr->p_pid) { @@ -308,18 +322,18 @@ /* Finally, deliver the requested signal (or none). */ if (t->p_stat == SSTOP) { t->p_xstat = SCARG(uap, data); SCHED_LOCK(s); - setrunnable(t); + setrunnable(proc_unstop(t)); SCHED_UNLOCK(s); } else { if (SCARG(uap, data) != 0) psignal(t, SCARG(uap, data)); } return (0); relebad: - PRELE(t); + PRELE(lt); return (error); case PT_KILL: /* just send the process a KILL signal. */ @@ -350,9 +364,9 @@ case PT_GETREGS: /* write = 0 done above. */ #endif #if defined(PT_SETREGS) || defined(PT_GETREGS) - if (!procfs_validregs(t, NULL)) + if (!procfs_validregs(lt, NULL)) return (EINVAL); else { iov.iov_base = SCARG(uap, addr); iov.iov_len = sizeof(struct reg); @@ -362,9 +376,9 @@ uio.uio_resid = sizeof(struct reg); uio.uio_segflg = UIO_USERSPACE; uio.uio_rw = write ? UIO_WRITE : UIO_READ; uio.uio_procp = p; - return (procfs_doregs(p, t, NULL, &uio)); + return (procfs_doregs(p, lt, NULL, &uio)); } #endif #ifdef PT_SETFPREGS @@ -375,9 +389,9 @@ case PT_GETFPREGS: /* write = 0 done above. */ #endif #if defined(PT_SETFPREGS) || defined(PT_GETFPREGS) - if (!procfs_validfpregs(t, NULL)) + if (!procfs_validfpregs(lt, NULL)) return (EINVAL); else { iov.iov_base = SCARG(uap, addr); iov.iov_len = sizeof(struct fpreg); @@ -387,9 +401,9 @@ uio.uio_resid = sizeof(struct fpreg); uio.uio_segflg = UIO_USERSPACE; uio.uio_rw = write ? UIO_WRITE : UIO_READ; uio.uio_procp = p; - return (procfs_dofpregs(p, t, NULL, &uio)); + return (procfs_dofpregs(p, lt, NULL, &uio)); } #endif } Index: sys/kern/syscalls.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/syscalls.c,v retrieving revision 1.119 retrieving revision 1.119.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.119 -r1.119.2.1 --- sys/kern/syscalls.c 2001/01/27 07:48:28 1.119 +++ sys/kern/syscalls.c 2001/03/05 22:49:44 1.119.2.1 @@ -423,16 +423,16 @@ #endif "lchflags", /* 304 = lchflags */ "issetugid", /* 305 = issetugid */ "utrace", /* 306 = utrace */ - "#307 (unimplemented)", /* 307 = unimplemented */ - "#308 (unimplemented)", /* 308 = unimplemented */ - "#309 (unimplemented)", /* 309 = unimplemented */ - "#310 (unimplemented)", /* 310 = unimplemented */ - "#311 (unimplemented)", /* 311 = unimplemented */ - "#312 (unimplemented)", /* 312 = unimplemented */ - "#313 (unimplemented)", /* 313 = unimplemented */ - "#314 (unimplemented)", /* 314 = unimplemented */ + "getcontext", /* 307 = getcontext */ + "setcontext", /* 308 = setcontext */ + "_lwp_create", /* 309 = _lwp_create */ + "_lwp_exit", /* 310 = _lwp_exit */ + "_lwp_self", /* 311 = _lwp_self */ + "_lwp_wait", /* 312 = _lwp_wait */ + "_lwp_suspend", /* 313 = _lwp_suspend */ + "_lwp_continue", /* 314 = _lwp_continue */ "#315 (unimplemented)", /* 315 = unimplemented */ "#316 (unimplemented)", /* 316 = unimplemented */ "#317 (unimplemented)", /* 317 = unimplemented */ "#318 (unimplemented)", /* 318 = unimplemented */ @@ -446,14 +446,14 @@ "#326 (unimplemented)", /* 326 = unimplemented */ "#327 (unimplemented)", /* 327 = unimplemented */ "#328 (unimplemented)", /* 328 = unimplemented */ "#329 (unimplemented)", /* 329 = unimplemented */ - "#330 (unimplemented)", /* 330 = unimplemented */ - "#331 (unimplemented)", /* 331 = unimplemented */ - "#332 (unimplemented)", /* 332 = unimplemented */ - "#333 (unimplemented)", /* 333 = unimplemented */ - "#334 (unimplemented)", /* 334 = unimplemented */ - "#335 (unimplemented)", /* 335 = unimplemented */ + "sa_register", /* 330 = sa_register */ + "sa_stacks", /* 331 = sa_stacks */ + "sa_enable", /* 332 = sa_enable */ + "sa_setconcurrency", /* 333 = sa_setconcurrency */ + "sa_yield", /* 334 = sa_yield */ + "sa_preempt", /* 335 = sa_preempt */ "#336 (unimplemented)", /* 336 = unimplemented */ "#337 (unimplemented)", /* 337 = unimplemented */ "#338 (unimplemented)", /* 338 = unimplemented */ "#339 (unimplemented)", /* 339 = unimplemented */ Index: sys/kern/syscalls.master =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/syscalls.master,v retrieving revision 1.108 retrieving revision 1.108.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.108 -r1.108.2.1 --- sys/kern/syscalls.master 2001/01/27 07:47:26 1.108 +++ sys/kern/syscalls.master 2001/03/05 22:49:45 1.108.2.1 @@ -609,22 +609,19 @@ 304 STD { int sys_lchflags(const char *path, u_long flags); } 305 STD { int sys_issetugid(void); } 306 STD { int sys_utrace(const char *label, void *addr, \ size_t len); } -; -; Syscalls 307 and 308 are reserved for getcontext and setcontext -; -307 UNIMPL -308 UNIMPL -; -; Syscalls 309-339 are reserved for LWP and scheduler activation syscalls. -; -309 UNIMPL -310 UNIMPL -311 UNIMPL -312 UNIMPL -313 UNIMPL -314 UNIMPL +307 STD { int sys_getcontext(struct __ucontext *ucp); } +308 STD { int sys_setcontext(const struct __ucontext *ucp); } +309 STD { int sys__lwp_create(const struct __ucontext *ucp, \ + u_long flags, lwpid_t *new_lwp); } +310 STD { int sys__lwp_exit(void); } +311 STD { lwpid_t sys__lwp_self(void); } +312 STD { int sys__lwp_wait(lwpid_t wait_for, \ + lwpid_t *departed); } +313 STD { int sys__lwp_suspend(lwpid_t target); } +314 STD { int sys__lwp_continue(lwpid_t target); } +; Syscalls 315-329 reserved for remaining Solaris-compatible LWP calls. 315 UNIMPL 316 UNIMPL 317 UNIMPL 318 UNIMPL @@ -638,14 +635,19 @@ 326 UNIMPL 327 UNIMPL 328 UNIMPL 329 UNIMPL -330 UNIMPL -331 UNIMPL -332 UNIMPL -333 UNIMPL -334 UNIMPL -335 UNIMPL +; Scheduler activation syscalls +330 STD { int sys_sa_register(sa_upcall_t new, \ + sa_upcall_t *old); } +331 STD { int sys_sa_stacks(int num, stack_t *stacks); } +332 STD { int sys_sa_enable(void); } +333 STD { int sys_sa_setconcurrency(int concurrency); } +334 STD { int sys_sa_yield(void); } +335 STD { int sys_sa_preempt(int sa_id); } +; +; Syscalls 336-339 are reserved for other scheduler activation syscalls. +; 336 UNIMPL 337 UNIMPL 338 UNIMPL 339 UNIMPL Index: sys/kern/sysv_msg.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/sysv_msg.c,v retrieving revision 1.32 retrieving revision 1.32.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.32 -r1.32.2.1 --- sys/kern/sysv_msg.c 2000/07/22 16:11:02 1.32 +++ sys/kern/sysv_msg.c 2001/03/05 22:49:45 1.32.2.1 @@ -164,18 +164,19 @@ free_msghdrs = msghdr; } int -sys___msgctl13(p, v, retval) - struct proc *p; +sys___msgctl13(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys___msgctl13_args /* { syscallarg(int) msqid; syscallarg(int) cmd; syscallarg(struct msqid_ds *) buf; } */ *uap = v; + struct proc *p = l->l_proc; struct msqid_ds msqbuf; int cmd, error; cmd = SCARG(uap, cmd); @@ -296,17 +297,18 @@ return (error); } int -sys_msgget(p, v, retval) - struct proc *p; +sys_msgget(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_msgget_args /* { syscallarg(key_t) key; syscallarg(int) msgflg; } */ *uap = v; + struct proc *p = l->l_proc; int msqid, error; int key = SCARG(uap, key); int msgflg = SCARG(uap, msgflg); struct ucred *cred = p->p_ucred; @@ -385,10 +387,10 @@ return (0); } int -sys_msgsnd(p, v, retval) - struct proc *p; +sys_msgsnd(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_msgsnd_args /* { @@ -396,8 +398,9 @@ syscallarg(const void *) msgp; syscallarg(size_t) msgsz; syscallarg(int) msgflg; } */ *uap = v; + struct proc *p = l->l_proc; int msqid = SCARG(uap, msqid); const char *user_msgp = SCARG(uap, msgp); size_t msgsz = SCARG(uap, msgsz); int msgflg = SCARG(uap, msgflg); @@ -660,10 +663,10 @@ return (0); } int -sys_msgrcv(p, v, retval) - struct proc *p; +sys_msgrcv(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_msgrcv_args /* { @@ -672,8 +675,9 @@ syscallarg(size_t) msgsz; syscallarg(long) msgtyp; syscallarg(int) msgflg; } */ *uap = v; + struct proc *p = l->l_proc; int msqid = SCARG(uap, msqid); char *user_msgp = SCARG(uap, msgp); size_t msgsz = SCARG(uap, msgsz); long msgtyp = SCARG(uap, msgtyp); Index: sys/kern/sysv_sem.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/sysv_sem.c,v retrieving revision 1.40 retrieving revision 1.40.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.40 -r1.40.2.1 --- sys/kern/sysv_sem.c 2000/07/22 16:11:02 1.40 +++ sys/kern/sysv_sem.c 2001/03/05 22:49:45 1.40.2.1 @@ -100,10 +100,10 @@ * Placebo. */ int -sys_semconfig(p, v, retval) - struct proc *p; +sys_semconfig(l, v, retval) + struct lwp *l; void *v; register_t *retval; { *retval = 0; @@ -280,10 +280,10 @@ } } int -sys_____semctl13(p, v, retval) - struct proc *p; +sys_____semctl13(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_____semctl13_args /* { @@ -291,8 +291,9 @@ syscallarg(int) semnum; syscallarg(int) cmd; syscallarg(union __semun *) arg; } */ *uap = v; + struct proc *p = l->l_proc; struct semid_ds sembuf; int cmd, error; void *pass_arg; union __semun karg; @@ -468,10 +469,10 @@ return (error); } int -sys_semget(p, v, retval) - struct proc *p; +sys_semget(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_semget_args /* { @@ -482,9 +483,9 @@ int semid, eval; int key = SCARG(uap, key); int nsems = SCARG(uap, nsems); int semflg = SCARG(uap, semflg); - struct ucred *cred = p->p_ucred; + struct ucred *cred = l->l_proc->p_ucred; SEM_PRINTF(("semget(0x%x, %d, 0%o)\n", key, nsems, semflg)); if (key != IPC_PRIVATE) { @@ -558,18 +559,19 @@ return(0); } int -sys_semop(p, v, retval) - struct proc *p; +sys_semop(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_semop_args /* { syscallarg(int) semid; syscallarg(struct sembuf *) sops; syscallarg(size_t) nsops; } */ *uap = v; + struct proc *p = l->l_proc; int semid = SCARG(uap, semid); int nsops = SCARG(uap, nsops); struct sembuf sops[MAX_SOPS]; struct semid_ds *semaptr; Index: sys/kern/sysv_shm.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/sysv_shm.c,v retrieving revision 1.61 retrieving revision 1.60.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.61 -r1.60.2.2 --- sys/kern/sysv_shm.c 2001/03/15 06:10:56 1.61 +++ sys/kern/sysv_shm.c 2001/04/09 01:57:57 1.60.2.2 @@ -191,16 +191,17 @@ } } int -sys_shmdt(p, v, retval) - struct proc *p; +sys_shmdt(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_shmdt_args /* { syscallarg(const void *) shmaddr; } */ *uap = v; + struct proc *p = l->l_proc; struct shmmap_state *shmmap_s; int i; shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm; @@ -217,18 +218,19 @@ return 0; } int -sys_shmat(p, v, retval) - struct proc *p; +sys_shmat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_shmat_args /* { syscallarg(int) shmid; syscallarg(const void *) shmaddr; syscallarg(int) shmflg; } */ *uap = v; + struct proc *p = l->l_proc; int error, i, flags; struct ucred *cred = p->p_ucred; struct shmid_ds *shmseg; struct shmmap_state *shmmap_s = NULL; @@ -296,18 +298,19 @@ return 0; } int -sys___shmctl13(p, v, retval) - struct proc *p; +sys___shmctl13(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys___shmctl13_args /* { syscallarg(int) shmid; syscallarg(int) cmd; syscallarg(struct shmid_ds *) buf; } */ *uap = v; + struct proc *p = l->l_proc; struct shmid_ds shmbuf; int cmd, error; cmd = SCARG(uap, cmd); @@ -490,18 +493,19 @@ return error; } int -sys_shmget(p, v, retval) - struct proc *p; +sys_shmget(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_shmget_args /* { syscallarg(key_t) key; syscallarg(int) size; syscallarg(int) shmflg; } */ *uap = v; + struct proc *p = l->l_proc; int segnum, mode, error; mode = SCARG(uap, shmflg) & ACCESSPERMS; if (SCARG(uap, key) != IPC_PRIVATE) { Index: sys/kern/tty.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/tty.c,v retrieving revision 1.127 retrieving revision 1.125.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.127 -r1.125.2.2 --- sys/kern/tty.c 2001/03/31 00:35:23 1.127 +++ sys/kern/tty.c 2001/04/09 01:57:57 1.125.2.2 @@ -44,8 +44,9 @@ #include #include #include +#include #include #define TTYDEFCHARS #include #undef TTYDEFCHARS @@ -752,9 +753,9 @@ case TIOCSETN: case TIOCSETP: case TIOCSLTC: #endif - while (isbackground(curproc, tp) && + while (isbackground(curproc->l_proc, tp) && p->p_pgrp->pg_jobc && (p->p_flag & P_PPWAIT) == 0 && !sigismasked(p, SIGTTOU)) { pgsignal(p->p_pgrp, SIGTTOU, 1); error = ttysleep(tp, &lbolt, TTOPRI | PCATCH, ttybg, 0); @@ -1303,9 +1304,9 @@ long lflag, slp; struct timeval stime; cc = tp->t_cc; - p = curproc; + p = curproc->l_proc; error = 0; has_stime = 0; last_cc = 0; slp = 0; @@ -1564,9 +1565,9 @@ splx(s); /* * Hang the process if it's in the background. */ - p = curproc; + p = curproc->l_proc; if (isbackground(p, tp) && ISSET(tp->t_lflag, TOSTOP) && (p->p_flag & P_PPWAIT) == 0 && !sigismember(&p->p_sigctx.ps_sigignore, SIGTTOU) && !sigismember(&p->p_sigctx.ps_sigmask, SIGTTOU)) { @@ -1907,8 +1908,9 @@ */ void ttyinfo(struct tty *tp) { + struct lwp *l; struct proc *p, *pick; struct timeval utime, stime; int tmp; @@ -1930,12 +1932,15 @@ for (pick = NULL; p != NULL; p = p->p_pglist.le_next) if (proc_compare(pick, p)) pick = p; - ttyprintf(tp, " cmd: %s %d [%s] ", pick->p_comm, pick->p_pid, - pick->p_stat == SONPROC ? "running" : - pick->p_stat == SRUN ? "runnable" : - pick->p_wmesg ? pick->p_wmesg : "iowait"); + ttyprintf(tp, " cmd: %s %d [", pick->p_comm, pick->p_pid); + LIST_FOREACH(l, &p->p_lwps, l_sibling) + ttyprintf(tp, "%s%s", + l->l_stat == LSONPROC ? "running" : + l->l_stat == LSRUN ? "runnable" : + l->l_wmesg ? l->l_wmesg : "iowait", + (LIST_NEXT(l, l_sibling) != NULL) ? " " : "] "); calcru(pick, &utime, &stime, NULL); /* Round up and print user time. */ @@ -1985,10 +1990,9 @@ * 3) The sleeper with the shortest sleep time is next. With ties, * we pick out just "short-term" sleepers (P_SINTR == 0). * 4) Further ties are broken by picking the highest pid. */ -#define ISRUN(p) (((p)->p_stat == SRUN) || ((p)->p_stat == SIDL) || \ - ((p)->p_stat == SONPROC)) +#define ISRUN(p) ((p)->p_nrlwps > 0) #define TESTAB(a, b) ((a)<<1 | (b)) #define ONLYA 2 #define ONLYB 1 #define BOTH 3 @@ -2027,8 +2031,9 @@ return (0); case BOTH: return (p2->p_pid > p1->p_pid); /* tie - return highest pid */ } +#if 0 /* XXX NJWLWP */ /* * pick the one with the smallest sleep time */ if (p2->p_slptime > p1->p_slptime) @@ -2041,8 +2046,9 @@ if (p1->p_flag & P_SINTR && (p2->p_flag & P_SINTR) == 0) return (1); if (p2->p_flag & P_SINTR && (p1->p_flag & P_SINTR) == 0) return (0); +#endif return (p2->p_pid > p1->p_pid); /* tie - return highest pid */ } /* Index: sys/kern/tty_pty.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/tty_pty.c,v retrieving revision 1.55 retrieving revision 1.55.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.55 -r1.55.2.1 --- sys/kern/tty_pty.c 2000/11/24 03:59:08 1.55 +++ sys/kern/tty_pty.c 2001/03/05 22:49:46 1.55.2.1 @@ -44,8 +44,9 @@ #include #include #include +#include #include #include #include #include @@ -323,9 +324,9 @@ dev_t dev; struct uio *uio; int flag; { - struct proc *p = curproc; + struct proc *p = curproc->l_proc; struct pt_softc *pti = pt_softc[minor(dev)]; struct tty *tp = pti->pt_tty; int error = 0; Index: sys/kern/tty_tb.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/tty_tb.c,v retrieving revision 1.26 retrieving revision 1.25.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.26 -r1.25.2.2 --- sys/kern/tty_tb.c 2001/03/31 00:35:23 1.26 +++ sys/kern/tty_tb.c 2001/04/09 01:57:58 1.25.2.2 @@ -47,8 +47,9 @@ #include #include #include #include +#include #include union tbpos { struct hitpos hitpos; @@ -152,9 +153,9 @@ struct tty *tp; { int modebits = TBPOINT|TBSTOP; - tbtioctl(tp, BIOSMODE, (caddr_t) &modebits, 0, curproc); + tbtioctl(tp, BIOSMODE, (caddr_t) &modebits, 0, curproc->l_proc); } /* * Read from a tablet line. Index: sys/kern/uipc_socket.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/uipc_socket.c,v retrieving revision 1.55 retrieving revision 1.54.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.55 -r1.54.2.2 --- sys/kern/uipc_socket.c 2001/03/21 19:22:29 1.55 +++ sys/kern/uipc_socket.c 2001/04/09 01:57:58 1.54.2.2 @@ -38,8 +38,9 @@ #include "opt_compat_sunos.h" #include #include +#include #include #include #include #include @@ -80,9 +81,9 @@ struct protosw *prp; struct socket *so; int error, s; - p = curproc; /* XXX */ + p = curproc->l_proc; /* XXX */ if (proto) prp = pffindproto(dom, proto, type); else prp = pffindtype(dom, type); @@ -272,9 +273,9 @@ { struct proc *p; int s, error; - p = curproc; /* XXX */ + p = curproc->l_proc; /* XXX */ if (so->so_options & SO_ACCEPTCONN) return (EOPNOTSUPP); s = splsoftnet(); /* @@ -355,9 +356,9 @@ struct mbuf **mp, *m; long space, len, resid; int clen, error, s, dontroute, mlen, atomic; - p = curproc; /* XXX */ + p = curproc->l_proc; /* XXX */ clen = 0; atomic = sosendallatonce(so) || top; if (uio) resid = uio->uio_resid; Index: sys/kern/uipc_syscalls.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/uipc_syscalls.c,v retrieving revision 1.57 retrieving revision 1.57.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.57 -r1.57.2.1 --- sys/kern/uipc_syscalls.c 2001/02/27 05:19:15 1.57 +++ sys/kern/uipc_syscalls.c 2001/03/05 22:49:47 1.57.2.1 @@ -46,8 +46,9 @@ #include #include #include +#include #include #include #include #include @@ -71,20 +72,23 @@ */ extern struct fileops socketops; int -sys_socket(struct proc *p, void *v, register_t *retval) +sys_socket(struct lwp *l, void *v, register_t *retval) { struct sys_socket_args /* { syscallarg(int) domain; syscallarg(int) type; syscallarg(int) protocol; } */ *uap = v; + + struct proc *p; struct filedesc *fdp; struct socket *so; struct file *fp; int fd, error; + p = l->l_proc; fdp = p->p_fd; /* falloc() will use the desciptor for us */ if ((error = falloc(p, &fp, &fd)) != 0) return (error); @@ -106,19 +110,21 @@ } /* ARGSUSED */ int -sys_bind(struct proc *p, void *v, register_t *retval) +sys_bind(struct lwp *l, void *v, register_t *retval) { struct sys_bind_args /* { syscallarg(int) s; syscallarg(const struct sockaddr *) name; syscallarg(unsigned int) namelen; } */ *uap = v; + struct proc *p; struct file *fp; struct mbuf *nam; int error; + p = l->l_proc; /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0) return (error); error = sockargs(&nam, SCARG(uap, name), SCARG(uap, namelen), @@ -134,17 +140,19 @@ } /* ARGSUSED */ int -sys_listen(struct proc *p, void *v, register_t *retval) +sys_listen(struct lwp *l, void *v, register_t *retval) { struct sys_listen_args /* { syscallarg(int) s; syscallarg(int) backlog; } */ *uap = v; + struct proc *p; struct file *fp; int error; + p = l->l_proc; /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0) return (error); error = solisten((struct socket *)fp->f_data, SCARG(uap, backlog)); @@ -152,22 +160,24 @@ return (error); } int -sys_accept(struct proc *p, void *v, register_t *retval) +sys_accept(struct lwp *l, void *v, register_t *retval) { struct sys_accept_args /* { syscallarg(int) s; syscallarg(struct sockaddr *) name; syscallarg(unsigned int *) anamelen; } */ *uap = v; + struct proc *p; struct filedesc *fdp; struct file *fp; struct mbuf *nam; unsigned int namelen; int error, s, fd; struct socket *so; + p = l->l_proc; fdp = p->p_fd; if (SCARG(uap, name) && (error = copyin((caddr_t)SCARG(uap, anamelen), (caddr_t)&namelen, sizeof(namelen)))) return (error); @@ -250,20 +260,22 @@ } /* ARGSUSED */ int -sys_connect(struct proc *p, void *v, register_t *retval) +sys_connect(struct lwp *l, void *v, register_t *retval) { struct sys_connect_args /* { syscallarg(int) s; syscallarg(const struct sockaddr *) name; syscallarg(unsigned int) namelen; } */ *uap = v; + struct proc *p; struct file *fp; struct socket *so; struct mbuf *nam; int error, s; + p = l->l_proc; /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0) return (error); so = (struct socket *)fp->f_data; @@ -301,21 +313,23 @@ return (error); } int -sys_socketpair(struct proc *p, void *v, register_t *retval) +sys_socketpair(struct lwp *l, void *v, register_t *retval) { struct sys_socketpair_args /* { syscallarg(int) domain; syscallarg(int) type; syscallarg(int) protocol; syscallarg(int *) rsv; } */ *uap = v; + struct proc *p; struct filedesc *fdp; struct file *fp1, *fp2; struct socket *so1, *so2; int fd, error, sv[2]; + p = l->l_proc; fdp = p->p_fd; error = socreate(SCARG(uap, domain), &so1, SCARG(uap, type), SCARG(uap, protocol)); if (error) @@ -368,9 +382,9 @@ return (error); } int -sys_sendto(struct proc *p, void *v, register_t *retval) +sys_sendto(struct lwp *l, void *v, register_t *retval) { struct sys_sendto_args /* { syscallarg(int) s; syscallarg(const void *) buf; @@ -378,11 +392,13 @@ syscallarg(int) flags; syscallarg(const struct sockaddr *) to; syscallarg(unsigned int) tolen; } */ *uap = v; + struct proc *p; struct msghdr msg; struct iovec aiov; + p = l->l_proc; msg.msg_name = (caddr_t)SCARG(uap, to); /* XXX kills const */ msg.msg_namelen = SCARG(uap, tolen); msg.msg_iov = &aiov; msg.msg_iovlen = 1; @@ -395,15 +411,16 @@ return (sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval)); } int -sys_sendmsg(struct proc *p, void *v, register_t *retval) +sys_sendmsg(struct lwp *l, void *v, register_t *retval) { struct sys_sendmsg_args /* { syscallarg(int) s; syscallarg(const struct msghdr *) msg; syscallarg(int) flags; } */ *uap = v; + struct proc *p; struct msghdr msg; struct iovec aiov[UIO_SMALLIOV], *iov; int error; @@ -426,8 +443,9 @@ msg.msg_iov = iov; #ifdef COMPAT_OLDSOCK msg.msg_flags = 0; #endif + p = l->l_proc; error = sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval); done: if (iov != aiov) free(iov, M_IOV); @@ -553,9 +571,9 @@ return (error); } int -sys_recvfrom(struct proc *p, void *v, register_t *retval) +sys_recvfrom(struct lwp *l, void *v, register_t *retval) { struct sys_recvfrom_args /* { syscallarg(int) s; syscallarg(void *) buf; @@ -563,8 +581,9 @@ syscallarg(int) flags; syscallarg(struct sockaddr *) from; syscallarg(unsigned int *) fromlenaddr; } */ *uap = v; + struct proc *p; struct msghdr msg; struct iovec aiov; int error; @@ -582,20 +601,22 @@ aiov.iov_base = SCARG(uap, buf); aiov.iov_len = SCARG(uap, len); msg.msg_control = 0; msg.msg_flags = SCARG(uap, flags); + p = l->l_proc; return (recvit(p, SCARG(uap, s), &msg, (caddr_t)SCARG(uap, fromlenaddr), retval)); } int -sys_recvmsg(struct proc *p, void *v, register_t *retval) +sys_recvmsg(struct lwp *l, void *v, register_t *retval) { struct sys_recvmsg_args /* { syscallarg(int) s; syscallarg(struct msghdr *) msg; syscallarg(int) flags; } */ *uap = v; + struct proc *p; struct msghdr msg; struct iovec aiov[UIO_SMALLIOV], *uiov, *iov; int error; @@ -622,8 +643,9 @@ msg.msg_flags = SCARG(uap, flags) &~ MSG_COMPAT; #else msg.msg_flags = SCARG(uap, flags); #endif + p = l->l_proc; if ((error = recvit(p, SCARG(uap, s), &msg, (caddr_t)0, retval)) == 0) { msg.msg_iov = uiov; error = copyout((caddr_t)&msg, (caddr_t)SCARG(uap, msg), sizeof(msg)); @@ -799,17 +821,19 @@ } /* ARGSUSED */ int -sys_shutdown(struct proc *p, void *v, register_t *retval) +sys_shutdown(struct lwp *l, void *v, register_t *retval) { struct sys_shutdown_args /* { syscallarg(int) s; syscallarg(int) how; } */ *uap = v; + struct proc *p; struct file *fp; int error; + p = l->l_proc; /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0) return (error); error = soshutdown((struct socket *)fp->f_data, SCARG(uap, how)); @@ -818,21 +842,23 @@ } /* ARGSUSED */ int -sys_setsockopt(struct proc *p, void *v, register_t *retval) +sys_setsockopt(struct lwp *l, void *v, register_t *retval) { struct sys_setsockopt_args /* { syscallarg(int) s; syscallarg(int) level; syscallarg(int) name; syscallarg(const void *) val; syscallarg(unsigned int) valsize; } */ *uap = v; + struct proc *p; struct file *fp; struct mbuf *m; int error; + p = l->l_proc; m = NULL; /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0) return (error); @@ -858,22 +884,24 @@ } /* ARGSUSED */ int -sys_getsockopt(struct proc *p, void *v, register_t *retval) +sys_getsockopt(struct lwp *l, void *v, register_t *retval) { struct sys_getsockopt_args /* { syscallarg(int) s; syscallarg(int) level; syscallarg(int) name; syscallarg(void *) val; syscallarg(unsigned int *) avalsize; } */ *uap = v; + struct proc *p; struct file *fp; struct mbuf *m, *m0; unsigned int op, i, valsize; int error; + p = l->l_proc; m = NULL; /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0) return (error); @@ -909,15 +937,17 @@ } /* ARGSUSED */ int -sys_pipe(struct proc *p, void *v, register_t *retval) +sys_pipe(struct lwp *l, void *v, register_t *retval) { + struct proc *p; struct filedesc *fdp; struct file *rf, *wf; struct socket *rso, *wso; int fd, error; + p = l->l_proc; fdp = p->p_fd; if ((error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0)) != 0) return (error); if ((error = socreate(AF_LOCAL, &wso, SOCK_STREAM, 0)) != 0) @@ -961,21 +991,23 @@ * Get socket name. */ /* ARGSUSED */ int -sys_getsockname(struct proc *p, void *v, register_t *retval) +sys_getsockname(struct lwp *l, void *v, register_t *retval) { struct sys_getsockname_args /* { syscallarg(int) fdes; syscallarg(struct sockaddr *) asa; syscallarg(unsigned int *) alen; } */ *uap = v; + struct proc *p; struct file *fp; struct socket *so; struct mbuf *m; unsigned int len; int error; + p = l->l_proc; /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, SCARG(uap, fdes), &fp)) != 0) return (error); error = copyin((caddr_t)SCARG(uap, alen), (caddr_t)&len, sizeof(len)); @@ -1004,21 +1036,23 @@ * Get name of peer for connected socket. */ /* ARGSUSED */ int -sys_getpeername(struct proc *p, void *v, register_t *retval) +sys_getpeername(struct lwp *l, void *v, register_t *retval) { struct sys_getpeername_args /* { syscallarg(int) fdes; syscallarg(struct sockaddr *) asa; syscallarg(unsigned int *) alen; } */ *uap = v; + struct proc *p; struct file *fp; struct socket *so; struct mbuf *m; unsigned int len; int error; + p = l->l_proc; /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, SCARG(uap, fdes), &fp)) != 0) return (error); so = (struct socket *)fp->f_data; Index: sys/kern/uipc_usrreq.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/uipc_usrreq.c,v retrieving revision 1.48 retrieving revision 1.48.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.48 -r1.48.4.1 --- sys/kern/uipc_usrreq.c 2000/06/05 16:29:45 1.48 +++ sys/kern/uipc_usrreq.c 2001/03/05 22:49:47 1.48.4.1 @@ -74,8 +74,9 @@ */ #include #include +#include #include #include #include #include @@ -800,9 +801,9 @@ int unp_externalize(rights) struct mbuf *rights; { - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ struct cmsghdr *cm = mtod(rights, struct cmsghdr *); int i, *fdp; struct file **rp; struct file *fp; Index: sys/kern/vfs_bio.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/vfs_bio.c,v retrieving revision 1.76 retrieving revision 1.74.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.76 -r1.74.2.2 --- sys/kern/vfs_bio.c 2001/04/01 16:16:56 1.76 +++ sys/kern/vfs_bio.c 2001/04/09 01:57:59 1.74.2.2 @@ -49,8 +49,9 @@ */ #include #include +#include #include #include #include #include @@ -186,12 +187,19 @@ struct ucred *cred; int async; { struct buf *bp; - struct proc *p = (curproc != NULL ? curproc : &proc0); /* XXX */ + struct lwp *l = (curproc != NULL ? curproc : &lwp0); /* XXX */ + struct proc *p = l->l_proc; bp = getblk(vp, blkno, size, 0, 0); +#ifdef DIAGNOSTIC + if (bp == NULL) { + panic("bio_doread: no such buf"); + } +#endif + /* * If buffer does not have data valid, start a read. * Note that if buffer is B_INVAL, getblk() won't return it. * Therefore, it's valid if it's I/O has completed or been delayed. @@ -311,9 +319,10 @@ bwrite(bp) struct buf *bp; { int rv, sync, wasdelayed, s; - struct proc *p = (curproc != NULL ? curproc : &proc0); /* XXX */ + struct lwp *l = (curproc != NULL ? curproc : &lwp0); /* XXX */ + struct proc *p = l->l_proc; struct vnode *vp; struct mount *mp; vp = bp->b_vp; @@ -410,9 +419,10 @@ void bdwrite(bp) struct buf *bp; { - struct proc *p = (curproc != NULL ? curproc : &proc0); /* XXX */ + struct lwp *l = (curproc != NULL ? curproc : &lwp0); /* XXX */ + struct proc *p = l->l_proc; int s; /* If this is a tape block, write the block now. */ /* XXX NOTE: the memory filesystem usurpes major device */ @@ -475,9 +485,10 @@ void bdirty(bp) struct buf *bp; { - struct proc *p = (curproc != NULL ? curproc : &proc0); /* XXX */ + struct lwp *l = (curproc != NULL ? curproc : &lwp0); /* XXX */ + struct proc *p = l->l_proc; int s; s = splbio(); Index: sys/kern/vfs_cluster.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/vfs_cluster.c,v retrieving revision 1.26 retrieving revision 1.26.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.26 -r1.26.2.1 --- sys/kern/vfs_cluster.c 2000/11/30 20:56:53 1.26 +++ sys/kern/vfs_cluster.c 2001/03/05 22:49:47 1.26.2.1 @@ -35,8 +35,9 @@ * @(#)vfs_cluster.c 8.10 (Berkeley) 3/28/95 */ #include +#include #include #include #include #include @@ -142,9 +143,9 @@ trace(TR_BREADMISS, pack(vp, size), lblkno); bp->b_flags |= B_READ; ioblkno = lblkno; alreadyincore = 0; - curproc->p_stats->p_ru.ru_inblock++; /* XXX */ + curproc->l_proc->p_stats->p_ru.ru_inblock++; /* XXX */ } /* * XXX * Replace 1 with a window size based on some permutation of @@ -240,9 +241,9 @@ rbp = NULL; else if (rbp) { /* case 2, 5 */ trace(TR_BREADMISSRA, pack(vp, (num_ra + 1) * size), ioblkno); - curproc->p_stats->p_ru.ru_inblock++; /* XXX */ + curproc->l_proc->p_stats->p_ru.ru_inblock++; /* XXX */ } } /* XXX Kirk, do we need to make sure the bp has creds? */ Index: sys/kern/vfs_getcwd.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/vfs_getcwd.c,v retrieving revision 1.14 retrieving revision 1.14.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.14 -r1.14.2.1 --- sys/kern/vfs_getcwd.c 2000/12/15 11:52:14 1.14 +++ sys/kern/vfs_getcwd.c 2001/03/05 22:49:48 1.14.2.1 @@ -44,8 +44,9 @@ #include #include #include #include +#include #include #include #include #include @@ -551,10 +552,10 @@ * to reading directory contents. */ int -sys___getcwd(p, v, retval) - struct proc *p; +sys___getcwd(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys___getcwd_args /* { @@ -585,10 +586,10 @@ * 5th argument here is "max number of vnodes to traverse". * Since each entry takes up at least 2 bytes in the output buffer, * limit it to N/2 vnodes for an N byte buffer. */ - error = getcwd_common (p->p_cwdi->cwdi_cdir, NULL, &bp, path, len/2, - GETCWD_CHECK_ACCESS, p); + error = getcwd_common (l->l_proc->p_cwdi->cwdi_cdir, NULL, &bp, path, + len/2, GETCWD_CHECK_ACCESS, l->l_proc); if (error) goto out; lenused = bend - bp; Index: sys/kern/vfs_lockf.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/vfs_lockf.c,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.17 -r1.17.2.1 --- sys/kern/vfs_lockf.c 2000/07/22 15:26:13 1.17 +++ sys/kern/vfs_lockf.c 2001/03/05 22:49:48 1.17.2.1 @@ -41,8 +41,9 @@ #include #include #include #include +#include #include #include #include #include @@ -138,14 +139,27 @@ */ MALLOC(lock, struct lockf *, sizeof(*lock), M_LOCKF, M_WAITOK); lock->lf_start = start; lock->lf_end = end; - lock->lf_id = ap->a_id; + /* XXX NJWLWP + * I don't want to make the entire VFS universe use LWPs, because + * they don't need them, for the most part. This is an exception, + * and a kluge. + */ + lock->lf_head = head; lock->lf_type = fl->l_type; lock->lf_next = (struct lockf *)0; TAILQ_INIT(&lock->lf_blkhd); lock->lf_flags = ap->a_flags; + if (lock->lf_flags & F_POSIX) { + KASSERT(curproc->l_proc == (struct proc *)ap->a_id); + lock->lf_id = (caddr_t) curproc; + } else { + lock->lf_id = ap->a_id; /* Not a proc at all, but a file * */ + } + + /* * Do the requested operation. */ switch (ap->a_op) { @@ -217,24 +231,24 @@ * do not go off into neverneverland. */ if ((lock->lf_flags & F_POSIX) && (block->lf_flags & F_POSIX)) { - struct proc *wproc; + struct lwp *wlwp; struct lockf *waitblock; int i = 0; /* The block is waiting on something */ - wproc = (struct proc *)block->lf_id; - while (wproc->p_wchan && - (wproc->p_wmesg == lockstr) && + wlwp = (struct lwp *)block->lf_id; + while (wlwp->l_wchan && + (wlwp->l_wmesg == lockstr) && (i++ < maxlockdepth)) { - waitblock = (struct lockf *)wproc->p_wchan; + waitblock = (struct lockf *)wlwp->l_wchan; /* Get the owner of the blocking lock */ waitblock = waitblock->lf_next; if ((waitblock->lf_flags & F_POSIX) == 0) break; - wproc = (struct proc *)waitblock->lf_id; - if (wproc == (struct proc *)lock->lf_id) { + wlwp = (struct lwp *)waitblock->lf_id; + if (wlwp == (struct lwp *)lock->lf_id) { free(lock, M_LOCKF); return (EDEADLK); } } @@ -515,9 +529,9 @@ fl->l_len = 0; else fl->l_len = block->lf_end - block->lf_start + 1; if (block->lf_flags & F_POSIX) - fl->l_pid = ((struct proc *)(block->lf_id))->p_pid; + fl->l_pid = ((struct lwp *)(block->lf_id))->l_proc->p_pid; else fl->l_pid = -1; } else { fl->l_type = F_UNLCK; Index: sys/kern/vfs_subr.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/vfs_subr.c,v retrieving revision 1.147 retrieving revision 1.146.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.147 -r1.146.2.2 --- sys/kern/vfs_subr.c 2001/03/09 01:02:11 1.147 +++ sys/kern/vfs_subr.c 2001/04/09 01:58:00 1.146.2.2 @@ -86,8 +86,9 @@ #include "opt_compat_43.h" #include #include +#include #include #include #include #include @@ -211,9 +212,9 @@ if (flags & LK_NOWAIT) return (ENOENT); if ((flags & LK_RECURSEFAIL) && mp->mnt_unmounter != NULL - && mp->mnt_unmounter == curproc) + && mp->mnt_unmounter == curproc->l_proc) return (EDEADLK); if (interlkp) simple_unlock(interlkp); /* @@ -414,9 +415,9 @@ struct vnode **vpp; { extern struct uvm_pagerops uvm_vnodeops; struct uvm_object *uobj; - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ struct freelst *listhd; static int toggle; struct vnode *vp; int error = 0; @@ -1039,9 +1040,9 @@ struct vnode *nvp; dev_t nvp_rdev; struct mount *mp; { - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ struct vnode *vp; struct vnode **vpp; if (nvp->v_type != VBLK && nvp->v_type != VCHR) @@ -1188,9 +1189,9 @@ void vput(vp) struct vnode *vp; { - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ #ifdef DIAGNOSTIC if (vp == NULL) panic("vput: null vp"); @@ -1233,9 +1234,9 @@ void vrele(vp) struct vnode *vp; { - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ #ifdef DIAGNOSTIC if (vp == NULL) panic("vrele: null vp"); @@ -1381,9 +1382,9 @@ struct mount *mp; struct vnode *skipvp; int flags; { - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ struct vnode *vp, *nvp; int busy = 0; simple_lock(&mntvnode_slock); @@ -1610,9 +1611,9 @@ void vgone(vp) struct vnode *vp; { - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ simple_lock(&vp->v_interlock); vgonel(vp, p); } @@ -2413,9 +2414,10 @@ vfs_shutdown() { struct buf *bp; int iter, nbusy, nbusy_prev = 0, dcount, s; - struct proc *p = curproc; + struct lwp *l = curproc; + struct proc *p = l->l_proc; /* XXX we're certainly not running in proc0's context! */ if (p == NULL) p = &proc0; @@ -2428,9 +2430,9 @@ /* avoid coming back this way again if we panic. */ doing_shutdown = 1; - sys_sync(p, NULL, NULL); + sys_sync(l, NULL, NULL); /* Wait for sync to finish. */ dcount = 10000; for (iter = 0; iter < 20;) { Index: sys/kern/vfs_syscalls.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/kern/vfs_syscalls.c,v retrieving revision 1.164 retrieving revision 1.164.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.164 -r1.164.2.1 --- sys/kern/vfs_syscalls.c 2000/11/27 08:39:44 1.164 +++ sys/kern/vfs_syscalls.c 2001/03/05 22:49:48 1.164.2.1 @@ -51,8 +51,9 @@ #include #include #include #include +#include #include #include #include #include @@ -120,10 +121,10 @@ sizeof(mountcompatnames[0]); /* ARGSUSED */ int -sys_mount(p, v, retval) - struct proc *p; +sys_mount(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_mount_args /* { @@ -131,8 +132,9 @@ syscallarg(const char *) path; syscallarg(int) flags; syscallarg(void *) data; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; struct mount *mp; int error, flag = 0; char fstypename[MFSNAMELEN]; @@ -410,17 +412,18 @@ * not special file (as before). */ /* ARGSUSED */ int -sys_unmount(p, v, retval) - struct proc *p; +sys_unmount(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_unmount_args /* { syscallarg(const char *) path; syscallarg(int) flags; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; struct mount *mp; int error; struct nameidata nd; @@ -553,15 +556,16 @@ #endif /* ARGSUSED */ int -sys_sync(p, v, retval) - struct proc *p; +sys_sync(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct mount *mp, *nmp; int asyncflag; + struct proc *p = l->l_proc; simple_lock(&mountlist_slock); for (mp = mountlist.cqh_last; mp != (void *)&mountlist; mp = nmp) { if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock)) { @@ -592,10 +596,10 @@ * Change filesystem quotas. */ /* ARGSUSED */ int -sys_quotactl(p, v, retval) - struct proc *p; +sys_quotactl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_quotactl_args /* { @@ -603,8 +607,9 @@ syscallarg(int) cmd; syscallarg(int) uid; syscallarg(caddr_t) arg; } */ *uap = v; + struct proc *p = l->l_proc; struct mount *mp; int error; struct nameidata nd; @@ -621,17 +626,18 @@ * Get filesystem statistics. */ /* ARGSUSED */ int -sys_statfs(p, v, retval) - struct proc *p; +sys_statfs(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_statfs_args /* { syscallarg(const char *) path; syscallarg(struct statfs *) buf; } */ *uap = v; + struct proc *p = l->l_proc; struct mount *mp; struct statfs *sp; int error; struct nameidata nd; @@ -653,17 +659,18 @@ * Get filesystem statistics. */ /* ARGSUSED */ int -sys_fstatfs(p, v, retval) - struct proc *p; +sys_fstatfs(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_fstatfs_args /* { syscallarg(int) fd; syscallarg(struct statfs *) buf; } */ *uap = v; + struct proc *p = l->l_proc; struct file *fp; struct mount *mp; struct statfs *sp; int error; @@ -686,18 +693,19 @@ /* * Get statistics on all filesystems. */ int -sys_getfsstat(p, v, retval) - struct proc *p; +sys_getfsstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_getfsstat_args /* { syscallarg(struct statfs *) buf; syscallarg(long) bufsize; syscallarg(int) flags; } */ *uap = v; + struct proc *p = l->l_proc; struct mount *mp, *nmp; struct statfs *sp; caddr_t sfsp; long count, maxcount, error; @@ -754,16 +762,17 @@ * Change current working directory to a given file descriptor. */ /* ARGSUSED */ int -sys_fchdir(p, v, retval) - struct proc *p; +sys_fchdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_fchdir_args /* { syscallarg(int) fd; } */ *uap = v; + struct proc *p = l->l_proc; struct filedesc *fdp = p->p_fd; struct cwdinfo *cwdi = p->p_cwdi; struct vnode *vp, *tdp; struct mount *mp; @@ -818,14 +827,15 @@ * Change this process's notion of the root directory to a given file descriptor. */ int -sys_fchroot(p, v, retval) - struct proc *p; +sys_fchroot(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_fchroot_args *uap = v; + struct proc *p = l->l_proc; struct filedesc *fdp = p->p_fd; struct cwdinfo *cwdi = p->p_cwdi; struct vnode *vp; struct file *fp; @@ -876,16 +886,17 @@ * Change current working directory (``.''). */ /* ARGSUSED */ int -sys_chdir(p, v, retval) - struct proc *p; +sys_chdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_chdir_args /* { syscallarg(const char *) path; } */ *uap = v; + struct proc *p = l->l_proc; struct cwdinfo *cwdi = p->p_cwdi; int error; struct nameidata nd; @@ -902,16 +913,17 @@ * Change notion of root (``/'') directory. */ /* ARGSUSED */ int -sys_chroot(p, v, retval) - struct proc *p; +sys_chroot(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_chroot_args /* { syscallarg(const char *) path; } */ *uap = v; + struct proc *p = l->l_proc; struct cwdinfo *cwdi = p->p_cwdi; struct vnode *vp; int error; struct nameidata nd; @@ -975,18 +987,19 @@ * Check permissions, allocate an open file structure, * and call the device open routine if any. */ int -sys_open(p, v, retval) - struct proc *p; +sys_open(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_open_args /* { syscallarg(const char *) path; syscallarg(int) flags; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; struct cwdinfo *cwdi = p->p_cwdi; struct filedesc *fdp = p->p_fd; struct file *fp; struct vnode *vp; @@ -1057,17 +1070,18 @@ /* * Get file handle system call */ int -sys_getfh(p, v, retval) - struct proc *p; +sys_getfh(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_getfh_args /* { syscallarg(char *) fname; syscallarg(fhandle_t *) fhp; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; fhandle_t fh; int error; struct nameidata nd; @@ -1100,17 +1114,18 @@ * Check permissions, allocate an open file structure, * and call the device open routine if any. */ int -sys_fhopen(p, v, retval) - struct proc *p; +sys_fhopen(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_fhopen_args /* { syscallarg(const fhandle_t *) fhp; syscallarg(int) flags; } */ *uap = v; + struct proc *p = l->l_proc; struct filedesc *fdp = p->p_fd; struct file *fp; struct vnode *vp = NULL; struct mount *mp; @@ -1232,17 +1247,18 @@ } /* ARGSUSED */ int -sys_fhstat(p, v, retval) - struct proc *p; +sys_fhstat(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_fhstat_args /* { syscallarg(const fhandle_t *) fhp; syscallarg(struct stat *) sb; } */ *uap = v; + struct proc *p = l->l_proc; struct stat sb; int error; fhandle_t fh; struct mount *mp; @@ -1270,17 +1286,18 @@ } /* ARGSUSED */ int -sys_fhstatfs(p, v, retval) - struct proc *p; +sys_fhstatfs(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_fhstatfs_args /* syscallarg(const fhandle_t *) fhp; syscallarg(struct statfs *) buf; } */ *uap = v; + struct proc *p = l->l_proc; struct statfs sp; fhandle_t fh; struct mount *mp; struct vnode *vp; @@ -1312,18 +1329,19 @@ * Create a special file. */ /* ARGSUSED */ int -sys_mknod(p, v, retval) - struct proc *p; +sys_mknod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_mknod_args /* { syscallarg(const char *) path; syscallarg(int) mode; syscallarg(int) dev; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; struct vattr vattr; int error; int whiteout = 0; @@ -1389,17 +1407,18 @@ * Create a named pipe. */ /* ARGSUSED */ int -sys_mkfifo(p, v, retval) - struct proc *p; +sys_mkfifo(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_mkfifo_args /* { syscallarg(const char *) path; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; struct vattr vattr; int error; struct nameidata nd; @@ -1426,17 +1445,18 @@ * Make a hard file link. */ /* ARGSUSED */ int -sys_link(p, v, retval) - struct proc *p; +sys_link(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_link_args /* { syscallarg(const char *) path; syscallarg(const char *) link; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; struct nameidata nd; int error; @@ -1469,17 +1489,18 @@ * Make a symbolic link. */ /* ARGSUSED */ int -sys_symlink(p, v, retval) - struct proc *p; +sys_symlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_symlink_args /* { syscallarg(const char *) path; syscallarg(const char *) link; } */ *uap = v; + struct proc *p = l->l_proc; struct vattr vattr; char *path; int error; struct nameidata nd; @@ -1514,16 +1535,17 @@ * Delete a whiteout from the filesystem. */ /* ARGSUSED */ int -sys_undelete(p, v, retval) - struct proc *p; +sys_undelete(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_undelete_args /* { syscallarg(const char *) path; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct nameidata nd; NDINIT(&nd, DELETE, LOCKPARENT|DOWHITEOUT, UIO_USERSPACE, @@ -1554,16 +1576,17 @@ * Delete a name from the filesystem. */ /* ARGSUSED */ int -sys_unlink(p, v, retval) - struct proc *p; +sys_unlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_unlink_args /* { syscallarg(const char *) path; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; int error; struct nameidata nd; @@ -1597,10 +1620,10 @@ /* * Reposition read/write file offset. */ int -sys_lseek(p, v, retval) - struct proc *p; +sys_lseek(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_lseek_args /* { @@ -1608,8 +1631,9 @@ syscallarg(int) pad; syscallarg(off_t) offset; syscallarg(int) whence; } */ *uap = v; + struct proc *p = l->l_proc; struct ucred *cred = p->p_ucred; struct filedesc *fdp = p->p_fd; struct file *fp; struct vnode *vp; @@ -1659,10 +1683,10 @@ /* * Positional read system call. */ int -sys_pread(p, v, retval) - struct proc *p; +sys_pread(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_pread_args /* { @@ -1670,8 +1694,9 @@ syscallarg(void *) buf; syscallarg(size_t) nbyte; syscallarg(off_t) offset; } */ *uap = v; + struct proc *p = l->l_proc; struct filedesc *fdp = p->p_fd; struct file *fp; struct vnode *vp; off_t offset; @@ -1712,10 +1737,10 @@ /* * Positional scatter read system call. */ int -sys_preadv(p, v, retval) - struct proc *p; +sys_preadv(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_preadv_args /* { @@ -1723,8 +1748,9 @@ syscallarg(const struct iovec *) iovp; syscallarg(int) iovcnt; syscallarg(off_t) offset; } */ *uap = v; + struct proc *p = l->l_proc; struct filedesc *fdp = p->p_fd; struct file *fp; struct vnode *vp; off_t offset; @@ -1765,10 +1791,10 @@ /* * Positional write system call. */ int -sys_pwrite(p, v, retval) - struct proc *p; +sys_pwrite(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_pwrite_args /* { @@ -1776,8 +1802,9 @@ syscallarg(const void *) buf; syscallarg(size_t) nbyte; syscallarg(off_t) offset; } */ *uap = v; + struct proc *p = l->l_proc; struct filedesc *fdp = p->p_fd; struct file *fp; struct vnode *vp; off_t offset; @@ -1818,10 +1845,10 @@ /* * Positional gather write system call. */ int -sys_pwritev(p, v, retval) - struct proc *p; +sys_pwritev(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_pwritev_args /* { @@ -1829,8 +1856,9 @@ syscallarg(const struct iovec *) iovp; syscallarg(int) iovcnt; syscallarg(off_t) offset; } */ *uap = v; + struct proc *p = l->l_proc; struct filedesc *fdp = p->p_fd; struct file *fp; struct vnode *vp; off_t offset; @@ -1871,17 +1899,18 @@ /* * Check access permissions. */ int -sys_access(p, v, retval) - struct proc *p; +sys_access(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_access_args /* { syscallarg(const char *) path; syscallarg(int) flags; } */ *uap = v; + struct proc *p = l->l_proc; struct ucred *cred = p->p_ucred; struct vnode *vp; int error, flags, t_gid, t_uid; struct nameidata nd; @@ -1921,17 +1950,18 @@ * Get file status; this version follows links. */ /* ARGSUSED */ int -sys___stat13(p, v, retval) - struct proc *p; +sys___stat13(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys___stat13_args /* { syscallarg(const char *) path; syscallarg(struct stat *) ub; } */ *uap = v; + struct proc *p = l->l_proc; struct stat sb; int error; struct nameidata nd; @@ -1951,17 +1981,18 @@ * Get file status; this version does not follow links. */ /* ARGSUSED */ int -sys___lstat13(p, v, retval) - struct proc *p; +sys___lstat13(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys___lstat13_args /* { syscallarg(const char *) path; syscallarg(struct stat *) ub; } */ *uap = v; + struct proc *p = l->l_proc; struct stat sb; int error; struct nameidata nd; @@ -1981,17 +2012,18 @@ * Get configurable pathname variables. */ /* ARGSUSED */ int -sys_pathconf(p, v, retval) - struct proc *p; +sys_pathconf(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_pathconf_args /* { syscallarg(const char *) path; syscallarg(int) name; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, @@ -2007,18 +2039,19 @@ * Return target name of a symbolic link. */ /* ARGSUSED */ int -sys_readlink(p, v, retval) - struct proc *p; +sys_readlink(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_readlink_args /* { syscallarg(const char *) path; syscallarg(char *) buf; syscallarg(size_t) count; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; struct iovec aiov; struct uio auio; int error; @@ -2053,17 +2086,18 @@ * Change flags of a file given a path name. */ /* ARGSUSED */ int -sys_chflags(p, v, retval) - struct proc *p; +sys_chflags(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_chflags_args /* { syscallarg(const char *) path; syscallarg(u_long) flags; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; int error; struct nameidata nd; @@ -2080,17 +2114,18 @@ * Change flags of a file given a file descriptor. */ /* ARGSUSED */ int -sys_fchflags(p, v, retval) - struct proc *p; +sys_fchflags(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_fchflags_args /* { syscallarg(int) fd; syscallarg(u_long) flags; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; struct file *fp; int error; @@ -2108,17 +2143,18 @@ * Change flags of a file given a path name; this version does * not follow links. */ int -sys_lchflags(p, v, retval) - struct proc *p; +sys_lchflags(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_lchflags_args /* { syscallarg(const char *) path; syscallarg(u_long) flags; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; int error; struct nameidata nd; @@ -2168,17 +2204,18 @@ * Change mode of a file given path name; this version follows links. */ /* ARGSUSED */ int -sys_chmod(p, v, retval) - struct proc *p; +sys_chmod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_chmod_args /* { syscallarg(const char *) path; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); @@ -2195,17 +2232,18 @@ * Change mode of a file given a file descriptor. */ /* ARGSUSED */ int -sys_fchmod(p, v, retval) - struct proc *p; +sys_fchmod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_fchmod_args /* { syscallarg(int) fd; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; struct file *fp; int error; /* getvnode() will use the descriptor for us */ @@ -2221,17 +2259,18 @@ * Change mode of a file given path name; this version does not follow links. */ /* ARGSUSED */ int -sys_lchmod(p, v, retval) - struct proc *p; +sys_lchmod(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_lchmod_args /* { syscallarg(const char *) path; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct nameidata nd; NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p); @@ -2269,18 +2308,19 @@ * Set ownership given a path name; this version follows links. */ /* ARGSUSED */ int -sys_chown(p, v, retval) - struct proc *p; +sys_chown(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_chown_args /* { syscallarg(const char *) path; syscallarg(uid_t) uid; syscallarg(gid_t) gid; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); @@ -2298,18 +2338,19 @@ * Provides POSIX semantics. */ /* ARGSUSED */ int -sys___posix_chown(p, v, retval) - struct proc *p; +sys___posix_chown(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_chown_args /* { syscallarg(const char *) path; syscallarg(uid_t) uid; syscallarg(gid_t) gid; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); @@ -2326,18 +2367,19 @@ * Set ownership given a file descriptor. */ /* ARGSUSED */ int -sys_fchown(p, v, retval) - struct proc *p; +sys_fchown(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_fchown_args /* { syscallarg(int) fd; syscallarg(uid_t) uid; syscallarg(gid_t) gid; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct file *fp; /* getvnode() will use the descriptor for us */ @@ -2354,18 +2396,19 @@ * Set ownership given a file descriptor, providing POSIX/XPG semantics. */ /* ARGSUSED */ int -sys___posix_fchown(p, v, retval) - struct proc *p; +sys___posix_fchown(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_fchown_args /* { syscallarg(int) fd; syscallarg(uid_t) uid; syscallarg(gid_t) gid; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct file *fp; /* getvnode() will use the descriptor for us */ @@ -2382,18 +2425,19 @@ * Set ownership given a path name; this version does not follow links. */ /* ARGSUSED */ int -sys_lchown(p, v, retval) - struct proc *p; +sys_lchown(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_lchown_args /* { syscallarg(const char *) path; syscallarg(uid_t) uid; syscallarg(gid_t) gid; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct nameidata nd; NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p); @@ -2411,18 +2455,19 @@ * Provides POSIX/XPG semantics. */ /* ARGSUSED */ int -sys___posix_lchown(p, v, retval) - struct proc *p; +sys___posix_lchown(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_lchown_args /* { syscallarg(const char *) path; syscallarg(uid_t) uid; syscallarg(gid_t) gid; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct nameidata nd; NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p); @@ -2498,17 +2543,18 @@ * version follows links. */ /* ARGSUSED */ int -sys_utimes(p, v, retval) - struct proc *p; +sys_utimes(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_utimes_args /* { syscallarg(const char *) path; syscallarg(const struct timeval *) tptr; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); @@ -2525,17 +2571,18 @@ * Set the access and modification times given a file descriptor. */ /* ARGSUSED */ int -sys_futimes(p, v, retval) - struct proc *p; +sys_futimes(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_futimes_args /* { syscallarg(int) fd; syscallarg(const struct timeval *) tptr; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct file *fp; /* getvnode() will use the descriptor for us */ @@ -2552,17 +2599,18 @@ * version does not follow links. */ /* ARGSUSED */ int -sys_lutimes(p, v, retval) - struct proc *p; +sys_lutimes(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_lutimes_args /* { syscallarg(const char *) path; syscallarg(const struct timeval *) tptr; } */ *uap = v; + struct proc *p = l->l_proc; int error; struct nameidata nd; NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p); @@ -2613,18 +2661,19 @@ * Truncate a file given its path name. */ /* ARGSUSED */ int -sys_truncate(p, v, retval) - struct proc *p; +sys_truncate(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_truncate_args /* { syscallarg(const char *) path; syscallarg(int) pad; syscallarg(off_t) length; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; struct vattr vattr; int error; struct nameidata nd; @@ -2651,18 +2700,19 @@ * Truncate a file given a file descriptor. */ /* ARGSUSED */ int -sys_ftruncate(p, v, retval) - struct proc *p; +sys_ftruncate(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_ftruncate_args /* { syscallarg(int) fd; syscallarg(int) pad; syscallarg(off_t) length; } */ *uap = v; + struct proc *p = l->l_proc; struct vattr vattr; struct vnode *vp; struct file *fp; int error; @@ -2694,16 +2744,17 @@ * Sync an open file. */ /* ARGSUSED */ int -sys_fsync(p, v, retval) - struct proc *p; +sys_fsync(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_fsync_args /* { syscallarg(int) fd; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; struct file *fp; int error; @@ -2725,16 +2776,17 @@ * Sync the data of an open file. */ /* ARGSUSED */ int -sys_fdatasync(p, v, retval) - struct proc *p; +sys_fdatasync(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_fdatasync_args /* { syscallarg(int) fd; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; struct file *fp; int error; @@ -2753,17 +2805,18 @@ * Rename files, (standard) BSD semantics frontend. */ /* ARGSUSED */ int -sys_rename(p, v, retval) - struct proc *p; +sys_rename(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_rename_args /* { syscallarg(const char *) from; syscallarg(const char *) to; } */ *uap = v; + struct proc *p = l->l_proc; return (rename_files(SCARG(uap, from), SCARG(uap, to), p, 0)); } @@ -2771,17 +2824,18 @@ * Rename files, POSIX semantics frontend. */ /* ARGSUSED */ int -sys___posix_rename(p, v, retval) - struct proc *p; +sys___posix_rename(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys___posix_rename_args /* { syscallarg(const char *) from; syscallarg(const char *) to; } */ *uap = v; + struct proc *p = l->l_proc; return (rename_files(SCARG(uap, from), SCARG(uap, to), p, 1)); } @@ -2883,17 +2937,18 @@ * Make a directory file. */ /* ARGSUSED */ int -sys_mkdir(p, v, retval) - struct proc *p; +sys_mkdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_mkdir_args /* { syscallarg(const char *) path; syscallarg(int) mode; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; struct vattr vattr; int error; struct nameidata nd; @@ -2926,16 +2981,17 @@ * Remove a directory file. */ /* ARGSUSED */ int -sys_rmdir(p, v, retval) - struct proc *p; +sys_rmdir(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_rmdir_args /* { syscallarg(const char *) path; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; int error; struct nameidata nd; @@ -2979,18 +3035,19 @@ /* * Read a block of directory entries in a file system independent format. */ int -sys_getdents(p, v, retval) - struct proc *p; +sys_getdents(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_getdents_args /* { syscallarg(int) fd; syscallarg(char *) buf; syscallarg(size_t) count; } */ *uap = v; + struct proc *p = l->l_proc; struct file *fp; int error, done; /* getvnode() will use the descriptor for us */ @@ -3011,16 +3068,17 @@ /* * Set the mode mask for creation of filesystem nodes. */ int -sys_umask(p, v, retval) - struct proc *p; +sys_umask(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_umask_args /* { syscallarg(mode_t) newmask; } */ *uap = v; + struct proc *p = l->l_proc; struct cwdinfo *cwdi; cwdi = p->p_cwdi; *retval = cwdi->cwdi_cmask; @@ -3033,16 +3091,17 @@ * away from vnode. */ /* ARGSUSED */ int -sys_revoke(p, v, retval) - struct proc *p; +sys_revoke(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_revoke_args /* { syscallarg(const char *) path; } */ *uap = v; + struct proc *p = l->l_proc; struct vnode *vp; struct vattr vattr; int error; struct nameidata nd; Index: sys/miscfs/genfs/genfs_vnops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/miscfs/genfs/genfs_vnops.c,v retrieving revision 1.32 retrieving revision 1.31.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.32 -r1.31.2.2 --- sys/miscfs/genfs/genfs_vnops.c 2001/03/10 22:46:45 1.32 +++ sys/miscfs/genfs/genfs_vnops.c 2001/04/09 01:58:08 1.31.2.2 @@ -37,8 +37,9 @@ #include "opt_nfsserver.h" #include #include +#include #include #include #include #include @@ -253,9 +254,9 @@ struct vnode *a_vp; int a_flags; } */ *ap = v; struct vnode *vp, *vq; - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ #ifdef DIAGNOSTIC if ((ap->a_flags & REVOKEALL) == 0) panic("genfs_revoke: not revokeall"); @@ -450,9 +451,9 @@ struct buf *bp, *mbp; struct vnode *vp = ap->a_vp; struct uvm_object *uobj = &vp->v_uvm.u_obj; struct vm_page *pgs[16]; /* XXXUBC 16 */ - struct ucred *cred = curproc->p_ucred; /* XXXUBC curproc */ + struct ucred *cred = curproc->l_proc->p_ucred; /* XXXUBC curproc */ boolean_t async = (flags & PGO_SYNCIO) == 0; boolean_t write = (ap->a_access_type & VM_PROT_WRITE) != 0; boolean_t sawhole = FALSE; UVMHIST_FUNC("genfs_getpages"); UVMHIST_CALLED(ubchist); Index: sys/miscfs/portal/portal_vnops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/miscfs/portal/portal_vnops.c,v retrieving revision 1.37 retrieving revision 1.37.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.37 -r1.37.2.1 --- sys/miscfs/portal/portal_vnops.c 2001/01/22 12:17:39 1.37 +++ sys/miscfs/portal/portal_vnops.c 2001/03/05 22:49:50 1.37.2.1 @@ -67,9 +67,9 @@ #include static int portal_fileid = PORTAL_ROOTFILEID+1; -static void portal_closefd __P((struct proc *, int)); +static void portal_closefd __P((struct lwp *, int)); static int portal_connect __P((struct socket *, struct socket *)); int portal_lookup __P((void *)); #define portal_create genfs_eopnotsupp_rele @@ -164,10 +164,10 @@ const struct vnodeopv_desc portal_vnodeop_opv_desc = { &portal_vnodeop_p, portal_vnodeop_entries }; static void -portal_closefd(p, fd) - struct proc *p; +portal_closefd(l, fd) + struct lwp *l; int fd; { struct sys_close_args /* { syscallarg(int) fd; @@ -175,9 +175,9 @@ register_t retval[2]; int error; SCARG(&ua, fd) = fd; - error = sys_close(p, &ua, retval); + error = sys_close(l, &ua, retval); /* * We should never get an error, and there isn't anything * we could do if we got one, so just print a message. */ @@ -491,9 +491,9 @@ */ int i; printf("portal_open: %d extra fds\n", newfds - 1); for (i = 1; i < newfds; i++) { - portal_closefd(p, *ip); + portal_closefd(curproc, *ip); /* XXXNJWLWP */ ip++; } } @@ -502,9 +502,9 @@ * of the mode of the existing descriptor. */ fp = p->p_fd->fd_ofiles[fd]; if (((ap->a_mode & (FREAD|FWRITE)) | fp->f_flag) != fp->f_flag) { - portal_closefd(p, fd); + portal_closefd(curproc, fd); /* XXXNJWLWP */ error = EACCES; goto bad; } Index: sys/miscfs/procfs/procfs.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/miscfs/procfs/procfs.h,v retrieving revision 1.34 retrieving revision 1.33.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.34 -r1.33.2.2 --- sys/miscfs/procfs/procfs.h 2001/03/29 22:41:52 1.34 +++ sys/miscfs/procfs/procfs.h 2001/04/09 01:58:09 1.33.2.2 @@ -128,17 +128,17 @@ int procfs_freevp __P((struct vnode *)); int procfs_allocvp __P((struct mount *, struct vnode **, long, pfstype)); int procfs_donote __P((struct proc *, struct proc *, struct pfsnode *, struct uio *)); -int procfs_doregs __P((struct proc *, struct proc *, struct pfsnode *, +int procfs_doregs __P((struct proc *, struct lwp *, struct pfsnode *, struct uio *)); -int procfs_dofpregs __P((struct proc *, struct proc *, struct pfsnode *, +int procfs_dofpregs __P((struct proc *, struct lwp *, struct pfsnode *, struct uio *)); -int procfs_domem __P((struct proc *, struct proc *, struct pfsnode *, +int procfs_domem __P((struct proc *, struct lwp *, struct pfsnode *, struct uio *)); -int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *, +int procfs_doctl __P((struct proc *, struct lwp *, struct pfsnode *, struct uio *)); -int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *, +int procfs_dostatus __P((struct proc *, struct lwp *, struct pfsnode *, struct uio *)); int procfs_domap __P((struct proc *, struct proc *, struct pfsnode *, struct uio *, int)); int procfs_docmdline __P((struct proc *, struct proc *, struct pfsnode *, @@ -153,12 +153,12 @@ void procfs_hashinit __P((void)); void procfs_hashdone __P((void)); /* functions to check whether or not files should be displayed */ -int procfs_validfile __P((struct proc *, struct mount *)); -int procfs_validfpregs __P((struct proc *, struct mount *)); -int procfs_validregs __P((struct proc *, struct mount *)); -int procfs_validmap __P((struct proc *, struct mount *)); +int procfs_validfile __P((struct lwp *, struct mount *)); +int procfs_validfpregs __P((struct lwp *, struct mount *)); +int procfs_validregs __P((struct lwp *, struct mount *)); +int procfs_validmap __P((struct lwp *, struct mount *)); int procfs_rw __P((void *)); int procfs_getcpuinfstr __P((char *, int *)); Index: sys/miscfs/procfs/procfs_ctl.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/miscfs/procfs/procfs_ctl.c,v retrieving revision 1.19 retrieving revision 1.19.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.19 -r1.19.2.1 --- sys/miscfs/procfs/procfs_ctl.c 2001/01/18 20:28:21 1.19 +++ sys/miscfs/procfs/procfs_ctl.c 2001/03/05 22:49:51 1.19.2.1 @@ -89,23 +89,23 @@ { "usr1", SIGUSR1 }, { "usr2", SIGUSR2 }, { 0 }, }; -int procfs_control __P((struct proc *, struct proc *, int, int)); +int procfs_control __P((struct proc *, struct lwp *, int, int)); /* Macros to clear/set/test flags. */ #define SET(t, f) (t) |= (f) #define CLR(t, f) (t) &= ~(f) #define ISSET(t, f) ((t) & (f)) int -procfs_control(curp, p, op, sig) +procfs_control(curp, l, op, sig) struct proc *curp; - struct proc *p; + struct lwp *l; int op, sig; { int s, error; - + struct proc *p = l->l_proc; /* * Attach - attaches the target process for debugging * by the calling process. */ @@ -232,11 +232,11 @@ #endif case PROCFS_CTL_RUN: case PROCFS_CTL_DETACH: #ifdef PT_STEP - PHOLD(p); - error = process_sstep(p, op == PROCFS_CTL_STEP); - PRELE(p); + PHOLD(l); + error = process_sstep(l, op == PROCFS_CTL_STEP); + PRELE(l); if (error) return (error); #endif @@ -255,12 +255,12 @@ } sendsig: /* Finally, deliver the requested signal (or none). */ - if (p->p_stat == SSTOP) { + if (l->l_stat == LSSTOP) { p->p_xstat = sig; SCHED_LOCK(s); - setrunnable(p); + setrunnable(l); SCHED_UNLOCK(s); } else { if (sig != 0) psignal(p, sig); @@ -270,10 +270,10 @@ case PROCFS_CTL_WAIT: /* * Wait for the target process to stop. */ - while (p->p_stat != SSTOP && P_ZOMBIE(p)) { - error = tsleep(p, PWAIT|PCATCH, "procfsx", 0); + while (l->l_stat != LSSTOP && P_ZOMBIE(p)) { + error = tsleep(l, PWAIT|PCATCH, "procfsx", 0); if (error) return (error); } return (0); @@ -282,18 +282,19 @@ panic("procfs_control"); } int -procfs_doctl(curp, p, pfs, uio) +procfs_doctl(curp, l, pfs, uio) struct proc *curp; + struct lwp *l; struct pfsnode *pfs; struct uio *uio; - struct proc *p; { int xlen; int error; char msg[PROCFS_CTLLEN+1]; const vfs_namemap_t *nm; + struct proc *p = l->l_proc; if (uio->uio_rw != UIO_WRITE) return (EOPNOTSUPP); @@ -314,15 +315,15 @@ error = EOPNOTSUPP; nm = vfs_findname(ctlnames, msg, xlen); if (nm) { - error = procfs_control(curp, p, nm->nm_val, 0); + error = procfs_control(curp, l, nm->nm_val, 0); } else { nm = vfs_findname(signames, msg, xlen); if (nm) { if (ISSET(p->p_flag, P_TRACED) && p->p_pptr == curp) - error = procfs_control(curp, p, PROCFS_CTL_RUN, + error = procfs_control(curp, l, PROCFS_CTL_RUN, nm->nm_val); else { psignal(p, nm->nm_val); error = 0; Index: sys/miscfs/procfs/procfs_fpregs.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/miscfs/procfs/procfs_fpregs.c,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.7 -r1.7.2.1 --- sys/miscfs/procfs/procfs_fpregs.c 2001/01/17 00:09:07 1.7 +++ sys/miscfs/procfs/procfs_fpregs.c 2001/03/05 22:49:51 1.7.2.1 @@ -42,18 +42,19 @@ #include #include #include #include +#include #include #include #include #include #include int -procfs_dofpregs(curp, p, pfs, uio) +procfs_dofpregs(curp, l, pfs, uio) struct proc *curp; /* tracer */ - struct proc *p; /* traced */ + struct lwp *l; /* traced */ struct pfsnode *pfs; struct uio *uio; { #if defined(PT_GETFPREGS) || defined(PT_SETFPREGS) @@ -61,9 +62,9 @@ struct fpreg r; char *kv; int kl; - if ((error = procfs_checkioperm(curp, p)) != 0) + if ((error = procfs_checkioperm(curp, l->l_proc)) != 0) return (error); kl = sizeof(r); kv = (char *) &r; @@ -72,24 +73,24 @@ kl -= uio->uio_offset; if (kl > uio->uio_resid) kl = uio->uio_resid; - PHOLD(p); + PHOLD(l); if (kl < 0) error = EINVAL; else - error = process_read_fpregs(p, &r); + error = process_read_fpregs(l, &r); if (error == 0) error = uiomove(kv, kl, uio); if (error == 0 && uio->uio_rw == UIO_WRITE) { - if (p->p_stat != SSTOP) + if (l->l_stat != LSSTOP) error = EBUSY; else - error = process_write_fpregs(p, &r); + error = process_write_fpregs(l, &r); } - PRELE(p); + PRELE(l); uio->uio_offset = 0; return (error); #else @@ -97,15 +98,15 @@ #endif } int -procfs_validfpregs(p, mp) - struct proc *p; +procfs_validfpregs(l, mp) + struct lwp *l; struct mount *mp; { #if defined(PT_SETFPREGS) || defined(PT_GETFPREGS) - return ((p->p_flag & P_SYSTEM) == 0); + return ((l->l_proc->p_flag & P_SYSTEM) == 0); #else return (0); #endif } Index: sys/miscfs/procfs/procfs_map.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/miscfs/procfs/procfs_map.c,v retrieving revision 1.12 retrieving revision 1.10.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.12 -r1.10.2.2 --- sys/miscfs/procfs/procfs_map.c 2001/04/02 07:16:05 1.12 +++ sys/miscfs/procfs/procfs_map.c 2001/04/09 01:58:09 1.10.2.2 @@ -42,8 +42,9 @@ */ #include #include +#include #include #include #include #include @@ -93,9 +94,9 @@ return (0); error = 0; buf_full = 0; - if (map != &curproc->p_vmspace->vm_map) + if (map != &curproc->l_proc->p_vmspace->vm_map) vm_map_lock_read(map); for (entry = map->header.next; ((uio->uio_resid > 0) && (entry != &map->header)); entry = entry->next) { @@ -163,17 +164,17 @@ error = uiomove(mebuffer, len, uio); if (error) break; } - if (map != &curproc->p_vmspace->vm_map) + if (map != &curproc->l_proc->p_vmspace->vm_map) vm_map_unlock_read(map); return error; } int -procfs_validmap(struct proc *p, struct mount *mp) +procfs_validmap(struct lwp *l, struct mount *mp) { - return ((p->p_flag & P_SYSTEM) == 0); + return ((l->l_proc->p_flag & P_SYSTEM) == 0); } /* * Try to find a pathname for a vnode. Since there is no mapping Index: sys/miscfs/procfs/procfs_mem.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/miscfs/procfs/procfs_mem.c,v retrieving revision 1.27 retrieving revision 1.27.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.27 -r1.27.2.1 --- sys/miscfs/procfs/procfs_mem.c 2000/11/24 18:58:37 1.27 +++ sys/miscfs/procfs/procfs_mem.c 2001/03/05 22:49:51 1.27.2.1 @@ -48,8 +48,9 @@ #include #include #include #include +#include #include #include #include @@ -64,18 +65,19 @@ * the kernel and then doing a uiomove direct * from the kernel address space. */ int -procfs_domem(curp, p, pfs, uio) +procfs_domem(curp, l, pfs, uio) struct proc *curp; /* tracer */ - struct proc *p; /* traced */ + struct lwp *l; /* traced */ struct pfsnode *pfs; struct uio *uio; { int error; size_t len; vaddr_t addr; + struct proc *p = l->l_proc; len = uio->uio_resid; if (len == 0) Index: sys/miscfs/procfs/procfs_regs.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/miscfs/procfs/procfs_regs.c,v retrieving revision 1.12 retrieving revision 1.12.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.12 -r1.12.2.1 --- sys/miscfs/procfs/procfs_regs.c 2001/01/17 00:09:08 1.12 +++ sys/miscfs/procfs/procfs_regs.c 2001/03/05 22:49:51 1.12.2.1 @@ -42,18 +42,19 @@ #include #include #include #include +#include #include #include #include #include #include int -procfs_doregs(curp, p, pfs, uio) +procfs_doregs(curp, l, pfs, uio) struct proc *curp; /* tracer */ - struct proc *p; /* traced */ + struct lwp *l; /* traced */ struct pfsnode *pfs; struct uio *uio; { #if defined(PT_GETREGS) || defined(PT_SETREGS) @@ -61,9 +62,9 @@ struct reg r; char *kv; int kl; - if ((error = procfs_checkioperm(curp, p)) != 0) + if ((error = procfs_checkioperm(curp, l->l_proc)) != 0) return (EPERM); kl = sizeof(r); kv = (char *) &r; @@ -72,24 +73,24 @@ kl -= uio->uio_offset; if (kl > uio->uio_resid) kl = uio->uio_resid; - PHOLD(p); + PHOLD(l); if (kl < 0) error = EINVAL; else - error = process_read_regs(p, &r); + error = process_read_regs(l, &r); if (error == 0) error = uiomove(kv, kl, uio); if (error == 0 && uio->uio_rw == UIO_WRITE) { - if (p->p_stat != SSTOP) + if (l->l_stat != LSSTOP) error = EBUSY; else - error = process_write_regs(p, &r); + error = process_write_regs(l, &r); } - PRELE(p); + PRELE(l); uio->uio_offset = 0; return (error); #else @@ -97,15 +98,15 @@ #endif } int -procfs_validregs(p, mp) - struct proc *p; +procfs_validregs(l, mp) + struct lwp *l; struct mount *mp; { #if defined(PT_SETREGS) || defined(PT_GETREGS) - return ((p->p_flag & P_SYSTEM) == 0); + return ((l->l_proc->p_flag & P_SYSTEM) == 0); #else return (0); #endif } Index: sys/miscfs/procfs/procfs_status.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/miscfs/procfs/procfs_status.c,v retrieving revision 1.16 retrieving revision 1.16.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.16 -r1.16.2.1 --- sys/miscfs/procfs/procfs_status.c 2000/12/30 23:14:52 1.16 +++ sys/miscfs/procfs/procfs_status.c 2001/03/05 22:49:51 1.16.2.1 @@ -51,17 +51,18 @@ #include #include int -procfs_dostatus(curp, p, pfs, uio) +procfs_dostatus(curp, l, pfs, uio) struct proc *curp; - struct proc *p; + struct lwp *l; struct pfsnode *pfs; struct uio *uio; { struct session *sess; struct tty *tp; struct ucred *cr; + struct proc *p = l->l_proc; char *ps; char *sep; int pid, ppid, pgid, sid; int i; @@ -103,9 +104,9 @@ } if (*sep != ',') ps += sprintf(ps, "noflags"); - if (p->p_flag & P_INMEM) + if (l->l_flag & L_INMEM) ps += sprintf(ps, " %ld,%ld", p->p_stats->p_start.tv_sec, p->p_stats->p_start.tv_usec); else @@ -122,9 +123,9 @@ st.tv_usec); } ps += sprintf(ps, " %s", - (p->p_wchan && p->p_wmesg) ? p->p_wmesg : "nochan"); + (l->l_wchan && l->l_wmesg) ? l->l_wmesg : "nochan"); cr = p->p_ucred; ps += sprintf(ps, " %d", cr->cr_uid); Index: sys/miscfs/procfs/procfs_subr.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/miscfs/procfs/procfs_subr.c,v retrieving revision 1.37 retrieving revision 1.36.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.37 -r1.36.2.2 --- sys/miscfs/procfs/procfs_subr.c 2001/03/29 22:41:52 1.37 +++ sys/miscfs/procfs/procfs_subr.c 2001/04/09 01:58:09 1.36.2.2 @@ -197,14 +197,39 @@ struct vnode *vp = ap->a_vp; struct uio *uio = ap->a_uio; struct proc *curp = uio->uio_procp; struct pfsnode *pfs = VTOPFS(vp); + struct lwp *l; struct proc *p; p = PFIND(pfs->pfs_pid); if (p == 0) return (EINVAL); + /* XXX NJWLWP + * The entire procfs interface needs work to be useful to + * a process with multiple LWPs. For the moment, we'll + * just kluge this and fail on others. + */ + + if (p->p_nlwps > 1) + switch (pfs->pfs_type) { + case Pnote: + case Pnotepg: + case Pstatus: + case Pmap: + case Pmem: + case Pcmdline: + break; + case Pregs: + case Pfpregs: + case Pctl: + default: + return (EOPNOTSUPP); + } + + l = LIST_FIRST(&p->p_lwps); + switch (pfs->pfs_type) { case Pregs: case Pfpregs: case Pmem: @@ -226,27 +251,27 @@ case Pnotepg: return (procfs_donote(curp, p, pfs, uio)); case Pregs: - return (procfs_doregs(curp, p, pfs, uio)); + return (procfs_doregs(curp, l, pfs, uio)); case Pfpregs: - return (procfs_dofpregs(curp, p, pfs, uio)); + return (procfs_dofpregs(curp, l, pfs, uio)); case Pctl: - return (procfs_doctl(curp, p, pfs, uio)); + return (procfs_doctl(curp, l, pfs, uio)); case Pstatus: - return (procfs_dostatus(curp, p, pfs, uio)); + return (procfs_dostatus(curp, l, pfs, uio)); case Pmap: return (procfs_domap(curp, p, pfs, uio, 0)); case Pmaps: return (procfs_domap(curp, p, pfs, uio, 1)); case Pmem: - return (procfs_domem(curp, p, pfs, uio)); + return (procfs_domem(curp, l, pfs, uio)); case Pcmdline: return (procfs_docmdline(curp, p, pfs, uio)); Index: sys/miscfs/procfs/procfs_vnops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/miscfs/procfs/procfs_vnops.c,v retrieving revision 1.80 retrieving revision 1.78.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.80 -r1.78.2.2 --- sys/miscfs/procfs/procfs_vnops.c 2001/03/30 20:25:11 1.80 +++ sys/miscfs/procfs/procfs_vnops.c 2001/04/09 01:58:10 1.78.2.2 @@ -47,8 +47,9 @@ #include #include #include #include +#include #include #include #include #include @@ -69,9 +70,9 @@ * Vnode Operations. * */ -static int procfs_validfile_linux __P((struct proc *, struct mount *)); +static int procfs_validfile_linux __P((struct lwp *, struct mount *)); /* * This is a list of the valid names in the * process-specific sub-directories. It is @@ -81,9 +82,9 @@ u_char pt_type; u_char pt_namlen; char *pt_name; pfstype pt_pfstype; - int (*pt_valid) __P((struct proc *, struct mount *)); + int (*pt_valid) __P((struct lwp *, struct mount *)); } proc_targets[] = { #define N(s) sizeof(s)-1, s /* name type validp */ { DT_DIR, N("."), Pproc, NULL }, @@ -595,9 +596,9 @@ vap->va_nlink = 1; vap->va_uid = 0; vap->va_gid = 0; vap->va_bytes = vap->va_size = - sprintf(buf, "%ld", (long)curproc->p_pid); + sprintf(buf, "%ld", (long)curproc->l_proc->p_pid); break; } case Pself: @@ -787,9 +788,10 @@ pt = &proc_root_targets[i]; if (cnp->cn_namelen == pt->pt_namlen && memcmp(pt->pt_name, pname, cnp->cn_namelen) == 0 && (pt->pt_valid == NULL || - (*pt->pt_valid)(p, dvp->v_mount))) + (*pt->pt_valid)(LIST_FIRST(&p->p_lwps), + dvp->v_mount))) break; } if (i != nproc_root_targets) { @@ -841,9 +843,10 @@ for (pt = proc_targets, i = 0; i < nproc_targets; pt++, i++) { if (cnp->cn_namelen == pt->pt_namlen && memcmp(pt->pt_name, pname, cnp->cn_namelen) == 0 && (pt->pt_valid == NULL || - (*pt->pt_valid)(p, dvp->v_mount))) + (*pt->pt_valid)(LIST_FIRST(&p->p_lwps), + dvp->v_mount))) goto found; } break; @@ -876,25 +879,25 @@ return (cnp->cn_nameiop == LOOKUP ? ENOENT : EROFS); } int -procfs_validfile(p, mp) - struct proc *p; +procfs_validfile(l, mp) + struct lwp *l; struct mount *mp; { - return (p->p_textvp != NULL); + return (l->l_proc->p_textvp != NULL); } static int -procfs_validfile_linux(p, mp) - struct proc *p; +procfs_validfile_linux(l, mp) + struct lwp *l; struct mount *mp; { int flags; flags = VFSTOPROC(mp)->pmnt_flags; return ((flags & PROCFSMNT_LINUXCOMPAT) && - (p == NULL || procfs_validfile(p, mp))); + (l == NULL || procfs_validfile(l, mp))); } /* * readdir returns directory entries from pfsnode (vp). @@ -969,9 +972,10 @@ for (pt = &proc_targets[i]; uio->uio_resid >= UIO_MX && i < nproc_targets; pt++, i++) { if (pt->pt_valid && - (*pt->pt_valid)(p, vp->v_mount) == 0) + (*pt->pt_valid)(LIST_FIRST(&p->p_lwps), + vp->v_mount) == 0) continue; d.d_fileno = PROCFS_FILENO(pfs->pfs_pid, pt->pt_pfstype); d.d_namlen = pt->pt_namlen; @@ -1133,9 +1137,9 @@ char buf[16]; /* should be enough */ int len; if (VTOPFS(ap->a_vp)->pfs_fileno == PROCFS_FILENO(0, Pcurproc)) - len = sprintf(buf, "%ld", (long)curproc->p_pid); + len = sprintf(buf, "%ld", (long)curproc->l_proc->p_pid); else if (VTOPFS(ap->a_vp)->pfs_fileno == PROCFS_FILENO(0, Pself)) len = sprintf(buf, "%s", "curproc"); else return (EINVAL); Index: sys/miscfs/specfs/spec_vnops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/miscfs/specfs/spec_vnops.c,v retrieving revision 1.53 retrieving revision 1.53.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.53 -r1.53.2.1 --- sys/miscfs/specfs/spec_vnops.c 2001/01/22 12:17:40 1.53 +++ sys/miscfs/specfs/spec_vnops.c 2001/03/05 22:49:52 1.53.2.1 @@ -35,8 +35,9 @@ * @(#)spec_vnops.c 8.15 (Berkeley) 7/14/95 */ #include +#include #include #include #include #include @@ -257,9 +258,10 @@ #ifdef DIAGNOSTIC if (uio->uio_rw != UIO_READ) panic("spec_read mode"); - if (uio->uio_segflg == UIO_USERSPACE && uio->uio_procp != curproc) + if (uio->uio_segflg == UIO_USERSPACE && + uio->uio_procp != curproc->l_proc) panic("spec_read proc"); #endif if (uio->uio_resid == 0) return (0); @@ -343,9 +345,10 @@ #ifdef DIAGNOSTIC if (uio->uio_rw != UIO_WRITE) panic("spec_write mode"); - if (uio->uio_segflg == UIO_USERSPACE && uio->uio_procp != curproc) + if (uio->uio_segflg == UIO_USERSPACE && + uio->uio_procp != curproc->l_proc) panic("spec_write proc"); #endif switch (vp->v_type) { Index: sys/miscfs/syncfs/sync_subr.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/miscfs/syncfs/sync_subr.c,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.8 -r1.8.2.1 --- sys/miscfs/syncfs/sync_subr.c 2000/11/27 08:39:46 1.8 +++ sys/miscfs/syncfs/sync_subr.c 2001/03/05 22:49:52 1.8.2.1 @@ -33,8 +33,9 @@ #include #include #include +#include #include #include #include #include @@ -61,9 +62,9 @@ static int syncer_delayno = 0; static long syncer_last; static struct synclist *syncer_workitem_pending; -struct proc *updateproc = NULL; +struct lwp *updateproc = NULL; void vn_initialize_syncerd() { @@ -181,10 +182,10 @@ while ((vp = LIST_FIRST(slp)) != NULL) { if (VOP_ISLOCKED(vp) == 0) { vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - (void) VOP_FSYNC(vp, curproc->p_ucred, - FSYNC_LAZY, 0, 0, curproc); + (void) VOP_FSYNC(vp, curproc->l_proc->p_ucred, + FSYNC_LAZY, 0, 0, curproc->l_proc); VOP_UNLOCK(vp, 0); } s = splbio(); if (LIST_FIRST(slp) == vp) { Index: sys/miscfs/union/union_subr.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/miscfs/union/union_subr.c,v retrieving revision 1.40 retrieving revision 1.40.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.40 -r1.40.2.1 --- sys/miscfs/union/union_subr.c 2000/08/03 20:41:28 1.40 +++ sys/miscfs/union/union_subr.c 2001/03/05 22:49:52 1.40.2.1 @@ -397,10 +397,11 @@ */ #ifdef DIAGNOSTIC if ((un->un_flags & UN_LOCKED) == 0) panic("union: . not locked"); - else if (curproc && un->un_pid != curproc->p_pid && - un->un_pid > -1 && curproc->p_pid > -1) + else if (curproc && + un->un_pid != curproc->l_proc->p_pid && + un->un_pid > -1 && curproc->l_proc->p_pid > -1) panic("union: allocvp not lock owner"); #endif } else { if (un->un_flags & UN_LOCKED) { @@ -413,9 +414,9 @@ un->un_flags |= UN_LOCKED; #ifdef DIAGNOSTIC if (curproc) - un->un_pid = curproc->p_pid; + un->un_pid = curproc->l_proc->p_pid; else un->un_pid = -1; #endif } @@ -514,9 +515,9 @@ if (un->un_uppervp) un->un_flags |= UN_ULOCK; #ifdef DIAGNOSTIC if (curproc) - un->un_pid = curproc->p_pid; + un->un_pid = curproc->l_proc->p_pid; else un->un_pid = -1; #endif if (cnp && (lowervp != NULLVP)) { Index: sys/miscfs/union/union_vnops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/miscfs/union/union_vnops.c,v retrieving revision 1.50 retrieving revision 1.50.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.50 -r1.50.2.1 --- sys/miscfs/union/union_vnops.c 2001/01/22 12:17:40 1.50 +++ sys/miscfs/union/union_vnops.c 2001/03/05 22:49:52 1.50.2.1 @@ -1758,10 +1758,10 @@ /* XXX ignores LK_NOWAIT */ if (un->un_flags & UN_LOCKED) { #ifdef DIAGNOSTIC - if (curproc && un->un_pid == curproc->p_pid && - un->un_pid > -1 && curproc->p_pid > -1) + if (curproc && un->un_pid == curproc->l_proc->p_pid && + un->un_pid > -1 && curproc->l_proc->p_pid > -1) panic("union: locking against myself"); #endif un->un_flags |= UN_WANTED; tsleep((caddr_t)&un->un_flags, PINOD, "unionlk2", 0); @@ -1769,9 +1769,9 @@ } #ifdef DIAGNOSTIC if (curproc) - un->un_pid = curproc->p_pid; + un->un_pid = curproc->l_proc->p_pid; else un->un_pid = -1; if (drain) un->un_flags |= UN_DRAINING; @@ -1804,10 +1804,10 @@ #ifdef DIAGNOSTIC if ((un->un_flags & UN_LOCKED) == 0) panic("union: unlock unlocked node"); - if (curproc && un->un_pid != curproc->p_pid && - curproc->p_pid > -1 && un->un_pid > -1) + if (curproc && un->un_pid != curproc->l_proc->p_pid && + curproc->l_proc->p_pid > -1 && un->un_pid > -1) panic("union: unlocking other process's union node"); if (un->un_flags & UN_DRAINED) panic("union: %p: warning: unlocking decommissioned lock\n", ap->a_vp); #endif Index: sys/msdosfs/msdosfs_vfsops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/msdosfs/msdosfs_vfsops.c,v retrieving revision 1.73 retrieving revision 1.73.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.73 -r1.73.2.1 --- sys/msdosfs/msdosfs_vfsops.c 2001/01/22 12:17:36 1.73 +++ sys/msdosfs/msdosfs_vfsops.c 2001/03/05 22:49:53 1.73.2.1 @@ -172,9 +172,9 @@ int msdosfs_mountroot() { struct mount *mp; - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ int error; struct msdosfs_args args; if (root_device->dv_class != DV_DISK) Index: sys/net/if.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/net/if.c,v retrieving revision 1.86 retrieving revision 1.86.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.86 -r1.86.2.1 --- sys/net/if.c 2001/03/03 03:29:20 1.86 +++ sys/net/if.c 2001/03/05 22:49:53 1.86.2.1 @@ -110,8 +110,9 @@ #include #include #include #include +#include #include #include #include #include @@ -516,9 +517,10 @@ so.so_proto = pr; if (pr->pr_usrreq != NULL) { (void) (*pr->pr_usrreq)(&so, PRU_PURGEIF, NULL, NULL, - (struct mbuf *) ifp, curproc); + (struct mbuf *) ifp, + curproc->l_proc); purged = 1; } } if (purged == 0) { Index: sys/net/if_gif.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/net/if_gif.c,v retrieving revision 1.26 retrieving revision 1.26.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.26 -r1.26.2.1 --- sys/net/if_gif.c 2001/02/21 00:17:09 1.26 +++ sys/net/if_gif.c 2001/03/05 22:49:54 1.26.2.1 @@ -42,8 +42,9 @@ #include #include #include #include +#include #include #include #include @@ -475,9 +476,9 @@ struct ifnet *ifp; u_long cmd; caddr_t data; { - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ struct gif_softc *sc = (struct gif_softc*)ifp; struct ifreq *ifr = (struct ifreq*)data; int error = 0, size; struct sockaddr *dst, *src; Index: sys/net/if_gre.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/net/if_gre.c,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.17 -r1.17.2.1 --- sys/net/if_gre.c 2001/02/20 07:58:17 1.17 +++ sys/net/if_gre.c 2001/03/05 22:49:54 1.17.2.1 @@ -54,8 +54,9 @@ #include #include #include +#include #include #include #include #include @@ -346,9 +347,9 @@ int gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; struct in_ifaddr *ia = (struct in_ifaddr *)data; struct gre_softc *sc = ifp->if_softc; Index: sys/net/if_ppp.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/net/if_ppp.c,v retrieving revision 1.67 retrieving revision 1.67.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.67 -r1.67.2.1 --- sys/net/if_ppp.c 2001/01/17 00:30:51 1.67 +++ sys/net/if_ppp.c 2001/03/05 22:49:54 1.67.2.1 @@ -88,8 +88,9 @@ #endif #define PPP_COMPRESS #include +#include #include #include #include #include @@ -607,9 +608,9 @@ struct ifnet *ifp; u_long cmd; caddr_t data; { - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ struct ppp_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; struct ppp_stats *psp; Index: sys/net/if_sl.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/net/if_sl.c,v retrieving revision 1.73 retrieving revision 1.72.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.73 -r1.72.2.2 --- sys/net/if_sl.c 2001/03/31 00:35:23 1.73 +++ sys/net/if_sl.c 2001/04/09 01:58:12 1.72.2.2 @@ -69,8 +69,9 @@ #include "opt_inet.h" #include "bpfilter.h" #include +#include #include #include #include #include @@ -252,9 +253,9 @@ slopen(dev, tp) dev_t dev; struct tty *tp; { - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ struct sl_softc *sc; int nsl; int error; int s; Index: sys/net/if_strip.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/net/if_strip.c,v retrieving revision 1.36 retrieving revision 1.35.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.36 -r1.35.2.2 --- sys/net/if_strip.c 2001/03/31 00:35:23 1.36 +++ sys/net/if_strip.c 2001/04/09 01:58:15 1.35.2.2 @@ -96,8 +96,9 @@ #include "opt_inet.h" #include "bpfilter.h" #include +#include #include #include #include #include @@ -433,9 +434,9 @@ stripopen(dev, tp) dev_t dev; struct tty *tp; { - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ struct strip_softc *sc; int nstrip; int error; #ifdef __NetBSD__ Index: sys/net/if_vlan.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/net/if_vlan.c,v retrieving revision 1.31 retrieving revision 1.30.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.31 -r1.30.2.2 --- sys/net/if_vlan.c 2001/04/07 18:41:42 1.31 +++ sys/net/if_vlan.c 2001/04/09 01:58:16 1.30.2.2 @@ -93,8 +93,9 @@ #include #include #include #include +#include #include #if NBPFILTER > 0 #include @@ -441,9 +442,9 @@ static int vlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ struct ifvlan *ifv = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *) data; struct ifreq *ifr = (struct ifreq *) data; struct ifnet *pr; Index: sys/net/ppp_tty.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/net/ppp_tty.c,v retrieving revision 1.24 retrieving revision 1.23.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.24 -r1.23.2.2 --- sys/net/ppp_tty.c 2001/03/31 00:35:24 1.24 +++ sys/net/ppp_tty.c 2001/04/09 01:58:17 1.23.2.2 @@ -174,9 +174,9 @@ pppopen(dev, tp) dev_t dev; struct tty *tp; { - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ struct ppp_softc *sc; int error, s; if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) Index: sys/net/rtsock.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/net/rtsock.c,v retrieving revision 1.45 retrieving revision 1.45.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.45 -r1.45.2.1 --- sys/net/rtsock.c 2001/01/17 04:05:42 1.45 +++ sys/net/rtsock.c 2001/03/05 22:49:55 1.45.2.1 @@ -67,8 +67,9 @@ #include "opt_inet.h" #include #include +#include #include #include #include #include @@ -243,9 +244,9 @@ if (rtm->rtm_version != RTM_VERSION) { dst = 0; senderr(EPROTONOSUPPORT); } - rtm->rtm_pid = curproc->p_pid; + rtm->rtm_pid = curproc->l_proc->p_pid; bzero(&info, sizeof(info)); info.rti_addrs = rtm->rtm_addrs; if (rt_xaddrs((caddr_t)(rtm + 1), len + (caddr_t)rtm, &info)) senderr(EINVAL); @@ -267,9 +268,9 @@ * Verify that the caller has the appropriate privilege; RTM_GET * is the only operation the non-superuser is allowed. */ if (rtm->rtm_type != RTM_GET && - suser(curproc->p_ucred, &curproc->p_acflag) != 0) + suser(curproc->l_proc->p_ucred, &curproc->l_proc->p_acflag) != 0) senderr(EACCES); switch (rtm->rtm_type) { Index: sys/netccitt/pk_acct.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/netccitt/pk_acct.c,v retrieving revision 1.13 retrieving revision 1.13.6.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.13 -r1.13.6.2 --- sys/netccitt/pk_acct.c 2000/03/30 13:53:35 1.13 +++ sys/netccitt/pk_acct.c 2001/03/13 20:29:48 1.13.6.2 @@ -69,9 +69,9 @@ { struct vnode *vp = NULL; struct nameidata nd; struct vnode *oacctp = pkacctp; - struct proc *p = curproc; /* XXX */ + struct proc *p = (curproc ? curproc->l_proc : 0); /* XXX */ int error; if (path == 0) goto close; @@ -120,9 +120,9 @@ if (sa -> x25_opts.op_flags & X25_REVERSE_CHARGE) acbuf.x25acct_revcharge = 1; acbuf.x25acct_stime = lcp -> lcd_stime; acbuf.x25acct_etime = time.tv_sec - acbuf.x25acct_stime; - acbuf.x25acct_uid = curproc -> p_cred -> p_ruid; + acbuf.x25acct_uid = curproc -> l_proc -> p_cred -> p_ruid; acbuf.x25acct_psize = sa -> x25_opts.op_psize; acbuf.x25acct_net = sa -> x25_net; /* * Convert address to bcd @@ -142,7 +142,7 @@ acbuf.x25acct_rxcnt = lcp -> lcd_rxcnt; (void) vn_rdwr(UIO_WRITE, vp, (caddr_t)&acbuf, sizeof (acbuf), (off_t)0, UIO_SYSSPACE, IO_UNIT|IO_APPEND, - curproc -> p_ucred, (size_t *)0, + curproc -> l_proc -> p_ucred, (size_t *)0, (struct proc *)0); } Index: sys/netccitt/pk_usrreq.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/netccitt/pk_usrreq.c,v retrieving revision 1.19 retrieving revision 1.19.6.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.19 -r1.19.6.2 --- sys/netccitt/pk_usrreq.c 2000/03/30 13:53:37 1.19 +++ sys/netccitt/pk_usrreq.c 2001/03/13 20:29:48 1.19.6.2 @@ -51,8 +51,9 @@ #include #include #include #include +#include #include #include #include @@ -435,9 +436,9 @@ struct socket *so; struct mbuf **mp; int cmd, level, optname; { - struct proc *p = curproc; /* XXX */ + struct proc *p = (curproc ? curproc->l_proc : 0); /* XXX */ struct mbuf *m = *mp; struct pklcd *lcp = (struct pklcd *) so->so_pcb; int error = EOPNOTSUPP; Index: sys/netinet/ip_output.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/netinet/ip_output.c,v retrieving revision 1.83 retrieving revision 1.83.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.83 -r1.83.2.2 --- sys/netinet/ip_output.c 2001/02/27 10:32:03 1.83 +++ sys/netinet/ip_output.c 2001/03/13 20:29:49 1.83.2.2 @@ -112,8 +112,9 @@ #include #include #include #include +#include #include #include #include @@ -856,9 +857,9 @@ int optval = 0; int error = 0; #ifdef IPSEC #ifdef __NetBSD__ - struct proc *p = curproc; /*XXX*/ + struct proc *p = (curproc ? curproc->l_proc : 0); /*XXX*/ #endif #endif if (level != IPPROTO_IP) { Index: sys/netinet6/in6_prefix.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/netinet6/in6_prefix.c,v retrieving revision 1.15 retrieving revision 1.14.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.15 -r1.14.2.2 --- sys/netinet6/in6_prefix.c 2001/03/25 09:06:03 1.15 +++ sys/netinet6/in6_prefix.c 2001/04/09 01:58:37 1.14.2.2 @@ -73,8 +73,9 @@ #include #include #include #include +#include #include #include @@ -632,9 +633,9 @@ /* propagate ANYCAST flag if it is set for ancestor addr */ if (rap->ra_flags.anycast != 0) ifra.ifra_flags |= IN6_IFF_ANYCAST; error = in6_control(so, SIOCAIFADDR_IN6, (caddr_t)&ifra, rpp->rp_ifp - , curproc); + , curproc->l_proc); if (error != 0) log(LOG_ERR, "in6_prefix.c: add_each_addr: addition of an addr" "%s/%d failed because in6_control failed for error %d\n", ip6_sprintf(&ifra.ifra_addr.sin6_addr), rpp->rp_plen, Index: sys/netinet6/in6_src.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/netinet6/in6_src.c,v retrieving revision 1.6 retrieving revision 1.5.2.3 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.6 -r1.5.2.3 --- sys/netinet6/in6_src.c 2001/03/30 11:08:57 1.6 +++ sys/netinet6/in6_src.c 2001/04/09 01:58:38 1.5.2.3 @@ -76,8 +76,9 @@ #include #include #include #include +#include #include #include #include @@ -338,9 +339,9 @@ u_int16_t last_port, lport = 0; int wild = 0; void *t; u_int16_t min, max; - struct proc *p = curproc; /* XXX */ + struct proc *p = (curproc ? curproc->l_proc : 0); /* XXX */ /* XXX: this is redundant when called from in6_pcbbind */ if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0 && ((so->so_proto->pr_flags & PR_CONNREQUIRED) == 0 || Index: sys/netinet6/ip6_input.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/netinet6/ip6_input.c,v retrieving revision 1.40 retrieving revision 1.37.2.3 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.40 -r1.37.2.3 --- sys/netinet6/ip6_input.c 2001/03/30 11:08:57 1.40 +++ sys/netinet6/ip6_input.c 2001/04/09 01:58:39 1.37.2.3 @@ -80,8 +80,9 @@ #include #include #include #include +#include #include #include #include @@ -1007,9 +1008,9 @@ struct mbuf **mp; struct ip6_hdr *ip6; struct mbuf *m; { - struct proc *p = curproc; /* XXX */ + struct proc *p = (curproc ? curproc->l_proc : 0); /* XXX */ int privileged; privileged = 0; if (p && !suser(p->p_ucred, &p->p_acflag)) Index: sys/netinet6/ip6_output.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/netinet6/ip6_output.c,v retrieving revision 1.34 retrieving revision 1.31.2.3 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.34 -r1.31.2.3 --- sys/netinet6/ip6_output.c 2001/03/30 11:08:57 1.34 +++ sys/netinet6/ip6_output.c 2001/04/09 01:58:41 1.31.2.3 @@ -76,8 +76,9 @@ #include #include #include #include +#include #include #include #include @@ -1233,9 +1234,9 @@ struct in6pcb *in6p = sotoin6pcb(so); struct mbuf *m = *mp; int optval = 0; int error = 0; - struct proc *p = curproc; /* XXX */ + struct proc *p = (curproc ? curproc->l_proc : 0); /* XXX */ if (level == IPPROTO_IPV6) { switch (op) { @@ -1567,9 +1568,9 @@ struct socket *so; { struct ip6_pktopts *opt = *pktopt; int error = 0; - struct proc *p = curproc; /* XXX */ + struct proc *p = (curproc ? curproc->l_proc : 0); /* XXX */ int priv = 0; /* turn off any old options. */ if (opt) { @@ -1617,9 +1618,9 @@ struct ip6_moptions *im6o = *im6op; struct route_in6 ro; struct sockaddr_in6 *dst; struct in6_multi_mship *imm; - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ if (im6o == NULL) { /* * No multicast option buffer attached to the pcb; Index: sys/netinet6/raw_ip6.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/netinet6/raw_ip6.c,v retrieving revision 1.31 retrieving revision 1.31.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.31 -r1.31.2.2 --- sys/netinet6/raw_ip6.c 2001/03/04 16:49:17 1.31 +++ sys/netinet6/raw_ip6.c 2001/03/13 20:29:51 1.31.2.2 @@ -74,8 +74,9 @@ #include #include #include #include +#include #include #include #include @@ -389,9 +390,9 @@ in6p = sotoin6pcb(so); priv = 0; { - struct proc *p = curproc; /* XXX */ + struct proc *p = (curproc ? curproc->l_proc : 0); /* XXX */ if (p && !suser(p->p_ucred, &p->p_acflag)) priv = 1; } Index: sys/netiso/tp_output.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/netiso/tp_output.c,v retrieving revision 1.19 retrieving revision 1.19.6.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.19 -r1.19.6.2 --- sys/netiso/tp_output.c 2000/03/30 13:10:14 1.19 +++ sys/netiso/tp_output.c 2001/03/13 20:29:51 1.19.6.2 @@ -76,8 +76,9 @@ #include #include #include #include +#include #include #include #include @@ -393,9 +394,9 @@ int cmd, level, optname; struct socket *so; struct mbuf **mp; { - struct proc *p = curproc; /* XXX */ + struct proc *p = (curproc ? curproc->l_proc : 0); /* XXX */ struct tp_pcb *tpcb = sototpcb(so); int s = splsoftnet(); caddr_t value; unsigned val_len; Index: sys/nfs/nfs_bio.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/nfs/nfs_bio.c,v retrieving revision 1.65 retrieving revision 1.63.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.65 -r1.63.2.2 --- sys/nfs/nfs_bio.c 2001/04/03 15:07:23 1.65 +++ sys/nfs/nfs_bio.c 2001/04/09 01:58:56 1.63.2.2 @@ -44,8 +44,9 @@ #include #include #include #include +#include #include #include #include #include @@ -517,9 +518,10 @@ #ifdef DIAGNOSTIC if (uio->uio_rw != UIO_WRITE) panic("nfs_write mode"); - if (uio->uio_segflg == UIO_USERSPACE && uio->uio_procp != curproc) + if (uio->uio_segflg == UIO_USERSPACE && + uio->uio_procp != curproc->l_proc) panic("nfs_write proc"); #endif if (vp->v_type != VREG) return (EIO); @@ -906,26 +908,28 @@ np->n_mtime != np->n_vattr->va_mtime.tv_sec))) { uprintf("Process killed due to " "text file modification\n"); psignal(p, SIGKILL); +#if 0 /* XXX NJWLWP */ p->p_holdcnt++; +#endif } break; case VLNK: uiop->uio_offset = (off_t)0; nfsstats.readlink_bios++; - error = nfs_readlinkrpc(vp, uiop, curproc->p_ucred); + error = nfs_readlinkrpc(vp, uiop, curproc->l_proc->p_ucred); break; case VDIR: nfsstats.readdir_bios++; uiop->uio_offset = bp->b_dcookie; if (nmp->nm_flag & NFSMNT_RDIRPLUS) { - error = nfs_readdirplusrpc(vp, uiop, curproc->p_ucred); + error = nfs_readdirplusrpc(vp, uiop, curproc->l_proc->p_ucred); if (error == NFSERR_NOTSUPP) nmp->nm_flag &= ~NFSMNT_RDIRPLUS; } if ((nmp->nm_flag & NFSMNT_RDIRPLUS) == 0) - error = nfs_readdirrpc(vp, uiop, curproc->p_ucred); + error = nfs_readdirrpc(vp, uiop, curproc->l_proc->p_ucred); if (!error) { bp->b_dcookie = uiop->uio_offset; } break; @@ -1125,9 +1129,9 @@ if (np->n_rcred) { crfree(np->n_rcred); } - np->n_rcred = curproc->p_ucred; + np->n_rcred = curproc->l_proc->p_ucred; crhold(np->n_rcred); /* * read the desired page(s). @@ -1530,9 +1534,9 @@ } else { commitoff = origoffset; commitbytes = npages << PAGE_SHIFT; commit: - error = nfs_commit(vp, commitoff, commitbytes, curproc); + error = nfs_commit(vp, commitoff, commitbytes, curproc->l_proc); nfs_del_tobecommitted_range(vp, commitoff, commitbytes); committed: for (i = 0; i < npages; i++) { pgs[i]->flags &= ~(PG_NEEDCOMMIT|PG_RDONLY); Index: sys/nfs/nfs_boot.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/nfs/nfs_boot.c,v retrieving revision 1.56 retrieving revision 1.56.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.56 -r1.56.2.1 --- sys/nfs/nfs_boot.c 2001/01/19 14:26:01 1.56 +++ sys/nfs/nfs_boot.c 2001/03/05 22:49:59 1.56.2.1 @@ -49,8 +49,9 @@ #include #include #include #include +#include #include #include #include #include @@ -361,9 +362,9 @@ sin->sin_len = m->m_len = sizeof(*sin); sin->sin_family = AF_INET; sin->sin_addr.s_addr = INADDR_ANY; sin->sin_port = htons(port); - error = sobind(so, m, curproc); + error = sobind(so, m, curproc->l_proc); m_freem(m); return (error); } Index: sys/nfs/nfs_node.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/nfs/nfs_node.c,v retrieving revision 1.41 retrieving revision 1.41.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.41 -r1.41.2.1 --- sys/nfs/nfs_node.c 2001/02/07 12:40:44 1.41 +++ sys/nfs/nfs_node.c 2001/03/05 22:49:59 1.41.2.1 @@ -42,8 +42,9 @@ #include #include #include +#include #include #include #include #include @@ -183,9 +184,10 @@ /* * XXXUBC doing this while holding the nfs_hashlock is bad, * but there's no alternative at the moment. */ - error = VOP_GETATTR(vp, np->n_vattr, curproc->p_ucred, curproc); + error = VOP_GETATTR(vp, np->n_vattr, curproc->l_proc->p_ucred, + curproc->l_proc); if (error) { return error; } uvm_vnp_setsize(vp, np->n_vattr->va_size); Index: sys/nfs/nfs_nqlease.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/nfs/nfs_nqlease.c,v retrieving revision 1.37 retrieving revision 1.37.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.37 -r1.37.2.1 --- sys/nfs/nfs_nqlease.c 2001/02/21 21:39:57 1.37 +++ sys/nfs/nfs_nqlease.c 2001/03/05 22:49:59 1.37.2.1 @@ -61,8 +61,9 @@ #include #include #include #include +#include #include #include #include #include @@ -994,16 +995,17 @@ * "sleep" since nfs_reclaim() called from vclean() can pull a node off * the list asynchronously. */ int -nqnfs_clientd(nmp, cred, ncd, flag, argp, p) +nqnfs_clientd(nmp, cred, ncd, flag, argp, l) struct nfsmount *nmp; struct ucred *cred; struct nfsd_cargs *ncd; int flag; caddr_t argp; - struct proc *p; + struct lwp *l; { + struct proc *p = l->l_proc; #ifndef NFS_V2_ONLY struct nfsnode *np; struct vnode *vp; struct nfsreq myrep; @@ -1050,9 +1052,9 @@ while ((nmp->nm_iflag & NFSMNT_DISMNT) == 0) { if (sleepreturn == EINTR || sleepreturn == ERESTART) { if (vfs_busy(nmp->nm_mountp, LK_NOWAIT, 0) == 0 && dounmount(nmp->nm_mountp, 0, p) != 0) - CLRSIG(p, CURSIG(p)); + CLRSIG(p, CURSIG(l)); sleepreturn = 0; continue; } #ifndef NFS_V2_ONLY Index: sys/nfs/nfs_socket.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/nfs/nfs_socket.c,v retrieving revision 1.66 retrieving revision 1.66.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.66 -r1.66.2.1 --- sys/nfs/nfs_socket.c 2001/02/21 21:39:57 1.66 +++ sys/nfs/nfs_socket.c 2001/03/05 22:49:59 1.66.2.1 @@ -49,8 +49,9 @@ #include #include #include +#include #include #include #include #include @@ -500,9 +501,9 @@ struct mbuf *control; u_int32_t len; struct mbuf **getnam; int error, sotype, rcvflg; - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ /* * Set up arguments for soreceive() */ Index: sys/nfs/nfs_syscalls.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/nfs/nfs_syscalls.c,v retrieving revision 1.48 retrieving revision 1.48.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.48 -r1.48.2.1 --- sys/nfs/nfs_syscalls.c 2000/11/27 08:39:50 1.48 +++ sys/nfs/nfs_syscalls.c 2001/03/05 22:50:00 1.48.2.1 @@ -51,8 +51,9 @@ #include #include #include #include +#include #include #include #include #include @@ -136,17 +137,18 @@ * - remains in the kernel as an nfsd * - remains in the kernel as an nfsiod */ int -sys_nfssvc(p, v, retval) - struct proc *p; +sys_nfssvc(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_nfssvc_args /* { syscallarg(int) flag; syscallarg(caddr_t) argp; } */ *uap = v; + struct proc *p = l->l_proc; int error; #ifdef NFS struct nameidata nd; struct nfsmount *nmp; @@ -173,9 +175,9 @@ (void) tsleep((caddr_t)&nfssvc_sockhead, PSOCK, "nfsd init", 0); } if (SCARG(uap, flag) & NFSSVC_BIOD) { #if defined(NFS) && defined(COMPAT_14) - error = nfssvc_iod(p); + error = nfssvc_iod(l); #else error = ENOSYS; #endif } else if (SCARG(uap, flag) & NFSSVC_MNTD) { @@ -200,9 +202,9 @@ (SCARG(uap, flag) & NFSSVC_GOTAUTH) == 0) return (0); nmp->nm_iflag |= NFSMNT_MNTD; error = nqnfs_clientd(nmp, p->p_ucred, &ncd, SCARG(uap, flag), - SCARG(uap, argp), p); + SCARG(uap, argp), l); #endif /* NFS */ } else if (SCARG(uap, flag) & NFSSVC_ADDSOCK) { #ifndef NFSSERVER error = ENOSYS; @@ -325,9 +327,9 @@ } if ((SCARG(uap, flag) & NFSSVC_AUTHINFAIL) && (nfsd = nsd->nsd_nfsd)) nfsd->nfsd_flag |= NFSD_AUTHFAIL; - error = nfssvc_nfsd(nsd, SCARG(uap, argp), p); + error = nfssvc_nfsd(nsd, SCARG(uap, argp), l); #endif /* !NFSSERVER */ } if (error == EINTR || error == ERESTART) error = 0; @@ -438,12 +440,12 @@ * Called by nfssvc() for nfsds. Just loops around servicing rpc requests * until it is killed by a signal. */ int -nfssvc_nfsd(nsd, argp, p) +nfssvc_nfsd(nsd, argp, l) struct nfsd_srvargs *nsd; caddr_t argp; - struct proc *p; + struct lwp *l; { struct mbuf *m; int siz; struct nfssvc_sock *slp; @@ -453,8 +455,9 @@ struct nfsrv_descript *nd = NULL; struct mbuf *mreq; int error = 0, cacherep, s, sotype, writes_todo; u_quad_t cur_usec; + struct proc *p = l->l_proc; #ifndef nolint cacherep = RC_DOIT; writes_todo = 0; @@ -467,9 +470,9 @@ nfsd->nfsd_procp = p; TAILQ_INSERT_TAIL(&nfsd_head, nfsd, nfsd_chain); nfs_numnfsd++; } - p->p_holdcnt++; + PHOLD(l); /* * Loop getting rpc requests until SIGKILL. */ for (;;) { @@ -565,9 +568,9 @@ nfsd->nfsd_authlen) && !copyout(nfsd->nfsd_verfstr, nsd->nsd_verfstr, nfsd->nfsd_verflen) && !copyout((caddr_t)nsd, argp, sizeof (*nsd))) { - p->p_holdcnt--; + PRELE(l); return (ENEEDAUTH); } cacherep = RC_DROPIT; } else @@ -743,9 +746,9 @@ nfsrv_slpderef(slp); } } done: - p->p_holdcnt--; + PRELE(l); TAILQ_REMOVE(&nfsd_head, nfsd, nfsd_chain); splx(s); free((caddr_t)nfsd, M_NFSD); nsd->nsd_nfsd = (struct nfsd *)0; @@ -925,15 +928,16 @@ * Never returns unless it fails or gets killed. */ int -nfssvc_iod(p) - struct proc *p; +nfssvc_iod(l) + struct lwp *l; { struct buf *bp; int i, myiod; struct nfsmount *nmp; int error = 0; + struct proc *p = l->l_proc; /* * Assign my position or return error if too many already running */ @@ -946,9 +950,9 @@ if (myiod == -1) return (EBUSY); nfs_asyncdaemon[myiod] = p; nfs_numasync++; - p->p_holdcnt++; + PHOLD(l); /* * Just loop around doing our stuff until SIGKILL */ for (;;) { @@ -984,9 +988,9 @@ if (error) { break; } } - p->p_holdcnt--; + PRELE(l); if (nmp) nmp->nm_bufqiods--; nfs_iodwant[myiod] = NULL; nfs_iodmount[myiod] = NULL; Index: sys/nfs/nfs_var.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/nfs/nfs_var.h,v retrieving revision 1.19 retrieving revision 1.19.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.19 -r1.19.2.1 --- sys/nfs/nfs_var.h 2000/11/27 08:39:50 1.19 +++ sys/nfs/nfs_var.h 2001/03/05 22:50:00 1.19.2.1 @@ -278,16 +278,16 @@ void nfs_cookieheuristic __P((struct vnode *, int *, struct proc *, struct ucred *)); /* nfs_syscalls.c */ -int sys_getfh __P((struct proc *, void *, register_t *)); -int sys_nfssvc __P((struct proc *, void *, register_t *)); +int sys_getfh __P((struct lwp *, void *, register_t *)); +int sys_nfssvc __P((struct lwp *, void *, register_t *)); int nfssvc_addsock __P((struct file *, struct mbuf *)); -int nfssvc_nfsd __P((struct nfsd_srvargs *, caddr_t, struct proc *)); +int nfssvc_nfsd __P((struct nfsd_srvargs *, caddr_t, struct lwp *)); void nfsrv_zapsock __P((struct nfssvc_sock *)); void nfsrv_slpderef __P((struct nfssvc_sock *)); void nfsrv_init __P((int)); -int nfssvc_iod __P((struct proc *)); +int nfssvc_iod __P((struct lwp *)); void start_nfsio __P((void *)); void nfs_getset_niothreads __P((int)); int nfs_getauth __P((struct nfsmount *, struct nfsreq *, struct ucred *, char **, int *, char *, int *, NFSKERBKEY_T)); Index: sys/nfs/nfs_vfsops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/nfs/nfs_vfsops.c,v retrieving revision 1.101 retrieving revision 1.101.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.101 -r1.101.2.1 --- sys/nfs/nfs_vfsops.c 2001/02/12 20:02:30 1.101 +++ sys/nfs/nfs_vfsops.c 2001/03/05 22:50:00 1.101.2.1 @@ -45,8 +45,9 @@ #include #include #include +#include #include #include #include #include @@ -290,9 +291,9 @@ struct proc *procp; long n; int error; - procp = curproc; /* XXX */ + procp = curproc->l_proc; /* XXX */ if (root_device->dv_class != DV_IFNET) return (ENODEV); Index: sys/nfs/nfs_vnops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/nfs/nfs_vnops.c,v retrieving revision 1.130 retrieving revision 1.130.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.130 -r1.130.2.1 --- sys/nfs/nfs_vnops.c 2001/02/11 01:09:04 1.130 +++ sys/nfs/nfs_vnops.c 2001/03/05 22:50:00 1.130.2.1 @@ -45,8 +45,9 @@ #include "opt_nfs.h" #include "opt_uvmhist.h" #include +#include #include #include #include #include @@ -2790,9 +2791,9 @@ panic("nfs physio/async"); if (bp->b_flags & B_ASYNC) p = NULL; else - p = curproc; /* XXX */ + p = curproc->l_proc; /* XXX */ /* * If the op is asynchronous and an i/o daemon is waiting * queue the request, wake it up and wait for completion @@ -2929,9 +2930,9 @@ nfsstats.rpccnt[NFSPROC_PATHCONF]++; nfsm_reqhead(vp, NFSPROC_PATHCONF, NFSX_FH(1)); nfsm_fhtom(vp, 1); nfsm_request(vp, NFSPROC_PATHCONF, - curproc, curproc->p_ucred); /* XXX */ + curproc->l_proc, curproc->l_proc->p_ucred); /* XXX */ nfsm_postop_attr(vp, attrflag); if (!error) { nfsm_dissect(pcp, struct nfsv3_pathconf *, NFSX_V3PATHCONF); @@ -2960,9 +2961,10 @@ if (v3) { nmp = VFSTONFS(vp->v_mount); if ((nmp->nm_iflag & NFSMNT_GOTFSINFO) == 0) if ((error = nfs_fsinfo(nmp, vp, - curproc->p_ucred, curproc)) != 0) /* XXX */ + curproc->l_proc->p_ucred, + curproc->l_proc)) != 0) /* XXX */ break; for (l = 0, maxsize = nmp->nm_maxfilesize; (maxsize >> l) > 0; l++) ; Index: sys/nfs/nqnfs.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/nfs/nqnfs.h,v retrieving revision 1.7 retrieving revision 1.7.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.7 -r1.7.4.1 --- sys/nfs/nqnfs.h 2000/06/09 00:00:18 1.7 +++ sys/nfs/nqnfs.h 2001/03/05 22:50:01 1.7.4.1 @@ -209,8 +209,8 @@ int nqnfs_getlease __P((struct vnode *, int, struct ucred *,struct proc *)); int nqnfs_callback __P((struct nfsmount *, struct mbuf *, struct mbuf *, caddr_t)); int nqnfs_clientd __P((struct nfsmount *, struct ucred *, - struct nfsd_cargs *, int, caddr_t, struct proc *)); + struct nfsd_cargs *, int, caddr_t, struct lwp *)); #endif #endif Index: sys/ntfs/ntfs_subr.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ntfs/ntfs_subr.c,v retrieving revision 1.27 retrieving revision 1.26.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.27 -r1.26.2.2 --- sys/ntfs/ntfs_subr.c 2001/03/29 10:51:16 1.27 +++ sys/ntfs/ntfs_subr.c 2001/04/09 01:58:59 1.26.2.2 @@ -31,8 +31,9 @@ #include #include #include #include +#include #include #include #include #include @@ -240,9 +241,9 @@ /* this is not a main record, so we can't use just plain vget() */ error = ntfs_vgetex(ntmp->ntm_mountp, aalp->al_inumber, NTFS_A_DATA, NULL, LK_EXCLUSIVE, - VG_EXT, curproc, &newvp); + VG_EXT, curproc->l_proc, &newvp); if (error) { printf("ntfs_ntvattrget: CAN'T VGET INO: %d\n", aalp->al_inumber); goto out; @@ -1007,9 +1008,9 @@ /* vget node, but don't load it */ error = ntfs_vgetex(ntmp->ntm_mountp, iep->ie_number, attrtype, attrname, LK_EXCLUSIVE, VG_DONTLOADIN | VG_DONTVALIDFN, - curproc, &nvp); + curproc->l_proc, &nvp); if (error) goto fail; nfp = VTOF(nvp); Index: sys/ntfs/ntfs_vfsops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ntfs/ntfs_vfsops.c,v retrieving revision 1.34 retrieving revision 1.33.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.34 -r1.33.2.2 --- sys/ntfs/ntfs_vfsops.c 2001/03/29 10:47:44 1.34 +++ sys/ntfs/ntfs_vfsops.c 2001/04/09 01:58:59 1.33.2.2 @@ -31,8 +31,9 @@ #include #include #include +#include #include #include #include #include @@ -153,9 +154,9 @@ static int ntfs_mountroot() { struct mount *mp; - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ int error; struct ntfs_args args; if (root_device->dv_class != DV_DISK) @@ -847,9 +848,10 @@ ddprintf(("ntfs_fhtovp(): %s: %d\n", mp->mnt_stat.f_mntonname, ntfhp->ntfid_ino)); error = ntfs_vgetex(mp, ntfhp->ntfid_ino, ntfhp->ntfid_attr, NULL, - LK_EXCLUSIVE | LK_RETRY, 0, curproc, vpp); /* XXX */ + LK_EXCLUSIVE | LK_RETRY, 0, curproc->l_proc, + vpp); /* XXX */ if (error != 0) { *vpp = NULLVP; return (error); } @@ -1001,9 +1003,10 @@ ino_t ino, struct vnode **vpp) { return ntfs_vgetex(mp, ino, NTFS_A_DATA, NULL, - LK_EXCLUSIVE | LK_RETRY, 0, curproc, vpp); /* XXX */ + LK_EXCLUSIVE | LK_RETRY, 0, curproc->l_proc, + vpp); /* XXX */ } #if defined(__FreeBSD__) static struct vfsops ntfs_vfsops = { Index: sys/sys/Makefile =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/sys/Makefile,v retrieving revision 1.25 retrieving revision 1.25.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.25 -r1.25.2.1 --- sys/sys/Makefile 2000/12/11 21:05:14 1.25 +++ sys/sys/Makefile 2001/03/05 22:50:02 1.25.2.1 @@ -11,18 +11,20 @@ exec_coff.h exec_ecoff.h exec_elf.h exec_script.h extent.h fcntl.h \ fdio.h \ featuretest.h file.h filedesc.h filio.h gmon.h inttypes.h ioccom.h \ ioctl.h ioctl_compat.h ipc.h kcore.h kernel.h kgdb.h ktrace.h lkm.h \ - localedef.h lock.h lockf.h malloc.h map.h mbuf.h md4.h md5.h midiio.h \ + localedef.h lock.h lockf.h lwp.h malloc.h map.h mbuf.h md4.h md5.h \ + midiio.h \ mman.h mount.h msg.h msgbuf.h mtio.h namei.h null.h param.h poll.h \ pool.h proc.h protosw.h ptrace.h queue.h reboot.h resource.h \ - resourcevar.h rnd.h scanio.h sched.h scsiio.h select.h sem.h sha1.h \ + resourcevar.h rnd.h sa.h scanio.h sched.h scsiio.h select.h \ + sem.h sha1.h \ shm.h signal.h signalvar.h socket.h socketvar.h sockio.h stat.h \ syscall.h syscallargs.h sysctl.h swap.h syslimits.h syslog.h systm.h \ tablet.h termios.h time.h timeb.h timepps.h times.h timex.h \ tprintf.h trace.h tty.h ttychars.h ttycom.h ttydefaults.h ttydev.h \ - types.h ucred.h uio.h un.h unistd.h unpcb.h user.h utsname.h \ - vadvise.h vmmeter.h vnode.h vnode_if.h wait.h wdog.h + types.h ucontext.h ucred.h uio.h un.h unistd.h unpcb.h user.h \ + utsname.h vadvise.h vmmeter.h vnode.h vnode_if.h wait.h wdog.h SYMLINKS= sys/exec_elf.h /usr/include/elf.h \ sys/fcntl.h /usr/include/fcntl.h \ sys/inttypes.h /usr/include/inttypes.h \ Index: sys/sys/exec.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/sys/exec.h,v retrieving revision 1.78 retrieving revision 1.78.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.78 -r1.78.2.1 --- sys/sys/exec.h 2001/02/14 18:21:42 1.78 +++ sys/sys/exec.h 2001/03/05 22:50:02 1.78.2.1 @@ -98,8 +98,9 @@ * the exec_vmcmd struct defines a command description to be used * in creating the new process's vmspace. */ +struct lwp; struct proc; struct exec_package; typedef int (*exec_makecmds_fcn) __P((struct proc *, struct exec_package *)); @@ -119,9 +120,9 @@ /* Copy arguments on the new stack */ void *(*es_copyargs) __P((struct exec_package *, struct ps_strings *, void *, void *)); /* Set registers before execution */ - void (*es_setregs) __P((struct proc *, struct exec_package *, + void (*es_setregs) __P((struct lwp *, struct exec_package *, u_long)); }; #define EXECSW_PRIO_ANY 0x000 /* default, no preference */ @@ -199,9 +200,9 @@ int vmcmd_readvn __P((struct proc *, struct exec_vmcmd *)); int vmcmd_map_zero __P((struct proc *, struct exec_vmcmd *)); void *copyargs __P((struct exec_package *, struct ps_strings *, void *, void *)); -void setregs __P((struct proc *, struct exec_package *, +void setregs __P((struct lwp *, struct exec_package *, u_long)); int check_exec __P((struct proc *, struct exec_package *)); int exec_init __P((int)); Index: sys/sys/lwp.h =================================================================== RCS file: lwp.h diff -N lwp.h --- /dev/null Tue Apr 24 13:41:34 2001 +++ /tmp/cvsBVWc5bD4f1 Tue Apr 24 17:08:22 2001 @@ -0,0 +1,139 @@ +/* $Id: lwp.h,v 1.1.2.2 2001/04/08 20:51:35 nathanw Exp $ */ + +/* XXX Copyright +*/ + +#ifndef _SYS_LWP_H +#define _SYS_LWP_H + + +#if defined(_KERNEL) +#include /* curcpu() and cpu_info */ +#endif +#include /* Machine-dependent proc substruct. */ +#include +#include +#include + +struct lwp { + struct lwp *l_forw; /* Doubly-linked run/sleep queue. */ + struct lwp *l_back; + LIST_ENTRY(lwp) l_list; /* Entry on list of all LWPs. */ + LIST_ENTRY(lwp) l_zlist; /* Entry on zombie list. */ + + struct proc *l_proc; /* Process which with we are associated. */ + + LIST_ENTRY(lwp) l_sibling; /* Entry on process's list of LWPs. */ + + int l_flag; + struct cpu_info * __volatile l_cpu; /* CPU we're running on if + SONPROC */ + int l_stat; + lwpid_t l_lid; /* LWP identifier; local to process. */ + +#define l_startzero l_swtime + u_int l_swtime; /* Time swapped in or out. */ + u_int l_slptime; /* Time since last blocked. */ + + void *l_wchan; /* Sleep address. */ + struct callout l_tsleep_ch; /* callout for tsleep */ + const char *l_wmesg; /* Reason for sleep. */ + int l_holdcnt; /* If non-zero, don't swap. */ + +#define l_endzero l_priority + +#define l_startcopy l_priority + + void *l_ctxlink; /* uc_link {get,set}context */ + + u_char l_priority; /* Process priority. */ + u_char l_usrpri; /* User-priority based on p_cpu and p_nice. */ + +#define l_endcopy l_private + + void *l_private; /* svr4-style lwp-private data */ + + + struct user *l_addr; /* Kernel virtual addr of u-area (PROC ONLY). */ + struct mdlwp l_md; /* Any machine-dependent fields. */ + +}; + +LIST_HEAD(lwplist, lwp); /* a list of LWPs */ + +extern struct lwplist alllwp; /* List of all LWPs. */ +extern struct lwplist deadlwp; /* */ +extern struct lwplist zomblwp; + +extern struct pool lwp_pool; /* memory pool for LWPs */ +extern struct pool lwp_uc_pool; /* memory pool for LWP startup args */ + +extern struct lwp lwp0; /* LWP for proc0 */ + +/* These flags are kept in l_flag. */ +#define L_INMEM 0x00004 /* Loaded into memory. */ +#define L_SELECT 0x00040 /* Selecting; wakeup/waiting danger. */ +#define L_SINTR 0x00080 /* Sleep is interruptible. */ +#define L_TIMEOUT 0x00400 /* Timing out during sleep. */ +#define L_DETACHED 0x00800 /* Won't be waited for. */ +#define L_SA 0x01000 /* Scheduler activations LWP */ + +/* + * Status values. + * + * A note about SRUN and SONPROC: SRUN indicates that a process is + * runnable but *not* yet running, i.e. is on a run queue. SONPROC + * indicates that the process is actually executing on a CPU, i.e. + * it is no longer on a run queue. + */ +#define LSIDL 1 /* Process being created by fork. */ +#define LSRUN 2 /* Currently runnable. */ +#define LSSLEEP 3 /* Sleeping on an address. */ +#define LSSTOP 4 /* Process debugging or suspension. */ +#define LSZOMB 5 /* Awaiting collection by parent. */ +#define LSDEAD 6 /* Process is almost a zombie. */ +#define LSONPROC 7 /* Process is currently on a CPU. */ +#define LSSUSPENDED 8 /* Not running, not signalable. */ + +#ifdef _KERNEL +#define PHOLD(l) \ +do { \ + if ((l)->l_holdcnt++ == 0 && ((l)->l_flag & L_INMEM) == 0) \ + uvm_swapin(l); \ +} while (0) +#define PRELE(l) (--(l)->l_holdcnt) + + +void preempt (struct lwp *); +int mi_switch (struct lwp *, struct lwp *); +void remrunqueue (struct lwp *); +void resetpriority (struct lwp *); +void setrunnable (struct lwp *); +void setrunqueue (struct lwp *); +void unsleep (struct lwp *); +int cpu_switch (struct lwp *); +void cpu_preempt (struct lwp *, struct lwp *); + +int newlwp(struct lwp *, struct proc *, vaddr_t, int, + void *, size_t, void (*)(void *), void *, struct lwp **); + +/* Flags for _lwp_wait1 */ +#define LWPWAIT_EXITCONTROL 0x00000001 +int lwp_wait1(struct lwp *, lwpid_t, lwpid_t *, int); +void cpu_fiddle_uc(struct lwp *, ucontext_t *); +void cpu_setfunc(struct lwp *, void (*)(void *), void *); +void startlwp(void *); +void upcallret(void *); + +void lwp_exit (struct lwp *); +void lwp_exit2 (struct lwp *); +#endif /* _KERNEL */ + +/* Flags for _lwp_create(), as per Solaris. */ + +#define LWP_DETACHED 0x00000040 +#define LWP_SUSPENDED 0x00000080 +#define __LWP_ASLWP 0x00000100 /* XXX more icky signal semantics */ + +#endif /* !_SYS_LWP_H_ */ + Index: sys/sys/malloc.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/sys/malloc.h,v retrieving revision 1.59 retrieving revision 1.59.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.59 -r1.59.2.1 --- sys/sys/malloc.h 2001/02/26 16:35:41 1.59 +++ sys/sys/malloc.h 2001/03/05 22:50:02 1.59.2.1 @@ -170,10 +170,12 @@ #define M_SOFTINTR 114 /* Softinterrupt structures */ #define M_EMULDATA 115 /* Per-process emulation data */ #define M_1394CTL 116 /* IEEE 1394 control structures */ #define M_1394DATA 117 /* IEEE 1394 data buffers */ -#define M_LAST 118 /* Must be last type + 1 */ +#define M_SA 118 /* Scheduler activation structures */ +#define M_LAST 119 /* Must be last type + 1 */ + #define INITKMEMNAMES { \ "free", /* 0 M_FREE */ \ "mbuf", /* 1 M_MBUF */ \ "devbuf", /* 2 M_DEVBUF */ \ @@ -291,9 +293,10 @@ "softintr", /* 114 M_SOFTINTR */ \ "emuldata", /* 115 M_EMULDATA */ \ "1394ctl", /* 116 M_1394CTL */ \ "1394data", /* 117 M_1394DATA */ \ - NULL, /* 118 */ \ + "sa", /* 118 M_SA */ \ + NULL, /* 119 */ \ } struct kmemstats { long ks_inuse; /* # of packets of this type currently in use */ Index: sys/sys/param.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/sys/param.h,v retrieving revision 1.126 retrieving revision 1.122.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.126 -r1.122.2.2 --- sys/sys/param.h 2001/04/07 15:56:51 1.126 +++ sys/sys/param.h 2001/04/09 01:59:02 1.122.2.2 @@ -139,8 +139,11 @@ /* Signals. */ #include +/* Scheduler activations. */ +#include + /* Machine type dependent parameters. */ #include #include @@ -164,9 +167,10 @@ #define PRIMASK 0x0ff #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ #define PNORELOCK 0x200 /* OR'd with pri for cond_wait() to not relock the interlock */ - +#define PNOEXITERR 0x400 /* OR'd with pri for tsleep to not exit + with an error code when LWPs are exiting */ #define NBPW sizeof(int) /* number of bytes per word (integer) */ #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ #define NODEV (dev_t)(-1) /* non-existent device */ Index: sys/sys/proc.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/sys/proc.h,v retrieving revision 1.124 retrieving revision 1.124.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.124 -r1.124.2.1 --- sys/sys/proc.h 2001/03/04 20:49:34 1.124 +++ sys/sys/proc.h 2001/03/05 22:50:02 1.124.2.1 @@ -46,11 +46,8 @@ #if defined(_KERNEL) && !defined(_LKM) #include "opt_multiprocessor.h" #endif -#if defined(_KERNEL) -#include /* curcpu() and cpu_info */ -#endif #include /* Machine-dependent proc substruct */ #include #include #include @@ -132,10 +129,8 @@ * which might be addressible only on a processor on which the process * is running. */ struct proc { - struct proc *p_forw; /* Doubly-linked run/sleep queue */ - struct proc *p_back; LIST_ENTRY(proc) p_list; /* List of all processes */ /* Substructures: */ struct pcred *p_cred; /* Process owner's identity */ @@ -148,59 +143,57 @@ #define p_ucred p_cred->pc_ucred #define p_rlimit p_limit->pl_rlimit - int p_exitsig; /* Signal to sent to parent on exit */ - int p_flag; /* P_* flags */ - struct cpu_info * __volatile p_cpu; - /* CPU we're running on if SONPROC */ - char p_stat; /* S* process status */ + int p_exitsig; /* signal to sent to parent on exit */ + int p_flag; /* P_* flags. */ + char p_stat; /* S* process status. */ char p_pad1[3]; - pid_t p_pid; /* Process identifier */ - LIST_ENTRY(proc) p_hash; /* Hash chain */ - LIST_ENTRY(proc) p_pglist; /* List of processes in pgrp */ - struct proc *p_pptr; /* Pointer to parent process */ - LIST_ENTRY(proc) p_sibling; /* List of sibling processes */ - LIST_HEAD(, proc) p_children; /* Pointer to list of children */ + pid_t p_pid; /* Process identifier. */ + LIST_ENTRY(proc) p_hash; /* Hash chain. */ + LIST_ENTRY(proc) p_pglist; /* List of processes in pgrp. */ + struct proc *p_pptr; /* Pointer to parent process. */ + LIST_ENTRY(proc) p_sibling; /* List of sibling processes. */ + LIST_HEAD(, proc) p_children; /* Pointer to list of children. */ -/* - * The following fields are all zeroed upon creation in fork. - */ -#define p_startzero p_oppid + struct simplelock p_lwplock; /* Lock on LWP-related state. */ + + LIST_HEAD(, lwp) p_lwps; /* Pointer to list of LWPs. */ + +/* The following fields are all zeroed upon creation in fork. */ +#define p_startzero p_nlwps - pid_t p_oppid; /* Save parent pid during ptrace. XXX */ - int p_dupfd; /* Sideways return value from filedescopen. XXX */ + int p_nlwps; /* Number of LWPs */ + int p_nrlwps; /* Number of running LWPs */ + int p_nzlwps; /* Number of zombie LWPs */ + int p_nlwpid; /* Next LWP ID */ - /* Scheduling */ - u_int p_estcpu; /* Time averaged value of p_cpticks. XXX belongs in p_startcopy section */ + struct sadata *p_sa; /* Scheduler activation information */ + + /* scheduling */ + u_int p_estcpu; /* Time averaged value of p_cpticks XXX belongs in p_startcopy section */ int p_cpticks; /* Ticks of cpu time */ - fixpt_t p_pctcpu; /* %cpu for this proc during p_swtime */ - void *p_wchan; /* Sleep address */ - struct callout p_tsleep_ch; /* Callout for tsleep */ - const char *p_wmesg; /* Reason for sleep */ - u_int p_swtime; /* Time swapped in or out */ - u_int p_slptime; /* Time since last blocked */ + fixpt_t p_pctcpu; /* %cpu for this process during p_swtime */ - struct callout p_realit_ch; /* Real time callout */ + pid_t p_oppid; /* Save parent pid during ptrace XXX */ + int p_dupfd; /* Sideways return value from filedescopen XXX */ + struct callout p_realit_ch; /* real time callout */ struct itimerval p_realtimer; /* Alarm timer */ - struct timeval p_rtime; /* Real time */ - u_quad_t p_uticks; /* Statclock hits in user mode */ - u_quad_t p_sticks; /* Statclock hits in system mode */ - u_quad_t p_iticks; /* Statclock hits processing intr */ + struct timeval p_rtime; /* Real time */ + u_quad_t p_uticks; /* Statclock hits in user mode */ + u_quad_t p_sticks; /* Statclock hits in system mode */ + u_quad_t p_iticks; /* Statclock hits processing intr */ int p_traceflag; /* Kernel trace points */ - struct file *p_tracep; /* Trace to file */ - - struct vnode *p_textvp; /* Vnode of executable */ + struct file *p_tracep; /* Trace to file */ - int p_locks; /* DEBUG: lockmgr count of held locks */ + struct vnode *p_textvp; /* Vnode of executable */ - int p_holdcnt; /* If non-zero, don't swap */ + int p_locks; /* DEBUG: lockmgr count of held locks */ const struct emul *p_emul; /* Emulation information */ - void *p_emuldata; /* - * Per-process emulation data, or NULL. - * Malloc type M_EMULDATA + void *p_emuldata; /* Per-process emulation data, or NULL. + * Malloc type M_EMULDATA */ /* * End area that is zeroed on creation @@ -211,71 +204,57 @@ * The following fields are all copied upon creation in fork. */ #define p_startcopy p_sigctx.ps_startcopy - struct sigctx p_sigctx; /* Signal state */ + struct sigctx p_sigctx; /* Signal state */ - u_char p_priority; /* Process priority */ - u_char p_usrpri; /* User-priority based on p_cpu and p_nice */ u_char p_nice; /* Process "nice" value */ char p_comm[MAXCOMLEN+1]; - struct pgrp *p_pgrp; /* Pointer to process group */ - void *p_ctxlink; /* uc_link {get,set}context */ + struct pgrp *p_pgrp; /* Pointer to process group */ - struct ps_strings *p_psstr; /* Address of process's ps_strings */ - size_t p_psargv; /* Offset of ps_argvstr in above */ - size_t p_psnargv; /* Offset of ps_nargvstr in above */ - size_t p_psenv; /* Offset of ps_envstr in above */ - size_t p_psnenv; /* Offset of ps_nenvstr in above */ + struct ps_strings *p_psstr; /* address of process's ps_strings */ + size_t p_psargv; /* offset of ps_argvstr in above */ + size_t p_psnargv; /* offset of ps_nargvstr in above */ + size_t p_psenv; /* offset of ps_envstr in above */ + size_t p_psnenv; /* offset of ps_nenvstr in above */ -/* +/* * End area that is copied on creation */ -#define p_endcopy p_thread - - void *p_thread; /* Id for this "thread"; Mach glue. XXX */ - struct user *p_addr; /* Kernel virtual addr of u-area (PROC ONLY) */ - struct mdproc p_md; /* Any machine-dependent fields */ +#define p_endcopy p_xstat u_short p_xstat; /* Exit status for wait; also stop signal */ u_short p_acflag; /* Accounting flags */ - struct rusage *p_ru; /* Exit information. XXX */ + struct rusage *p_ru; /* Exit information. XXX */ + + struct mdproc p_md; /* Any machine-dependent fields */ }; #define p_session p_pgrp->pg_session #define p_pgid p_pgrp->pg_id /* * Status values. * - * A note about SRUN and SONPROC: SRUN indicates that a process is - * runnable but *not* yet running, i.e. is on a run queue. SONPROC - * indicates that the process is actually executing on a CPU, i.e. - * it is no longer on a run queue. */ #define SIDL 1 /* Process being created by fork */ -#define SRUN 2 /* Currently runnable */ -#define SSLEEP 3 /* Sleeping on an address */ +#define SACTIVE 2 /* Process is not stopped */ #define SSTOP 4 /* Process debugging or suspension */ #define SZOMB 5 /* Awaiting collection by parent */ #define SDEAD 6 /* Process is almost a zombie */ -#define SONPROC 7 /* Process is currently on a CPU */ #define P_ZOMBIE(p) ((p)->p_stat == SZOMB || (p)->p_stat == SDEAD) /* These flags are kept in p_flag. */ #define P_ADVLOCK 0x00001 /* Process may hold a POSIX advisory lock */ #define P_CONTROLT 0x00002 /* Has a controlling terminal */ -#define P_INMEM 0x00004 /* Loaded into memory */ #define P_NOCLDSTOP 0x00008 /* No SIGCHLD when children stop */ #define P_PPWAIT 0x00010 /* Parent is waiting for child to exec/exit */ #define P_PROFIL 0x00020 /* Has started profiling */ -#define P_SELECT 0x00040 /* Selecting; wakeup/waiting danger */ -#define P_SINTR 0x00080 /* Sleep is interruptible */ #define P_SUGID 0x00100 /* Had set id privileges since last exec */ #define P_SYSTEM 0x00200 /* System proc: no sigs, stats or swapping */ -#define P_TIMEOUT 0x00400 /* Timing out during sleep */ +#define P_SA 0x00400 /* Using scheduler activations */ #define P_TRACED 0x00800 /* Debugged process being traced */ #define P_WAITED 0x01000 /* Debugging process has waited for child */ #define P_WEXIT 0x02000 /* Working on exiting */ #define P_EXEC 0x04000 /* Process called exec */ @@ -335,14 +314,8 @@ if (--(s)->s_count == 0) \ FREE(s, M_SESSION); \ } while (0) -#define PHOLD(p) \ -do { \ - if ((p)->p_holdcnt++ == 0 && ((p)->p_flag & P_INMEM) == 0) \ - uvm_swapin(p); \ -} while (0) -#define PRELE(p) (--(p)->p_holdcnt) /* * Flags passed to fork1(). */ @@ -367,9 +340,9 @@ #if !defined(curproc) #if defined(MULTIPROCESSOR) #define curproc curcpu()->ci_curproc /* Current running proc */ #else -extern struct proc *curproc; /* Current running proc */ +extern struct lwp *curproc; /* Current running proc. */ #endif /* MULTIPROCESSOR */ #endif /* ! curproc */ extern struct proc proc0; /* Process slot for swapper */ @@ -390,58 +363,45 @@ extern struct pool proc_pool; /* Memory pool for procs */ extern struct pool pcred_pool; /* Memory pool for pcreds */ extern struct pool plimit_pool; /* Memory pool for plimits */ +extern struct pool pstats_pool; /* memory pool for pstats */ extern struct pool rusage_pool; /* Memory pool for rusages */ struct proc *pfind(pid_t); /* Find process by id */ struct pgrp *pgfind(pid_t); /* Find process group by id */ struct simplelock; - int chgproccnt(uid_t uid, int diff); int enterpgrp(struct proc *p, pid_t pgid, int mksess); void fixjobc(struct proc *p, struct pgrp *pgrp, int entering); int inferior(struct proc *p, struct proc *q); int leavepgrp(struct proc *p); void yield(void); -void preempt(struct proc *); -void mi_switch(struct proc *); void pgdelete(struct pgrp *pgrp); void procinit(void); -#ifndef remrunqueue -void remrunqueue(struct proc *); -#endif -void resetpriority(struct proc *); -void setrunnable(struct proc *); -#ifndef setrunqueue -void setrunqueue(struct proc *); -#endif +void resetprocpriority(struct proc *); void suspendsched(void); int ltsleep(void *chan, int pri, const char *wmesg, int timo, __volatile struct simplelock *); -void unsleep(struct proc *); void wakeup(void *chan); void wakeup_one(void *chan); void reaper(void *); -void exit1(struct proc *, int); -void exit2(struct proc *); -int fork1(struct proc *, int, int, void *, size_t, +void exit1(struct lwp *, int); +void exit2(struct lwp *); +int fork1(struct lwp *, int, int, void *, size_t, void (*)(void *), void *, register_t *, struct proc **); void rqinit(void); int groupmember(gid_t, struct ucred *); -#ifndef cpu_switch -void cpu_switch(struct proc *); -#endif -void cpu_exit(struct proc *); -void cpu_fork(struct proc *, struct proc *, void *, size_t, +void cpu_exit(struct lwp *, int); +void cpu_fork(struct lwp *, struct lwp *, void *, size_t, void (*)(void *), void *); /* * XXX: use __P() to allow ports to have as a #define. * XXX: we need a better way to solve this. */ -void cpu_wait __P((struct proc *)); +void cpu_wait __P((struct lwp *)); void child_return(void *); int proc_isunder(struct proc *, struct proc*); Index: sys/sys/ptrace.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/sys/ptrace.h,v retrieving revision 1.21 retrieving revision 1.21.42.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.21 -r1.21.42.1 --- sys/sys/ptrace.h 1996/02/09 18:25:26 1.21 +++ sys/sys/ptrace.h 2001/03/05 22:50:03 1.21.42.1 @@ -61,20 +61,20 @@ #endif void proc_reparent __P((struct proc *child, struct proc *newparent)); #ifdef PT_GETFPREGS -int process_read_fpregs __P((struct proc *p, struct fpreg *regs)); +int process_read_fpregs __P((struct lwp *l, struct fpreg *regs)); #endif #ifdef PT_GETREGS -int process_read_regs __P((struct proc *p, struct reg *regs)); +int process_read_regs __P((struct lwp *l, struct reg *regs)); #endif -int process_set_pc __P((struct proc *p, caddr_t addr)); -int process_sstep __P((struct proc *p, int sstep)); +int process_set_pc __P((struct lwp *l, caddr_t addr)); +int process_sstep __P((struct lwp *l, int sstep)); #ifdef PT_SETFPREGS -int process_write_fpregs __P((struct proc *p, struct fpreg *regs)); +int process_write_fpregs __P((struct lwp *l, struct fpreg *regs)); #endif #ifdef PT_SETREGS -int process_write_regs __P((struct proc *p, struct reg *regs)); +int process_write_regs __P((struct lwp *l, struct reg *regs)); #endif #ifndef FIX_SSTEP #define FIX_SSTEP(p) Index: sys/sys/resourcevar.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/sys/resourcevar.h,v retrieving revision 1.15 retrieving revision 1.15.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.15 -r1.15.2.1 --- sys/sys/resourcevar.h 2000/12/10 19:29:31 1.15 +++ sys/sys/resourcevar.h 2001/03/05 22:50:03 1.15.2.1 @@ -95,7 +95,9 @@ void calcru __P((struct proc *p, struct timeval *up, struct timeval *sp, struct timeval *ip)); struct plimit *limcopy __P((struct plimit *lim)); void limfree __P((struct plimit *)); -void ruadd __P((struct rusage *ru, struct rusage *ru2)); +void ruadd __P((struct rusage *ru, struct rusage *ru2)); +struct pstats *pstatscopy __P((struct pstats *ps)); +void pstatsfree __P((struct pstats *ps)); #endif #endif /* !_SYS_RESOURCEVAR_H_ */ Index: sys/sys/sa.h =================================================================== RCS file: sa.h diff -N sa.h --- /dev/null Tue Apr 24 13:41:34 2001 +++ /tmp/cvsgFEGaLG9AA Tue Apr 24 17:08:22 2001 @@ -0,0 +1,31 @@ +/* $Id: sa.h,v 1.1.2.1 2001/03/05 22:50:03 nathanw Exp $ */ + +/* XXX Copyright + */ + +#ifndef _SYS_SA_H +#define _SYS_SA_H + +#include + +struct sa_t { + ucontext_t *sa_context; + int sa_id; + int sa_cpu; + int sa_sig; + int sa_code; +}; + +typedef void (*sa_upcall_t)(int type, struct sa_t *sas[], int events, + int interrupted); + +#define SA_UPCALL_NEWPROC 0 +#define SA_UPCALL_PREEMPTED 1 +#define SA_UPCALL_BLOCKED 2 +#define SA_UPCALL_UNBLOCKED 3 +#define SA_UPCALL_SIGNAL 4 +#define SA_UPCALL_USER 5 +#define SA_UPCALL_NUPCALLS 6 + + +#endif /* !_SYS_SA_H */ Index: sys/sys/savar.h =================================================================== RCS file: savar.h diff -N savar.h --- /dev/null Tue Apr 24 13:41:34 2001 +++ /tmp/cvsXo2JawxvGS Tue Apr 24 17:08:22 2001 @@ -0,0 +1,41 @@ +/* $Id: savar.h,v 1.1.2.1 2001/03/05 22:50:03 nathanw Exp $ */ + +/* XXX Copyright + * + */ + +/* + * Internal data usd by the scheduler activation implementation + */ + +#ifndef _SYS_SAVAR_H +#define _SYS_SAVAR_H + +struct sadata { + + struct simplelock sa_lock; /* Lock on fields of this structure. */ + + sa_upcall_t sa_upcall; /* The upcall entry point for this process */ + + LIST_HEAD(, lwp) sa_lwpcache; + int sa_ncached; + + stack_t *sa_stacks; /* Pointer to array of upcall stacks */ + int sa_nstackentries; /* Size of the array */ + int sa_nstacks; /* Number of entries with valid stacks */ + + int sa_concurrency; /* Desired concurrency */ +}; + +extern struct pool sadata_pool; /* memory pool for sadata structures */ + +#define SA_NUMSTACKS 16 /* Number of stacks allocated. XXX */ + +void sa_switch(struct lwp *, int); +void sa_switchcall(void *); +int sa_upcall(struct lwp *, int, struct lwp *, struct lwp *, int, u_long); +void cpu_upcall(struct lwp *, stack_t *st, int, int, int, struct sa_t **); +ucontext_t *cpu_stashcontext(struct lwp *); + + +#endif /* !_SYS_SAVAR_H */ Index: sys/sys/sched.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/sys/sched.h,v retrieving revision 1.10 retrieving revision 1.10.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.10 -r1.10.2.1 --- sys/sys/sched.h 2000/08/26 04:17:44 1.10 +++ sys/sys/sched.h 2001/03/05 22:50:03 1.10.2.1 @@ -102,10 +102,10 @@ */ #define SLPQUE_TABLESIZE 128 #define SLPQUE_LOOKUP(x) (((u_long)(x) >> 8) & (SLPQUE_TABLESIZE - 1)) struct slpque { - struct proc *sq_head; - struct proc **sq_tailp; + struct lwp *sq_head; + struct lwp **sq_tailp; }; /* * Run queues. @@ -117,10 +117,10 @@ * first non-empty queue. */ #define RUNQUE_NQS 32 struct prochd { - struct proc *ph_link; - struct proc *ph_rlink; + struct lwp *ph_link; + struct lwp *ph_rlink; }; /* * CPU states. @@ -181,9 +181,9 @@ struct proc; struct cpu_info; -void schedclock(struct proc *p); +void schedclock(struct lwp *p); void sched_wakeup(void *); void roundrobin(struct cpu_info *); /* Index: sys/sys/signal.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/sys/signal.h,v retrieving revision 1.42 retrieving revision 1.42.20.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.42 -r1.42.20.1 --- sys/sys/signal.h 1998/12/21 10:35:00 1.42 +++ sys/sys/signal.h 2001/03/05 22:50:03 1.42.20.1 @@ -158,29 +158,38 @@ #define __sigfillset(s) ((s)->__bits[0] = 0xffffffff, \ (s)->__bits[1] = 0xffffffff, \ (s)->__bits[2] = 0xffffffff, \ (s)->__bits[3] = 0xffffffff) - -#ifdef _KERNEL -#define sigaddset(s, n) __sigaddset(s, n) -#define sigdelset(s, n) __sigdelset(s, n) -#define sigismember(s, n) __sigismember(s, n) -#define sigemptyset(s) __sigemptyset(s) -#define sigfillset(s) __sigfillset(s) -#define sigplusset(s, t) \ +#define __sigplusset(s, t) \ do { \ (t)->__bits[0] |= (s)->__bits[0]; \ (t)->__bits[1] |= (s)->__bits[1]; \ (t)->__bits[2] |= (s)->__bits[2]; \ (t)->__bits[3] |= (s)->__bits[3]; \ } while (0) -#define sigminusset(s, t) \ +#define __sigminusset(s, t) \ do { \ (t)->__bits[0] &= ~(s)->__bits[0]; \ (t)->__bits[1] &= ~(s)->__bits[1]; \ (t)->__bits[2] &= ~(s)->__bits[2]; \ (t)->__bits[3] &= ~(s)->__bits[3]; \ } while (0) +#define __sigandset(s, t) \ + do { \ + (t)->__bits[0] &= (s)->__bits[0]; \ + (t)->__bits[1] &= (s)->__bits[1]; \ + (t)->__bits[2] &= (s)->__bits[2]; \ + (t)->__bits[3] &= (s)->__bits[3]; \ + } while (0) + +#ifdef _KERNEL +#define sigaddset(s, n) __sigaddset(s, n) +#define sigdelset(s, n) __sigdelset(s, n) +#define sigismember(s, n) __sigismember(s, n) +#define sigemptyset(s) __sigemptyset(s) +#define sigfillset(s) __sigfillset(s) +#define sigplusset(s, t) __sigplusset(s, t) +#define sigminusset(s, t) __sigminusset(s, t) #endif /* _KERNEL */ /* * Signal vector "template" used in sigaction call. Index: sys/sys/signalvar.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/sys/signalvar.h,v retrieving revision 1.28 retrieving revision 1.28.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.28 -r1.28.2.1 --- sys/sys/signalvar.h 2001/01/14 22:32:01 1.28 +++ sys/sys/signalvar.h 2001/03/05 22:50:03 1.28.2.1 @@ -99,9 +99,9 @@ * Determine signal that should be delivered to process p, the current * process, 0 if none. If there is a pending stop signal with default * action, the process stops in issignal(). */ -#define CURSIG(p) (p->p_sigctx.ps_sigcheck ? issignal(p) : 0) +#define CURSIG(l) (l->l_proc->p_sigctx.ps_sigcheck ? issignal(l) : 0) /* * Clear a pending signal from a process. */ @@ -165,22 +165,23 @@ /* * Machine-independent functions: */ -int coredump __P((struct proc *p)); +int coredump __P((struct lwp *p)); void execsigs __P((struct proc *p)); void gsignal __P((int pgid, int sig)); -int issignal __P((struct proc *p)); +int issignal __P((struct lwp *l)); void pgsignal __P((struct pgrp *pgrp, int sig, int checkctty)); void postsig __P((int sig)); void psignal1 __P((struct proc *p, int sig, int dolock)); #define psignal(p, sig) psignal1((p), (sig), 1) #define sched_psignal(p, sig) psignal1((p), (sig), 0) void siginit __P((struct proc *p)); -void trapsignal __P((struct proc *p, int sig, u_long code)); -void sigexit __P((struct proc *, int)); +void trapsignal __P((struct lwp *l, int sig, u_long code)); +void sigexit __P((struct lwp *, int)); void setsigvec __P((struct proc *, int, struct sigaction *)); int killpg1 __P((struct proc *, int, int, int)); +struct lwp *proc_unstop __P((struct proc *p)); int sigaction1 __P((struct proc *p, int signum, \ const struct sigaction *nsa, struct sigaction *osa)); int sigprocmask1 __P((struct proc *p, int how, \ @@ -204,11 +205,11 @@ struct core; struct core32; struct vnode; struct ucred; -int cpu_coredump __P((struct proc *, struct vnode *, struct ucred *, +int cpu_coredump __P((struct lwp *, struct vnode *, struct ucred *, struct core *)); -int cpu_coredump32 __P((struct proc *, struct vnode *, struct ucred *, +int cpu_coredump32 __P((struct lwp *, struct vnode *, struct ucred *, struct core32 *)); /* * Compatibility functions. See compat/common/kern_sig_13.c. Index: sys/sys/syscall.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/sys/syscall.h,v retrieving revision 1.118 retrieving revision 1.118.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.118 -r1.118.2.1 --- sys/sys/syscall.h 2001/01/27 07:48:29 1.118 +++ sys/sys/syscall.h 2001/03/05 22:50:03 1.118.2.1 @@ -712,7 +712,49 @@ #define SYS_issetugid 305 /* syscall: "utrace" ret: "int" args: "const char *" "void *" "size_t" */ #define SYS_utrace 306 + +/* syscall: "getcontext" ret: "int" args: "struct __ucontext *" */ +#define SYS_getcontext 307 + +/* syscall: "setcontext" ret: "int" args: "const struct __ucontext *" */ +#define SYS_setcontext 308 + +/* syscall: "_lwp_create" ret: "int" args: "const struct __ucontext *" "u_long" "lwpid_t *" */ +#define SYS__lwp_create 309 + +/* syscall: "_lwp_exit" ret: "int" args: */ +#define SYS__lwp_exit 310 + +/* syscall: "_lwp_self" ret: "lwpid_t" args: */ +#define SYS__lwp_self 311 + +/* syscall: "_lwp_wait" ret: "int" args: "lwpid_t" "lwpid_t *" */ +#define SYS__lwp_wait 312 + +/* syscall: "_lwp_suspend" ret: "int" args: "lwpid_t" */ +#define SYS__lwp_suspend 313 + +/* syscall: "_lwp_continue" ret: "int" args: "lwpid_t" */ +#define SYS__lwp_continue 314 + +/* syscall: "sa_register" ret: "int" args: "sa_upcall_t" "sa_upcall_t *" */ +#define SYS_sa_register 330 + +/* syscall: "sa_stacks" ret: "int" args: "int" "stack_t *" */ +#define SYS_sa_stacks 331 + +/* syscall: "sa_enable" ret: "int" args: */ +#define SYS_sa_enable 332 + +/* syscall: "sa_setconcurrency" ret: "int" args: "int" */ +#define SYS_sa_setconcurrency 333 + +/* syscall: "sa_yield" ret: "int" args: */ +#define SYS_sa_yield 334 + +/* syscall: "sa_preempt" ret: "int" args: "int" */ +#define SYS_sa_preempt 335 #define SYS_MAXSYSCALL 340 #define SYS_NSYSENT 512 Index: sys/sys/syscallargs.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/sys/syscallargs.h,v retrieving revision 1.99 retrieving revision 1.99.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.99 -r1.99.2.1 --- sys/sys/syscallargs.h 2001/01/27 07:48:30 1.99 +++ sys/sys/syscallargs.h 2001/03/05 22:50:03 1.99.2.1 @@ -1213,313 +1213,372 @@ syscallarg(void *) addr; syscallarg(size_t) len; }; +struct sys_getcontext_args { + syscallarg(struct __ucontext *) ucp; +}; + +struct sys_setcontext_args { + syscallarg(const struct __ucontext *) ucp; +}; + +struct sys__lwp_create_args { + syscallarg(const struct __ucontext *) ucp; + syscallarg(u_long) flags; + syscallarg(lwpid_t *) new_lwp; +}; + +struct sys__lwp_wait_args { + syscallarg(lwpid_t) wait_for; + syscallarg(lwpid_t *) departed; +}; + +struct sys__lwp_suspend_args { + syscallarg(lwpid_t) target; +}; + +struct sys__lwp_continue_args { + syscallarg(lwpid_t) target; +}; + +struct sys_sa_register_args { + syscallarg(sa_upcall_t) new; + syscallarg(sa_upcall_t *) old; +}; + +struct sys_sa_stacks_args { + syscallarg(int) num; + syscallarg(stack_t *) stacks; +}; + +struct sys_sa_setconcurrency_args { + syscallarg(int) concurrency; +}; + +struct sys_sa_preempt_args { + syscallarg(int) sa_id; +}; + /* * System call prototypes. */ -int sys_exit(struct proc *, void *, register_t *); -int sys_fork(struct proc *, void *, register_t *); -int sys_read(struct proc *, void *, register_t *); -int sys_write(struct proc *, void *, register_t *); -int sys_open(struct proc *, void *, register_t *); -int sys_close(struct proc *, void *, register_t *); -int sys_wait4(struct proc *, void *, register_t *); -int compat_43_sys_creat(struct proc *, void *, register_t *); -int sys_link(struct proc *, void *, register_t *); -int sys_unlink(struct proc *, void *, register_t *); -int sys_chdir(struct proc *, void *, register_t *); -int sys_fchdir(struct proc *, void *, register_t *); -int sys_mknod(struct proc *, void *, register_t *); -int sys_chmod(struct proc *, void *, register_t *); -int sys_chown(struct proc *, void *, register_t *); -int sys_obreak(struct proc *, void *, register_t *); -int sys_getfsstat(struct proc *, void *, register_t *); -int compat_43_sys_lseek(struct proc *, void *, register_t *); +int sys_exit(struct lwp *, void *, register_t *); +int sys_fork(struct lwp *, void *, register_t *); +int sys_read(struct lwp *, void *, register_t *); +int sys_write(struct lwp *, void *, register_t *); +int sys_open(struct lwp *, void *, register_t *); +int sys_close(struct lwp *, void *, register_t *); +int sys_wait4(struct lwp *, void *, register_t *); +int compat_43_sys_creat(struct lwp *, void *, register_t *); +int sys_link(struct lwp *, void *, register_t *); +int sys_unlink(struct lwp *, void *, register_t *); +int sys_chdir(struct lwp *, void *, register_t *); +int sys_fchdir(struct lwp *, void *, register_t *); +int sys_mknod(struct lwp *, void *, register_t *); +int sys_chmod(struct lwp *, void *, register_t *); +int sys_chown(struct lwp *, void *, register_t *); +int sys_obreak(struct lwp *, void *, register_t *); +int sys_getfsstat(struct lwp *, void *, register_t *); +int compat_43_sys_lseek(struct lwp *, void *, register_t *); #ifdef COMPAT_43 -int sys_getpid_with_ppid(struct proc *, void *, register_t *); +int sys_getpid_with_ppid(struct lwp *, void *, register_t *); #else -int sys_getpid(struct proc *, void *, register_t *); +int sys_getpid(struct lwp *, void *, register_t *); #endif -int sys_mount(struct proc *, void *, register_t *); -int sys_unmount(struct proc *, void *, register_t *); -int sys_setuid(struct proc *, void *, register_t *); +int sys_mount(struct lwp *, void *, register_t *); +int sys_unmount(struct lwp *, void *, register_t *); +int sys_setuid(struct lwp *, void *, register_t *); #ifdef COMPAT_43 -int sys_getuid_with_euid(struct proc *, void *, register_t *); +int sys_getuid_with_euid(struct lwp *, void *, register_t *); #else -int sys_getuid(struct proc *, void *, register_t *); +int sys_getuid(struct lwp *, void *, register_t *); #endif -int sys_geteuid(struct proc *, void *, register_t *); -int sys_ptrace(struct proc *, void *, register_t *); -int sys_recvmsg(struct proc *, void *, register_t *); -int sys_sendmsg(struct proc *, void *, register_t *); -int sys_recvfrom(struct proc *, void *, register_t *); -int sys_accept(struct proc *, void *, register_t *); -int sys_getpeername(struct proc *, void *, register_t *); -int sys_getsockname(struct proc *, void *, register_t *); -int sys_access(struct proc *, void *, register_t *); -int sys_chflags(struct proc *, void *, register_t *); -int sys_fchflags(struct proc *, void *, register_t *); -int sys_sync(struct proc *, void *, register_t *); -int sys_kill(struct proc *, void *, register_t *); -int compat_43_sys_stat(struct proc *, void *, register_t *); -int sys_getppid(struct proc *, void *, register_t *); -int compat_43_sys_lstat(struct proc *, void *, register_t *); -int sys_dup(struct proc *, void *, register_t *); -int sys_pipe(struct proc *, void *, register_t *); -int sys_getegid(struct proc *, void *, register_t *); -int sys_profil(struct proc *, void *, register_t *); +int sys_geteuid(struct lwp *, void *, register_t *); +int sys_ptrace(struct lwp *, void *, register_t *); +int sys_recvmsg(struct lwp *, void *, register_t *); +int sys_sendmsg(struct lwp *, void *, register_t *); +int sys_recvfrom(struct lwp *, void *, register_t *); +int sys_accept(struct lwp *, void *, register_t *); +int sys_getpeername(struct lwp *, void *, register_t *); +int sys_getsockname(struct lwp *, void *, register_t *); +int sys_access(struct lwp *, void *, register_t *); +int sys_chflags(struct lwp *, void *, register_t *); +int sys_fchflags(struct lwp *, void *, register_t *); +int sys_sync(struct lwp *, void *, register_t *); +int sys_kill(struct lwp *, void *, register_t *); +int compat_43_sys_stat(struct lwp *, void *, register_t *); +int sys_getppid(struct lwp *, void *, register_t *); +int compat_43_sys_lstat(struct lwp *, void *, register_t *); +int sys_dup(struct lwp *, void *, register_t *); +int sys_pipe(struct lwp *, void *, register_t *); +int sys_getegid(struct lwp *, void *, register_t *); +int sys_profil(struct lwp *, void *, register_t *); #if defined(KTRACE) || !defined(_KERNEL) -int sys_ktrace(struct proc *, void *, register_t *); +int sys_ktrace(struct lwp *, void *, register_t *); #else #endif -int compat_13_sys_sigaction(struct proc *, void *, register_t *); +int compat_13_sys_sigaction(struct lwp *, void *, register_t *); #ifdef COMPAT_43 -int sys_getgid_with_egid(struct proc *, void *, register_t *); +int sys_getgid_with_egid(struct lwp *, void *, register_t *); #else -int sys_getgid(struct proc *, void *, register_t *); +int sys_getgid(struct lwp *, void *, register_t *); #endif -int compat_13_sys_sigprocmask(struct proc *, void *, register_t *); -int sys___getlogin(struct proc *, void *, register_t *); -int sys_setlogin(struct proc *, void *, register_t *); -int sys_acct(struct proc *, void *, register_t *); -int compat_13_sys_sigpending(struct proc *, void *, register_t *); -int compat_13_sys_sigaltstack(struct proc *, void *, register_t *); -int sys_ioctl(struct proc *, void *, register_t *); -int compat_12_sys_reboot(struct proc *, void *, register_t *); -int sys_revoke(struct proc *, void *, register_t *); -int sys_symlink(struct proc *, void *, register_t *); -int sys_readlink(struct proc *, void *, register_t *); -int sys_execve(struct proc *, void *, register_t *); -int sys_umask(struct proc *, void *, register_t *); -int sys_chroot(struct proc *, void *, register_t *); -int compat_43_sys_fstat(struct proc *, void *, register_t *); -int compat_43_sys_getkerninfo(struct proc *, void *, register_t *); -int compat_43_sys_getpagesize(struct proc *, void *, register_t *); -int compat_12_sys_msync(struct proc *, void *, register_t *); -int sys_vfork(struct proc *, void *, register_t *); -int sys_sbrk(struct proc *, void *, register_t *); -int sys_sstk(struct proc *, void *, register_t *); -int compat_43_sys_mmap(struct proc *, void *, register_t *); -int sys_ovadvise(struct proc *, void *, register_t *); -int sys_munmap(struct proc *, void *, register_t *); -int sys_mprotect(struct proc *, void *, register_t *); -int sys_madvise(struct proc *, void *, register_t *); -int sys_mincore(struct proc *, void *, register_t *); -int sys_getgroups(struct proc *, void *, register_t *); -int sys_setgroups(struct proc *, void *, register_t *); -int sys_getpgrp(struct proc *, void *, register_t *); -int sys_setpgid(struct proc *, void *, register_t *); -int sys_setitimer(struct proc *, void *, register_t *); -int compat_43_sys_wait(struct proc *, void *, register_t *); -int compat_12_sys_swapon(struct proc *, void *, register_t *); -int sys_getitimer(struct proc *, void *, register_t *); -int compat_43_sys_gethostname(struct proc *, void *, register_t *); -int compat_43_sys_sethostname(struct proc *, void *, register_t *); -int compat_43_sys_getdtablesize(struct proc *, void *, register_t *); -int sys_dup2(struct proc *, void *, register_t *); -int sys_fcntl(struct proc *, void *, register_t *); -int sys_select(struct proc *, void *, register_t *); -int sys_fsync(struct proc *, void *, register_t *); -int sys_setpriority(struct proc *, void *, register_t *); -int sys_socket(struct proc *, void *, register_t *); -int sys_connect(struct proc *, void *, register_t *); -int compat_43_sys_accept(struct proc *, void *, register_t *); -int sys_getpriority(struct proc *, void *, register_t *); -int compat_43_sys_send(struct proc *, void *, register_t *); -int compat_43_sys_recv(struct proc *, void *, register_t *); -int compat_13_sys_sigreturn(struct proc *, void *, register_t *); -int sys_bind(struct proc *, void *, register_t *); -int sys_setsockopt(struct proc *, void *, register_t *); -int sys_listen(struct proc *, void *, register_t *); -int compat_43_sys_sigvec(struct proc *, void *, register_t *); -int compat_43_sys_sigblock(struct proc *, void *, register_t *); -int compat_43_sys_sigsetmask(struct proc *, void *, register_t *); -int compat_13_sys_sigsuspend(struct proc *, void *, register_t *); -int compat_43_sys_sigstack(struct proc *, void *, register_t *); -int compat_43_sys_recvmsg(struct proc *, void *, register_t *); -int compat_43_sys_sendmsg(struct proc *, void *, register_t *); -int sys_gettimeofday(struct proc *, void *, register_t *); -int sys_getrusage(struct proc *, void *, register_t *); -int sys_getsockopt(struct proc *, void *, register_t *); -int sys_readv(struct proc *, void *, register_t *); -int sys_writev(struct proc *, void *, register_t *); -int sys_settimeofday(struct proc *, void *, register_t *); -int sys_fchown(struct proc *, void *, register_t *); -int sys_fchmod(struct proc *, void *, register_t *); -int compat_43_sys_recvfrom(struct proc *, void *, register_t *); -int sys_setreuid(struct proc *, void *, register_t *); -int sys_setregid(struct proc *, void *, register_t *); -int sys_rename(struct proc *, void *, register_t *); -int compat_43_sys_truncate(struct proc *, void *, register_t *); -int compat_43_sys_ftruncate(struct proc *, void *, register_t *); -int sys_flock(struct proc *, void *, register_t *); -int sys_mkfifo(struct proc *, void *, register_t *); -int sys_sendto(struct proc *, void *, register_t *); -int sys_shutdown(struct proc *, void *, register_t *); -int sys_socketpair(struct proc *, void *, register_t *); -int sys_mkdir(struct proc *, void *, register_t *); -int sys_rmdir(struct proc *, void *, register_t *); -int sys_utimes(struct proc *, void *, register_t *); -int sys_adjtime(struct proc *, void *, register_t *); -int compat_43_sys_getpeername(struct proc *, void *, register_t *); -int compat_43_sys_gethostid(struct proc *, void *, register_t *); -int compat_43_sys_sethostid(struct proc *, void *, register_t *); -int compat_43_sys_getrlimit(struct proc *, void *, register_t *); -int compat_43_sys_setrlimit(struct proc *, void *, register_t *); -int compat_43_sys_killpg(struct proc *, void *, register_t *); -int sys_setsid(struct proc *, void *, register_t *); -int sys_quotactl(struct proc *, void *, register_t *); -int compat_43_sys_quota(struct proc *, void *, register_t *); -int compat_43_sys_getsockname(struct proc *, void *, register_t *); +int compat_13_sys_sigprocmask(struct lwp *, void *, register_t *); +int sys___getlogin(struct lwp *, void *, register_t *); +int sys_setlogin(struct lwp *, void *, register_t *); +int sys_acct(struct lwp *, void *, register_t *); +int compat_13_sys_sigpending(struct lwp *, void *, register_t *); +int compat_13_sys_sigaltstack(struct lwp *, void *, register_t *); +int sys_ioctl(struct lwp *, void *, register_t *); +int compat_12_sys_reboot(struct lwp *, void *, register_t *); +int sys_revoke(struct lwp *, void *, register_t *); +int sys_symlink(struct lwp *, void *, register_t *); +int sys_readlink(struct lwp *, void *, register_t *); +int sys_execve(struct lwp *, void *, register_t *); +int sys_umask(struct lwp *, void *, register_t *); +int sys_chroot(struct lwp *, void *, register_t *); +int compat_43_sys_fstat(struct lwp *, void *, register_t *); +int compat_43_sys_getkerninfo(struct lwp *, void *, register_t *); +int compat_43_sys_getpagesize(struct lwp *, void *, register_t *); +int compat_12_sys_msync(struct lwp *, void *, register_t *); +int sys_vfork(struct lwp *, void *, register_t *); +int sys_sbrk(struct lwp *, void *, register_t *); +int sys_sstk(struct lwp *, void *, register_t *); +int compat_43_sys_mmap(struct lwp *, void *, register_t *); +int sys_ovadvise(struct lwp *, void *, register_t *); +int sys_munmap(struct lwp *, void *, register_t *); +int sys_mprotect(struct lwp *, void *, register_t *); +int sys_madvise(struct lwp *, void *, register_t *); +int sys_mincore(struct lwp *, void *, register_t *); +int sys_getgroups(struct lwp *, void *, register_t *); +int sys_setgroups(struct lwp *, void *, register_t *); +int sys_getpgrp(struct lwp *, void *, register_t *); +int sys_setpgid(struct lwp *, void *, register_t *); +int sys_setitimer(struct lwp *, void *, register_t *); +int compat_43_sys_wait(struct lwp *, void *, register_t *); +int compat_12_sys_swapon(struct lwp *, void *, register_t *); +int sys_getitimer(struct lwp *, void *, register_t *); +int compat_43_sys_gethostname(struct lwp *, void *, register_t *); +int compat_43_sys_sethostname(struct lwp *, void *, register_t *); +int compat_43_sys_getdtablesize(struct lwp *, void *, register_t *); +int sys_dup2(struct lwp *, void *, register_t *); +int sys_fcntl(struct lwp *, void *, register_t *); +int sys_select(struct lwp *, void *, register_t *); +int sys_fsync(struct lwp *, void *, register_t *); +int sys_setpriority(struct lwp *, void *, register_t *); +int sys_socket(struct lwp *, void *, register_t *); +int sys_connect(struct lwp *, void *, register_t *); +int compat_43_sys_accept(struct lwp *, void *, register_t *); +int sys_getpriority(struct lwp *, void *, register_t *); +int compat_43_sys_send(struct lwp *, void *, register_t *); +int compat_43_sys_recv(struct lwp *, void *, register_t *); +int compat_13_sys_sigreturn(struct lwp *, void *, register_t *); +int sys_bind(struct lwp *, void *, register_t *); +int sys_setsockopt(struct lwp *, void *, register_t *); +int sys_listen(struct lwp *, void *, register_t *); +int compat_43_sys_sigvec(struct lwp *, void *, register_t *); +int compat_43_sys_sigblock(struct lwp *, void *, register_t *); +int compat_43_sys_sigsetmask(struct lwp *, void *, register_t *); +int compat_13_sys_sigsuspend(struct lwp *, void *, register_t *); +int compat_43_sys_sigstack(struct lwp *, void *, register_t *); +int compat_43_sys_recvmsg(struct lwp *, void *, register_t *); +int compat_43_sys_sendmsg(struct lwp *, void *, register_t *); +int sys_gettimeofday(struct lwp *, void *, register_t *); +int sys_getrusage(struct lwp *, void *, register_t *); +int sys_getsockopt(struct lwp *, void *, register_t *); +int sys_readv(struct lwp *, void *, register_t *); +int sys_writev(struct lwp *, void *, register_t *); +int sys_settimeofday(struct lwp *, void *, register_t *); +int sys_fchown(struct lwp *, void *, register_t *); +int sys_fchmod(struct lwp *, void *, register_t *); +int compat_43_sys_recvfrom(struct lwp *, void *, register_t *); +int sys_setreuid(struct lwp *, void *, register_t *); +int sys_setregid(struct lwp *, void *, register_t *); +int sys_rename(struct lwp *, void *, register_t *); +int compat_43_sys_truncate(struct lwp *, void *, register_t *); +int compat_43_sys_ftruncate(struct lwp *, void *, register_t *); +int sys_flock(struct lwp *, void *, register_t *); +int sys_mkfifo(struct lwp *, void *, register_t *); +int sys_sendto(struct lwp *, void *, register_t *); +int sys_shutdown(struct lwp *, void *, register_t *); +int sys_socketpair(struct lwp *, void *, register_t *); +int sys_mkdir(struct lwp *, void *, register_t *); +int sys_rmdir(struct lwp *, void *, register_t *); +int sys_utimes(struct lwp *, void *, register_t *); +int sys_adjtime(struct lwp *, void *, register_t *); +int compat_43_sys_getpeername(struct lwp *, void *, register_t *); +int compat_43_sys_gethostid(struct lwp *, void *, register_t *); +int compat_43_sys_sethostid(struct lwp *, void *, register_t *); +int compat_43_sys_getrlimit(struct lwp *, void *, register_t *); +int compat_43_sys_setrlimit(struct lwp *, void *, register_t *); +int compat_43_sys_killpg(struct lwp *, void *, register_t *); +int sys_setsid(struct lwp *, void *, register_t *); +int sys_quotactl(struct lwp *, void *, register_t *); +int compat_43_sys_quota(struct lwp *, void *, register_t *); +int compat_43_sys_getsockname(struct lwp *, void *, register_t *); #if defined(NFS) || defined(NFSSERVER) || !defined(_KERNEL) -int sys_nfssvc(struct proc *, void *, register_t *); +int sys_nfssvc(struct lwp *, void *, register_t *); #else #endif -int compat_43_sys_getdirentries(struct proc *, void *, register_t *); -int sys_statfs(struct proc *, void *, register_t *); -int sys_fstatfs(struct proc *, void *, register_t *); -int sys_getfh(struct proc *, void *, register_t *); -int compat_09_sys_getdomainname(struct proc *, void *, register_t *); -int compat_09_sys_setdomainname(struct proc *, void *, register_t *); -int compat_09_sys_uname(struct proc *, void *, register_t *); -int sys_sysarch(struct proc *, void *, register_t *); +int compat_43_sys_getdirentries(struct lwp *, void *, register_t *); +int sys_statfs(struct lwp *, void *, register_t *); +int sys_fstatfs(struct lwp *, void *, register_t *); +int sys_getfh(struct lwp *, void *, register_t *); +int compat_09_sys_getdomainname(struct lwp *, void *, register_t *); +int compat_09_sys_setdomainname(struct lwp *, void *, register_t *); +int compat_09_sys_uname(struct lwp *, void *, register_t *); +int sys_sysarch(struct lwp *, void *, register_t *); #if (defined(SYSVSEM) || !defined(_KERNEL)) && !defined(alpha) -int compat_10_sys_semsys(struct proc *, void *, register_t *); +int compat_10_sys_semsys(struct lwp *, void *, register_t *); #else #endif #if (defined(SYSVMSG) || !defined(_KERNEL)) && !defined(alpha) -int compat_10_sys_msgsys(struct proc *, void *, register_t *); +int compat_10_sys_msgsys(struct lwp *, void *, register_t *); #else #endif #if (defined(SYSVSHM) || !defined(_KERNEL)) && !defined(alpha) -int compat_10_sys_shmsys(struct proc *, void *, register_t *); +int compat_10_sys_shmsys(struct lwp *, void *, register_t *); #else #endif -int sys_pread(struct proc *, void *, register_t *); -int sys_pwrite(struct proc *, void *, register_t *); -int sys_ntp_gettime(struct proc *, void *, register_t *); +int sys_pread(struct lwp *, void *, register_t *); +int sys_pwrite(struct lwp *, void *, register_t *); +int sys_ntp_gettime(struct lwp *, void *, register_t *); #if defined(NTP) || !defined(_KERNEL) -int sys_ntp_adjtime(struct proc *, void *, register_t *); +int sys_ntp_adjtime(struct lwp *, void *, register_t *); #else #endif -int sys_setgid(struct proc *, void *, register_t *); -int sys_setegid(struct proc *, void *, register_t *); -int sys_seteuid(struct proc *, void *, register_t *); +int sys_setgid(struct lwp *, void *, register_t *); +int sys_setegid(struct lwp *, void *, register_t *); +int sys_seteuid(struct lwp *, void *, register_t *); #if defined(LFS) || !defined(_KERNEL) -int sys_lfs_bmapv(struct proc *, void *, register_t *); -int sys_lfs_markv(struct proc *, void *, register_t *); -int sys_lfs_segclean(struct proc *, void *, register_t *); -int sys_lfs_segwait(struct proc *, void *, register_t *); +int sys_lfs_bmapv(struct lwp *, void *, register_t *); +int sys_lfs_markv(struct lwp *, void *, register_t *); +int sys_lfs_segclean(struct lwp *, void *, register_t *); +int sys_lfs_segwait(struct lwp *, void *, register_t *); #else #endif -int compat_12_sys_stat(struct proc *, void *, register_t *); -int compat_12_sys_fstat(struct proc *, void *, register_t *); -int compat_12_sys_lstat(struct proc *, void *, register_t *); -int sys_pathconf(struct proc *, void *, register_t *); -int sys_fpathconf(struct proc *, void *, register_t *); -int sys_getrlimit(struct proc *, void *, register_t *); -int sys_setrlimit(struct proc *, void *, register_t *); -int compat_12_sys_getdirentries(struct proc *, void *, register_t *); -int sys_mmap(struct proc *, void *, register_t *); -int sys_lseek(struct proc *, void *, register_t *); -int sys_truncate(struct proc *, void *, register_t *); -int sys_ftruncate(struct proc *, void *, register_t *); -int sys___sysctl(struct proc *, void *, register_t *); -int sys_mlock(struct proc *, void *, register_t *); -int sys_munlock(struct proc *, void *, register_t *); -int sys_undelete(struct proc *, void *, register_t *); -int sys_futimes(struct proc *, void *, register_t *); -int sys_getpgid(struct proc *, void *, register_t *); -int sys_reboot(struct proc *, void *, register_t *); -int sys_poll(struct proc *, void *, register_t *); +int compat_12_sys_stat(struct lwp *, void *, register_t *); +int compat_12_sys_fstat(struct lwp *, void *, register_t *); +int compat_12_sys_lstat(struct lwp *, void *, register_t *); +int sys_pathconf(struct lwp *, void *, register_t *); +int sys_fpathconf(struct lwp *, void *, register_t *); +int sys_getrlimit(struct lwp *, void *, register_t *); +int sys_setrlimit(struct lwp *, void *, register_t *); +int compat_12_sys_getdirentries(struct lwp *, void *, register_t *); +int sys_mmap(struct lwp *, void *, register_t *); +int sys_lseek(struct lwp *, void *, register_t *); +int sys_truncate(struct lwp *, void *, register_t *); +int sys_ftruncate(struct lwp *, void *, register_t *); +int sys___sysctl(struct lwp *, void *, register_t *); +int sys_mlock(struct lwp *, void *, register_t *); +int sys_munlock(struct lwp *, void *, register_t *); +int sys_undelete(struct lwp *, void *, register_t *); +int sys_futimes(struct lwp *, void *, register_t *); +int sys_getpgid(struct lwp *, void *, register_t *); +int sys_reboot(struct lwp *, void *, register_t *); +int sys_poll(struct lwp *, void *, register_t *); #if defined(LKM) || !defined(_KERNEL) -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); -int sys_lkmnosys(struct proc *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); +int sys_lkmnosys(struct lwp *, void *, register_t *); #else /* !LKM */ #endif /* !LKM */ #if defined(SYSVSEM) || !defined(_KERNEL) -int compat_14_sys___semctl(struct proc *, void *, register_t *); -int sys_semget(struct proc *, void *, register_t *); -int sys_semop(struct proc *, void *, register_t *); -int sys_semconfig(struct proc *, void *, register_t *); +int compat_14_sys___semctl(struct lwp *, void *, register_t *); +int sys_semget(struct lwp *, void *, register_t *); +int sys_semop(struct lwp *, void *, register_t *); +int sys_semconfig(struct lwp *, void *, register_t *); #else #endif #if defined(SYSVMSG) || !defined(_KERNEL) -int compat_14_sys_msgctl(struct proc *, void *, register_t *); -int sys_msgget(struct proc *, void *, register_t *); -int sys_msgsnd(struct proc *, void *, register_t *); -int sys_msgrcv(struct proc *, void *, register_t *); +int compat_14_sys_msgctl(struct lwp *, void *, register_t *); +int sys_msgget(struct lwp *, void *, register_t *); +int sys_msgsnd(struct lwp *, void *, register_t *); +int sys_msgrcv(struct lwp *, void *, register_t *); #else #endif #if defined(SYSVSHM) || !defined(_KERNEL) -int sys_shmat(struct proc *, void *, register_t *); -int compat_14_sys_shmctl(struct proc *, void *, register_t *); -int sys_shmdt(struct proc *, void *, register_t *); -int sys_shmget(struct proc *, void *, register_t *); +int sys_shmat(struct lwp *, void *, register_t *); +int compat_14_sys_shmctl(struct lwp *, void *, register_t *); +int sys_shmdt(struct lwp *, void *, register_t *); +int sys_shmget(struct lwp *, void *, register_t *); #else #endif -int sys_clock_gettime(struct proc *, void *, register_t *); -int sys_clock_settime(struct proc *, void *, register_t *); -int sys_clock_getres(struct proc *, void *, register_t *); -int sys_nanosleep(struct proc *, void *, register_t *); -int sys_fdatasync(struct proc *, void *, register_t *); -int sys_mlockall(struct proc *, void *, register_t *); -int sys_munlockall(struct proc *, void *, register_t *); -int sys___posix_rename(struct proc *, void *, register_t *); -int sys_swapctl(struct proc *, void *, register_t *); -int sys_getdents(struct proc *, void *, register_t *); -int sys_minherit(struct proc *, void *, register_t *); -int sys_lchmod(struct proc *, void *, register_t *); -int sys_lchown(struct proc *, void *, register_t *); -int sys_lutimes(struct proc *, void *, register_t *); -int sys___msync13(struct proc *, void *, register_t *); -int sys___stat13(struct proc *, void *, register_t *); -int sys___fstat13(struct proc *, void *, register_t *); -int sys___lstat13(struct proc *, void *, register_t *); -int sys___sigaltstack14(struct proc *, void *, register_t *); -int sys___vfork14(struct proc *, void *, register_t *); -int sys___posix_chown(struct proc *, void *, register_t *); -int sys___posix_fchown(struct proc *, void *, register_t *); -int sys___posix_lchown(struct proc *, void *, register_t *); -int sys_getsid(struct proc *, void *, register_t *); +int sys_clock_gettime(struct lwp *, void *, register_t *); +int sys_clock_settime(struct lwp *, void *, register_t *); +int sys_clock_getres(struct lwp *, void *, register_t *); +int sys_nanosleep(struct lwp *, void *, register_t *); +int sys_fdatasync(struct lwp *, void *, register_t *); +int sys_mlockall(struct lwp *, void *, register_t *); +int sys_munlockall(struct lwp *, void *, register_t *); +int sys___posix_rename(struct lwp *, void *, register_t *); +int sys_swapctl(struct lwp *, void *, register_t *); +int sys_getdents(struct lwp *, void *, register_t *); +int sys_minherit(struct lwp *, void *, register_t *); +int sys_lchmod(struct lwp *, void *, register_t *); +int sys_lchown(struct lwp *, void *, register_t *); +int sys_lutimes(struct lwp *, void *, register_t *); +int sys___msync13(struct lwp *, void *, register_t *); +int sys___stat13(struct lwp *, void *, register_t *); +int sys___fstat13(struct lwp *, void *, register_t *); +int sys___lstat13(struct lwp *, void *, register_t *); +int sys___sigaltstack14(struct lwp *, void *, register_t *); +int sys___vfork14(struct lwp *, void *, register_t *); +int sys___posix_chown(struct lwp *, void *, register_t *); +int sys___posix_fchown(struct lwp *, void *, register_t *); +int sys___posix_lchown(struct lwp *, void *, register_t *); +int sys_getsid(struct lwp *, void *, register_t *); #if defined(KTRACE) || !defined(_KERNEL) -int sys_fktrace(struct proc *, void *, register_t *); +int sys_fktrace(struct lwp *, void *, register_t *); #else #endif -int sys_preadv(struct proc *, void *, register_t *); -int sys_pwritev(struct proc *, void *, register_t *); -int sys___sigaction14(struct proc *, void *, register_t *); -int sys___sigpending14(struct proc *, void *, register_t *); -int sys___sigprocmask14(struct proc *, void *, register_t *); -int sys___sigsuspend14(struct proc *, void *, register_t *); -int sys___sigreturn14(struct proc *, void *, register_t *); -int sys___getcwd(struct proc *, void *, register_t *); -int sys_fchroot(struct proc *, void *, register_t *); -int sys_fhopen(struct proc *, void *, register_t *); -int sys_fhstat(struct proc *, void *, register_t *); -int sys_fhstatfs(struct proc *, void *, register_t *); +int sys_preadv(struct lwp *, void *, register_t *); +int sys_pwritev(struct lwp *, void *, register_t *); +int sys___sigaction14(struct lwp *, void *, register_t *); +int sys___sigpending14(struct lwp *, void *, register_t *); +int sys___sigprocmask14(struct lwp *, void *, register_t *); +int sys___sigsuspend14(struct lwp *, void *, register_t *); +int sys___sigreturn14(struct lwp *, void *, register_t *); +int sys___getcwd(struct lwp *, void *, register_t *); +int sys_fchroot(struct lwp *, void *, register_t *); +int sys_fhopen(struct lwp *, void *, register_t *); +int sys_fhstat(struct lwp *, void *, register_t *); +int sys_fhstatfs(struct lwp *, void *, register_t *); #if defined(SYSVSEM) || !defined(_KERNEL) -int sys_____semctl13(struct proc *, void *, register_t *); +int sys_____semctl13(struct lwp *, void *, register_t *); #else #endif #if defined(SYSVMSG) || !defined(_KERNEL) -int sys___msgctl13(struct proc *, void *, register_t *); +int sys___msgctl13(struct lwp *, void *, register_t *); #else #endif #if defined(SYSVSHM) || !defined(_KERNEL) -int sys___shmctl13(struct proc *, void *, register_t *); +int sys___shmctl13(struct lwp *, void *, register_t *); #else #endif -int sys_lchflags(struct proc *, void *, register_t *); -int sys_issetugid(struct proc *, void *, register_t *); -int sys_utrace(struct proc *, void *, register_t *); +int sys_lchflags(struct lwp *, void *, register_t *); +int sys_issetugid(struct lwp *, void *, register_t *); +int sys_utrace(struct lwp *, void *, register_t *); +int sys_getcontext(struct lwp *, void *, register_t *); +int sys_setcontext(struct lwp *, void *, register_t *); +int sys__lwp_create(struct lwp *, void *, register_t *); +int sys__lwp_exit(struct lwp *, void *, register_t *); +int sys__lwp_self(struct lwp *, void *, register_t *); +int sys__lwp_wait(struct lwp *, void *, register_t *); +int sys__lwp_suspend(struct lwp *, void *, register_t *); +int sys__lwp_continue(struct lwp *, void *, register_t *); +int sys_sa_register(struct lwp *, void *, register_t *); +int sys_sa_stacks(struct lwp *, void *, register_t *); +int sys_sa_enable(struct lwp *, void *, register_t *); +int sys_sa_setconcurrency(struct lwp *, void *, register_t *); +int sys_sa_yield(struct lwp *, void *, register_t *); +int sys_sa_preempt(struct lwp *, void *, register_t *); #endif /* _SYS__SYSCALLARGS_H_ */ Index: sys/sys/sysctl.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/sys/sysctl.h,v retrieving revision 1.60 retrieving revision 1.60.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.60 -r1.60.2.1 --- sys/sys/sysctl.h 2001/01/09 21:30:25 1.60 +++ sys/sys/sysctl.h 2001/03/05 22:50:04 1.60.2.1 @@ -45,8 +45,10 @@ * These are for the eproc structure defined below. */ #include #include +#include +#include #include #include /* Index: sys/sys/systm.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/sys/systm.h,v retrieving revision 1.125 retrieving revision 1.125.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.125 -r1.125.2.1 --- sys/sys/systm.h 2001/01/27 07:21:43 1.125 +++ sys/sys/systm.h 2001/03/05 22:50:04 1.125.2.1 @@ -126,9 +126,9 @@ */ extern dev_t swapdev; /* swapping device */ extern struct vnode *swapdev_vp;/* vnode equivalent to above */ -typedef int sy_call_t(struct proc *, void *, register_t *); +typedef int sy_call_t(struct lwp *, void *, register_t *); extern struct sysent { /* system call table */ short sy_narg; /* number of args */ short sy_argsize; /* total size of arguments */ @@ -180,9 +180,9 @@ void *hashinit __P((int, enum hashtype, int, int, u_long *)); void hashdone __P((void *, int)); int seltrue __P((dev_t dev, int events, struct proc *p)); -int sys_nosys __P((struct proc *, void *, register_t *)); +int sys_nosys __P((struct lwp *, void *, register_t *)); void printf __P((const char *, ...)) __attribute__((__format__(__printf__,1,2))); Index: sys/sys/types.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/sys/types.h,v retrieving revision 1.48 retrieving revision 1.48.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.48 -r1.48.2.1 --- sys/sys/types.h 2000/12/18 21:20:35 1.48 +++ sys/sys/types.h 2001/03/05 22:50:04 1.48.2.1 @@ -98,9 +98,9 @@ #ifndef pid_t typedef __pid_t pid_t; /* process id */ #define pid_t __pid_t #endif - +typedef int32_t lwpid_t; /* LWP id */ typedef quad_t rlim_t; /* resource limit */ typedef int32_t segsz_t; /* segment size */ typedef int32_t swblk_t; /* swap offset */ typedef u_int32_t uid_t; /* user id */ @@ -116,8 +116,9 @@ int val; /* value for SETVAL */ struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */ unsigned short *array; /* array for GETALL & SETALL */ }; + #endif /* _KERNEL || _LIBC */ /* * These belong in unistd.h, but are placed here too to ensure that @@ -250,8 +251,11 @@ * Forward structure declarations for function prototypes. We include the * common structures that cross subsystem boundaries here; others are mostly * used in the same place that the structure is defined. */ +struct lwp; +struct user; +struct __ucontext; struct proc; struct pgrp; struct ucred; struct rusage; Index: sys/sys/ucontext.h =================================================================== RCS file: ucontext.h diff -N ucontext.h --- /dev/null Tue Apr 24 13:41:34 2001 +++ /tmp/cvsQFnVuG5gAt Tue Apr 24 17:08:23 2001 @@ -0,0 +1,76 @@ +/* $NetBSD: ucontext.h,v 1.1.2.1 2001/03/05 22:50:04 nathanw Exp $ */ + +/*- + * Copyright (c) 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus Klein. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_UCONTEXT_H_ +#define _SYS_UCONTEXT_H_ + +#include +#ifndef _KERNEL +#include /* FIXME: too much. */ +#endif + +typedef struct __ucontext ucontext_t; + +struct __ucontext { + unsigned int uc_flags; /* properties */ + ucontext_t * uc_link; /* context to resume */ + sigset_t uc_sigmask; /* signals blocked in this context */ + stack_t uc_stack; /* the stack used by this context */ + mcontext_t uc_mcontext; /* machine state */ +#if defined(_UC_MACHINE_PAD) + long __uc_pad[_UC_MACHINE_PAD]; +#endif +}; + +/* uc_flags */ +#define _UC_SIGMASK 0x01 /* valid uc_sigmask */ +#define _UC_STACK 0x02 /* valid uc_stack */ +#define _UC_CPU 0x04 /* valid GPR context in uc_mcontext */ +#define _UC_FPU 0x08 /* valid FPU context in uc_mcontext */ + +#ifdef _KERNEL +#include + +struct lwp; +void getucontext(struct lwp *, ucontext_t *); +int setucontext(struct lwp *, const ucontext_t *); +void cpu_getmcontext(struct lwp *, mcontext_t *, unsigned int *); +int cpu_setmcontext(struct lwp *, const mcontext_t *, unsigned int); +#endif /* _KERNEL */ + +#endif /* !_SYS_UCONTEXT_H_ */ Index: sys/sys/user.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/sys/user.h,v retrieving revision 1.13 retrieving revision 1.13.14.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.13 -r1.13.14.1 --- sys/sys/user.h 1999/04/30 21:23:50 1.13 +++ sys/sys/user.h 2001/03/05 22:50:04 1.13.14.1 @@ -60,8 +60,7 @@ struct user { struct pcb u_pcb; - struct pstats u_stats; /* p_stats points here (use it!) */ }; #endif /* !_SYS_USER_H_ */ Index: sys/ufs/ext2fs/ext2fs_bmap.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/ext2fs/ext2fs_bmap.c,v retrieving revision 1.5 retrieving revision 1.5.6.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.5 -r1.5.6.1 --- sys/ufs/ext2fs/ext2fs_bmap.c 2000/03/30 12:41:11 1.5 +++ sys/ufs/ext2fs/ext2fs_bmap.c 2001/03/05 22:50:04 1.5.6.1 @@ -44,8 +44,9 @@ #include #include #include +#include #include #include #include #include @@ -205,9 +206,9 @@ trace(TR_BREADMISS, pack(vp, size), metalbn); bp->b_blkno = blkptrtodb(ump, daddr); bp->b_flags |= B_READ; VOP_STRATEGY(bp); - curproc->p_stats->p_ru.ru_inblock++; /* XXX */ + curproc->l_proc->p_stats->p_ru.ru_inblock++; /* XXX */ if ((error = biowait(bp)) != 0) { brelse(bp); return (error); } Index: sys/ufs/ext2fs/ext2fs_inode.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/ext2fs/ext2fs_inode.c,v retrieving revision 1.23 retrieving revision 1.23.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.23 -r1.23.2.1 --- sys/ufs/ext2fs/ext2fs_inode.c 2001/02/18 20:17:04 1.23 +++ sys/ufs/ext2fs/ext2fs_inode.c 2001/03/05 22:50:05 1.23.2.1 @@ -39,8 +39,9 @@ #include #include #include +#include #include #include #include #include @@ -414,9 +415,9 @@ /* Braces must be here in case trace evaluates to nothing. */ trace(TR_BREADHIT, pack(vp, fs->e2fs_bsize), lbn); } else { trace(TR_BREADMISS, pack(vp, fs->e2fs_bsize), lbn); - curproc->p_stats->p_ru.ru_inblock++; /* pay for read */ + curproc->l_proc->p_stats->p_ru.ru_inblock++; /* pay for read */ bp->b_flags |= B_READ; if (bp->b_bcount > bp->b_bufsize) panic("ext2fs_indirtrunc: bad buffer size"); bp->b_blkno = dbn; Index: sys/ufs/ext2fs/ext2fs_vfsops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/ext2fs/ext2fs_vfsops.c,v retrieving revision 1.42 retrieving revision 1.42.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.42 -r1.42.2.1 --- sys/ufs/ext2fs/ext2fs_vfsops.c 2001/01/22 12:17:42 1.42 +++ sys/ufs/ext2fs/ext2fs_vfsops.c 2001/03/05 22:50:05 1.42.2.1 @@ -43,8 +43,9 @@ #include #include #include +#include #include #include #include #include @@ -143,9 +144,9 @@ { extern struct vnode *rootvp; struct m_ext2fs *fs; struct mount *mp; - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ struct ufsmount *ump; int error; if (root_device->dv_class != DV_DISK) Index: sys/ufs/ffs/ffs_alloc.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/ffs/ffs_alloc.c,v retrieving revision 1.42 retrieving revision 1.41.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.42 -r1.41.2.2 --- sys/ufs/ffs/ffs_alloc.c 2001/03/13 21:16:23 1.42 +++ sys/ufs/ffs/ffs_alloc.c 2001/04/09 01:59:06 1.41.2.2 @@ -1816,6 +1816,6 @@ char *cp; { log(LOG_ERR, "uid %d comm %s on %s: %s\n", - uid, curproc->p_comm, fs->fs_fsmnt, cp); + uid, curproc->l_proc->p_comm, fs->fs_fsmnt, cp); } Index: sys/ufs/ffs/ffs_balloc.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/ffs/ffs_balloc.c,v retrieving revision 1.23 retrieving revision 1.23.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.23 -r1.23.2.1 --- sys/ufs/ffs/ffs_balloc.c 2000/11/27 08:39:54 1.23 +++ sys/ufs/ffs/ffs_balloc.c 2001/03/05 22:50:05 1.23.2.1 @@ -41,8 +41,9 @@ #include #include #include +#include #include #include #include #include @@ -413,9 +414,9 @@ * slow, running out of disk space is not expected to be a common * occurence. The error return from fsync is ignored as we already * have an error to return to the user. */ - (void) VOP_FSYNC(vp, cred, FSYNC_WAIT, 0, 0, curproc); + (void) VOP_FSYNC(vp, cred, FSYNC_WAIT, 0, 0, curproc->l_proc); for (deallocated = 0, blkp = allociblk; blkp < allocblk; blkp++) { ffs_blkfree(ip, *blkp, fs->fs_bsize); deallocated += fs->fs_bsize; } @@ -455,9 +456,9 @@ #endif ip->i_ffs_blocks -= btodb(deallocated); ip->i_flag |= IN_CHANGE | IN_UPDATE; } - (void) VOP_FSYNC(vp, cred, FSYNC_WAIT, 0, 0, curproc); + (void) VOP_FSYNC(vp, cred, FSYNC_WAIT, 0, 0, curproc->l_proc); return (error); } Index: sys/ufs/ffs/ffs_inode.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/ffs/ffs_inode.c,v retrieving revision 1.40 retrieving revision 1.40.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.40 -r1.40.2.1 --- sys/ufs/ffs/ffs_inode.c 2001/01/27 04:23:21 1.40 +++ sys/ufs/ffs/ffs_inode.c 2001/03/05 22:50:06 1.40.2.1 @@ -42,8 +42,9 @@ #include #include #include +#include #include #include #include #include @@ -477,9 +478,9 @@ /* Braces must be here in case trace evaluates to nothing. */ trace(TR_BREADHIT, pack(vp, fs->fs_bsize), lbn); } else { trace(TR_BREADMISS, pack(vp, fs->fs_bsize), lbn); - curproc->p_stats->p_ru.ru_inblock++; /* pay for read */ + curproc->l_proc->p_stats->p_ru.ru_inblock++; /* pay for read */ bp->b_flags |= B_READ; if (bp->b_bcount > bp->b_bufsize) panic("ffs_indirtrunc: bad buffer size"); bp->b_blkno = dbn; Index: sys/ufs/ffs/ffs_softdep.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/ffs/ffs_softdep.c,v retrieving revision 1.13 retrieving revision 1.13.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.13 -r1.13.2.1 --- sys/ufs/ffs/ffs_softdep.c 2001/01/10 04:47:10 1.13 +++ sys/ufs/ffs/ffs_softdep.c 2001/03/05 22:50:06 1.13.2.1 @@ -37,8 +37,9 @@ #include #include #include #include +#include #include #include #include #include @@ -95,10 +96,10 @@ #define DtoM(type) (type) /* * Finding the current process. */ -#define CURPROC curproc -#define CURPROC_PID (curproc ? curproc->p_pid : 0) +#define CURPROC (curproc ? curproc->l_proc : 0) +#define CURPROC_PID (curproc ? curproc->l_proc->p_pid : 0) /* * End system adaptaion definitions. */ @@ -4940,10 +4941,10 @@ LIST_FIRST(&bp->b_dep)->wk_type != D_ALLOCINDIR) { continue; } - VOP_FSYNC(bp->b_vp, curproc->p_ucred, FSYNC_WAIT, 0, 0, - curproc); + VOP_FSYNC(bp->b_vp, curproc->l_proc->p_ucred, + FSYNC_WAIT, 0, 0, curproc->l_proc); return; } } printf("softdep_flush_indir: nothing to flush?\n"); Index: sys/ufs/ffs/ffs_vfsops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/ffs/ffs_vfsops.c,v retrieving revision 1.80 retrieving revision 1.80.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.80 -r1.80.2.1 --- sys/ufs/ffs/ffs_vfsops.c 2001/02/07 22:40:06 1.80 +++ sys/ufs/ffs/ffs_vfsops.c 2001/03/05 22:50:06 1.80.2.1 @@ -44,8 +44,9 @@ #include #include #include +#include #include #include #include #include @@ -120,9 +121,9 @@ ffs_mountroot() { struct fs *fs; struct mount *mp; - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ struct ufsmount *ump; int error; if (root_device->dv_class != DV_DISK) Index: sys/ufs/lfs/lfs_balloc.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/lfs/lfs_balloc.c,v retrieving revision 1.27 retrieving revision 1.27.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.27 -r1.27.2.1 --- sys/ufs/lfs/lfs_balloc.c 2000/11/21 00:00:31 1.27 +++ sys/ufs/lfs/lfs_balloc.c 2001/03/05 22:50:07 1.27.2.1 @@ -358,18 +358,18 @@ */ top: lfs_seglock(fs, SEGM_PROT); - if (!ISSPACE(fs, bb, curproc->p_ucred)) { + if (!ISSPACE(fs, bb, curproc->l_proc->p_ucred)) { error = ENOSPC; goto out; } if ((error = bread(vp, lbn, osize, NOCRED, bpp))) { brelse(*bpp); goto out; } #ifdef QUOTA - if ((error = chkdq(ip, bb, curproc->p_ucred, 0))) { + if ((error = chkdq(ip, bb, curproc->l_proc->p_ucred, 0))) { brelse(*bpp); goto out; } #endif @@ -382,9 +382,9 @@ if ((*bpp)->b_flags & B_DELWRI) { if (!lfs_fits(fs, bb)) { brelse(*bpp); #ifdef QUOTA - chkdq(ip, -bb, curproc->p_ucred, 0); + chkdq(ip, -bb, curproc->l_proc->p_ucred, 0); #endif lfs_segunlock(fs); lfs_availwait(fs, bb); goto top; Index: sys/ufs/lfs/lfs_bio.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/lfs/lfs_bio.c,v retrieving revision 1.35 retrieving revision 1.35.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.35 -r1.35.2.1 --- sys/ufs/lfs/lfs_bio.c 2000/12/03 06:43:36 1.35 +++ sys/ufs/lfs/lfs_bio.c 2001/03/05 22:50:07 1.35.2.1 @@ -238,9 +238,10 @@ wakeup(&lfs_allclean_wakeup); wakeup(&fs->lfs_nextseg); #ifdef DIAGNOSTIC - if (fs->lfs_seglock && fs->lfs_lockpid == curproc->p_pid) + if (fs->lfs_seglock && + fs->lfs_lockpid == curproc->l_proc->p_pid) panic("lfs_availwait: deadlock"); #endif error = tsleep(&fs->lfs_avail, PCATCH | PUSER, "cleaner", 0); if (error) Index: sys/ufs/lfs/lfs_segment.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/lfs/lfs_segment.c,v retrieving revision 1.67 retrieving revision 1.67.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.67 -r1.67.2.1 --- sys/ufs/lfs/lfs_segment.c 2001/01/09 05:05:35 1.67 +++ sys/ufs/lfs/lfs_segment.c 2001/03/05 22:50:07 1.67.2.1 @@ -411,9 +411,9 @@ needs_unlock = 0; if (VOP_ISLOCKED(vp)) { if (vp != fs->lfs_ivnode && - vp->v_lock.lk_lockholder != curproc->p_pid) { + vp->v_lock.lk_lockholder != curproc->l_proc->p_pid) { #ifdef DEBUG_LFS printf("lfs_writevnodes: not writing ino %d," " locked by pid %d\n", VTOI(vp)->i_number, Index: sys/ufs/lfs/lfs_subr.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/lfs/lfs_subr.c,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.17 -r1.17.2.1 --- sys/ufs/lfs/lfs_subr.c 2000/09/09 04:49:55 1.17 +++ sys/ufs/lfs/lfs_subr.c 2001/03/05 22:50:07 1.17.2.1 @@ -134,9 +134,9 @@ struct segment *sp; int s; if (fs->lfs_seglock) { - if (fs->lfs_lockpid == curproc->p_pid) { + if (fs->lfs_lockpid == curproc->l_proc->p_pid) { ++fs->lfs_seglock; fs->lfs_sp->seg_flags |= flags; return; } else while (fs->lfs_seglock) @@ -144,9 +144,9 @@ "lfs seglock", 0); } fs->lfs_seglock = 1; - fs->lfs_lockpid = curproc->p_pid; + fs->lfs_lockpid = curproc->l_proc->p_pid; sp = fs->lfs_sp = malloc(sizeof(struct segment), M_SEGMENT, M_WAITOK); sp->bpp = malloc(((LFS_SUMMARY_SIZE - sizeof(SEGSUM)) / sizeof(ufs_daddr_t) + 1) * sizeof(struct buf *), @@ -215,9 +215,9 @@ continue; if (lfs_vref(vp)) continue; if (VOP_ISLOCKED(vp) && - vp->v_lock.lk_lockholder != curproc->p_pid) { + vp->v_lock.lk_lockholder != curproc->l_proc->p_pid) { lfs_vunref(vp); continue; } if ((vp->v_flag & VDIROP) && Index: sys/ufs/lfs/lfs_syscalls.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/lfs/lfs_syscalls.c,v retrieving revision 1.56 retrieving revision 1.56.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.56 -r1.56.2.1 --- sys/ufs/lfs/lfs_syscalls.c 2000/12/03 07:34:49 1.56 +++ sys/ufs/lfs/lfs_syscalls.c 2001/03/05 22:50:08 1.56.2.1 @@ -134,18 +134,19 @@ * 0 on success * -1/errno is return on error. */ int -sys_lfs_markv(p, v, retval) - struct proc *p; +sys_lfs_markv(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_lfs_markv_args /* { syscallarg(fsid_t *) fsidp; syscallarg(struct block_info *) blkiov; syscallarg(int) blkcnt; } */ *uap = v; + struct proc *p = l->l_proc; BLOCK_INFO *blkp; IFILE *ifp; struct buf *bp, *nbp; struct inode *ip = NULL; @@ -540,18 +541,19 @@ * -1/errno is return on error. */ int -sys_lfs_bmapv(p, v, retval) - struct proc *p; +sys_lfs_bmapv(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_lfs_bmapv_args /* { syscallarg(fsid_t *) fsidp; syscallarg(struct block_info *) blkiov; syscallarg(int) blkcnt; } */ *uap = v; + struct proc *p = l->l_proc; BLOCK_INFO *blkp; IFILE *ifp; struct buf *bp; struct inode *ip = NULL; @@ -773,17 +775,18 @@ * 0 on success * -1/errno is return on error. */ int -sys_lfs_segclean(p, v, retval) - struct proc *p; +sys_lfs_segclean(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_lfs_segclean_args /* { syscallarg(fsid_t *) fsidp; syscallarg(u_long) segment; } */ *uap = v; + struct proc *p = l->l_proc; CLEANERINFO *cip; SEGUSE *sup; struct buf *bp; struct mount *mntp; @@ -854,17 +857,18 @@ * 1 on timeout * -1/errno is return on error. */ int -sys_lfs_segwait(p, v, retval) - struct proc *p; +sys_lfs_segwait(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_lfs_segwait_args /* { syscallarg(fsid_t *) fsidp; syscallarg(struct timeval *) tv; } */ *uap = v; + struct proc *p = l->l_proc; extern int lfs_allclean_wakeup; struct mount *mntp; struct timeval atv; fsid_t fsid; Index: sys/ufs/lfs/lfs_vfsops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/lfs/lfs_vfsops.c,v retrieving revision 1.64 retrieving revision 1.64.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.64 -r1.64.2.1 --- sys/ufs/lfs/lfs_vfsops.c 2001/01/26 07:59:23 1.64 +++ sys/ufs/lfs/lfs_vfsops.c 2001/03/05 22:50:08 1.64.2.1 @@ -172,9 +172,9 @@ lfs_mountroot() { extern struct vnode *rootvp; struct mount *mp; - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ int error; if (root_device->dv_class != DV_DISK) return (ENODEV); @@ -1198,9 +1198,10 @@ /* * If the filesystem is not completely mounted yet, suspend * any access requests (wait for roll-forward to complete). */ - while((fs->lfs_flags & LFS_NOTYET) && curproc->p_pid != fs->lfs_rfpid) + while((fs->lfs_flags & LFS_NOTYET) && + curproc->l_proc->p_pid != fs->lfs_rfpid) tsleep(&fs->lfs_flags, PRIBIO+1, "lfs_notyet", 0); if ((*vpp = ufs_ihashget(dev, ino, LK_EXCLUSIVE)) != NULL) return (0); Index: sys/ufs/lfs/lfs_vnops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/lfs/lfs_vnops.c,v retrieving revision 1.50 retrieving revision 1.50.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.50 -r1.50.2.1 --- sys/ufs/lfs/lfs_vnops.c 2001/01/22 12:17:43 1.50 +++ sys/ufs/lfs/lfs_vnops.c 2001/03/05 22:50:08 1.50.2.1 @@ -497,9 +497,10 @@ * XXX KS - If we can't flush we also can't call vgone(), so must * return. But, that leaves this vnode in limbo, also not good. * Can this ever happen (barring hardware failure)? */ - if ((error = VOP_FSYNC(*vpp, NOCRED, FSYNC_WAIT, 0, 0, curproc)) != 0) { + if ((error = VOP_FSYNC(*vpp, NOCRED, FSYNC_WAIT, 0, 0, + curproc->l_proc)) != 0) { printf("Couldn't fsync in mknod (ino %d)---what do I do?\n", VTOI(*vpp)->i_number); return (error); } Index: sys/ufs/mfs/mfs_vfsops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/mfs/mfs_vfsops.c,v retrieving revision 1.32 retrieving revision 1.32.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.32 -r1.32.2.1 --- sys/ufs/mfs/mfs_vfsops.c 2001/02/24 00:05:22 1.32 +++ sys/ufs/mfs/mfs_vfsops.c 2001/03/05 22:50:08 1.32.2.1 @@ -42,8 +42,9 @@ #include #include #include #include +#include #include #include #include #include @@ -130,9 +131,9 @@ mfs_mountroot() { struct fs *fs; struct mount *mp; - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ struct ufsmount *ump; struct mfsnode *mfsp; int error = 0; @@ -300,9 +301,15 @@ struct mfsnode *mfsp = VTOMFS(vp); struct buf *bp; caddr_t base; int sleepreturn = 0; + struct lwp *l; /* XXX NJWLWP */ + /* XXX NJWLWP the vnode interface again gives us a proc in a + * place where we want a execution context. Cheat. + */ + KASSERT(curproc->l_proc == p); + l = curproc; base = mfsp->mfs_baseoff; while (BUFQ_FIRST(&mfsp->mfs_buflist) != (struct buf *) -1) { while ((bp = BUFQ_FIRST(&mfsp->mfs_buflist)) != NULL) { BUFQ_REMOVE(&mfsp->mfs_buflist, bp); @@ -313,14 +320,13 @@ * If a non-ignored signal is received, try to unmount. * If that fails, or the filesystem is already in the * process of being unmounted, clear the signal (it has been * "processed"), otherwise we will loop here, as tsleep - * will always return EINTR/ERESTART. - */ + * will always return EINTR/ERESTART. */ if (sleepreturn != 0) { if (vfs_busy(mp, LK_NOWAIT, 0) || dounmount(mp, 0, p) != 0) - CLRSIG(p, CURSIG(p)); + CLRSIG(p, CURSIG(l)); sleepreturn = 0; continue; } Index: sys/ufs/mfs/mfs_vnops.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/mfs/mfs_vnops.c,v retrieving revision 1.27 retrieving revision 1.27.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.27 -r1.27.2.1 --- sys/ufs/mfs/mfs_vnops.c 2001/01/22 12:17:44 1.27 +++ sys/ufs/mfs/mfs_vnops.c 2001/03/05 22:50:09 1.27.2.1 @@ -38,8 +38,9 @@ #include #include #include #include +#include #include #include #include #include @@ -143,9 +144,9 @@ } */ *ap = v; struct buf *bp = ap->a_bp; struct mfsnode *mfsp; struct vnode *vp; - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc->l_proc; /* XXX */ if (!vfinddev(bp->b_dev, VBLK, &vp) || vp->v_usecount == 0) panic("mfs_strategy: bad dev"); mfsp = VTOMFS(vp); Index: sys/ufs/ufs/ufs_bmap.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/ufs/ufs/ufs_bmap.c,v retrieving revision 1.10 retrieving revision 1.10.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.10 -r1.10.2.1 --- sys/ufs/ufs/ufs_bmap.c 2000/11/27 08:39:57 1.10 +++ sys/ufs/ufs/ufs_bmap.c 2001/03/05 22:50:09 1.10.2.1 @@ -42,8 +42,9 @@ #include #include #include +#include #include #include #include #include @@ -200,9 +201,9 @@ trace(TR_BREADMISS, pack(vp, size), metalbn); bp->b_blkno = blkptrtodb(ump, daddr); bp->b_flags |= B_READ; VOP_STRATEGY(bp); - curproc->p_stats->p_ru.ru_inblock++; /* XXX */ + curproc->l_proc->p_stats->p_ru.ru_inblock++; /* XXX */ if ((error = biowait(bp)) != 0) { brelse(bp); return (error); } Index: sys/uvm/uvm.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/uvm/uvm.h,v retrieving revision 1.24 retrieving revision 1.24.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.24 -r1.24.2.1 --- sys/uvm/uvm.h 2000/11/27 08:40:02 1.24 +++ sys/uvm/uvm.h 2001/03/05 22:50:09 1.24.2.1 @@ -89,9 +89,9 @@ pages in the idle loop */ /* page daemon trigger */ int pagedaemon; /* daemon sleeps on this */ - struct proc *pagedaemon_proc; /* daemon's pid */ + struct lwp *pagedaemon_proc; /* daemon's pid */ simple_lock_data_t pagedaemon_lock; /* aiodone daemon trigger */ int aiodoned; /* daemon sleeps on this */ Index: sys/uvm/uvm_extern.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/uvm/uvm_extern.h,v retrieving revision 1.58 retrieving revision 1.56.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.58 -r1.56.2.2 --- sys/uvm/uvm_extern.h 2001/03/15 06:10:56 1.58 +++ sys/uvm/uvm_extern.h 2001/04/09 01:59:12 1.56.2.2 @@ -517,12 +517,12 @@ void vmapbuf __P((struct buf *, vsize_t)); void vunmapbuf __P((struct buf *, vsize_t)); void pagemove __P((caddr_t, caddr_t, size_t)); #ifndef cpu_swapin -void cpu_swapin __P((struct proc *)); +void cpu_swapin __P((struct lwp *)); #endif #ifndef cpu_swapout -void cpu_swapout __P((struct proc *)); +void cpu_swapout __P((struct lwp *)); #endif /* uvm_aobj.c */ struct uvm_object *uao_create __P((vsize_t, int)); @@ -546,15 +546,17 @@ /* uvm_glue.c */ #if defined(KGDB) void uvm_chgkprot __P((caddr_t, size_t, int)); #endif -void uvm_fork __P((struct proc *, struct proc *, boolean_t, +void uvm_proc_fork __P((struct proc *, struct proc *, boolean_t)); +void uvm_lwp_fork __P((struct lwp *, struct lwp *, void *, size_t, void (*)(void *), void *)); -void uvm_exit __P((struct proc *)); +void uvm_proc_exit __P((struct proc *)); +void uvm_lwp_exit __P((struct lwp *)); void uvm_init_limits __P((struct proc *)); boolean_t uvm_kernacc __P((caddr_t, size_t, int)); __dead void uvm_scheduler __P((void)) __attribute__((noreturn)); -void uvm_swapin __P((struct proc *)); +void uvm_swapin __P((struct lwp *)); boolean_t uvm_useracc __P((caddr_t, size_t, int)); int uvm_vslock __P((struct proc *, caddr_t, size_t, vm_prot_t)); void uvm_vsunlock __P((struct proc *, caddr_t, size_t)); @@ -604,13 +606,13 @@ struct vmspace *uvmspace_alloc __P((vaddr_t, vaddr_t, boolean_t)); void uvmspace_init __P((struct vmspace *, struct pmap *, vaddr_t, vaddr_t, boolean_t)); -void uvmspace_exec __P((struct proc *, vaddr_t, vaddr_t)); +void uvmspace_exec __P((struct lwp *, vaddr_t, vaddr_t)); struct vmspace *uvmspace_fork __P((struct vmspace *)); void uvmspace_free __P((struct vmspace *)); void uvmspace_share __P((struct proc *, struct proc *)); -void uvmspace_unshare __P((struct proc *)); +void uvmspace_unshare __P((struct lwp *)); /* uvm_meter.c */ void uvm_meter __P((void)); Index: sys/uvm/uvm_fault.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/uvm/uvm_fault.c,v retrieving revision 1.60 retrieving revision 1.56.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.60 -r1.56.2.2 --- sys/uvm/uvm_fault.c 2001/04/01 16:45:53 1.60 +++ sys/uvm/uvm_fault.c 2001/04/09 01:59:13 1.56.2.2 @@ -42,8 +42,9 @@ #include #include #include +#include #include #include #include #include @@ -305,11 +306,11 @@ error = 0; uvmexp.fltanget++; /* bump rusage counters */ if (anon->u.an_page) - curproc->p_addr->u_stats.p_ru.ru_minflt++; + curproc->l_proc->p_stats->p_ru.ru_minflt++; else - curproc->p_addr->u_stats.p_ru.ru_majflt++; + curproc->l_proc->p_stats->p_ru.ru_majflt++; /* * loop until we get it, or fail. */ @@ -1326,12 +1327,12 @@ */ if (uobjpage) { /* update rusage counters */ - curproc->p_addr->u_stats.p_ru.ru_minflt++; + curproc->l_proc->p_stats->p_ru.ru_minflt++; } else { /* update rusage counters */ - curproc->p_addr->u_stats.p_ru.ru_majflt++; + curproc->l_proc->p_stats->p_ru.ru_majflt++; /* locked: maps(read), amap(if there), uobj */ uvmfault_unlockall(&ufi, amap, NULL, NULL); /* locked: uobj */ Index: sys/uvm/uvm_glue.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/uvm/uvm_glue.c,v retrieving revision 1.45 retrieving revision 1.44.2.3 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.45 -r1.44.2.3 --- sys/uvm/uvm_glue.c 2001/03/15 06:10:57 1.45 +++ sys/uvm/uvm_glue.c 2001/04/09 01:59:14 1.44.2.3 @@ -74,8 +74,9 @@ */ #include #include +#include #include #include #include #include @@ -90,9 +91,9 @@ /* * local prototypes */ -static void uvm_swapout __P((struct proc *)); +static void uvm_swapout __P((struct lwp *)); /* * XXXCDC: do these really belong here? */ @@ -154,9 +155,9 @@ boolean_t rv; vm_prot_t prot = rw == B_READ ? VM_PROT_READ : VM_PROT_WRITE; /* XXX curproc */ - map = &curproc->p_vmspace->vm_map; + map = &curproc->l_proc->p_vmspace->vm_map; vm_map_lock_read(map); rv = uvm_map_checkprot(map, trunc_page((vaddr_t)addr), round_page((vaddr_t)addr + len), prot); @@ -246,11 +247,30 @@ round_page((vaddr_t)addr + len)); } /* - * uvm_fork: fork a virtual address space + * uvm_proc_fork: fork a virtual address space * * - the address space is copied as per parent map's inherit values + */ +void +uvm_proc_fork(p1, p2, shared) + struct proc *p1, *p2; + boolean_t shared; +{ + + if (shared == TRUE) { + p2->p_vmspace = NULL; + uvmspace_share(p1, p2); /* share vmspace */ + } else { + p2->p_vmspace = uvmspace_fork(p1->p_vmspace); /* fork vmspace */ + } +} + + +/* + * uvm_lwp_fork: fork a thread + * * - a new "user" structure is allocated for the child process * [filled in by MD layer...] * - if specified, the child gets a new user stack described by * stack and stacksize @@ -261,25 +281,18 @@ * - XXXCDC: we need a way for this to return a failure value rather * than just hang */ void -uvm_fork(p1, p2, shared, stack, stacksize, func, arg) - struct proc *p1, *p2; - boolean_t shared; +uvm_lwp_fork(l1, l2, stack, stacksize, func, arg) + struct lwp *l1, *l2; void *stack; size_t stacksize; void (*func) __P((void *)); void *arg; { - struct user *up = p2->p_addr; + struct user *up = l2->l_addr; int error; - if (shared == TRUE) { - p2->p_vmspace = NULL; - uvmspace_share(p1, p2); /* share vmspace */ - } else - p2->p_vmspace = uvmspace_fork(p1->p_vmspace); /* fork vmspace */ - /* * Wire down the U-area for the process, which contains the PCB * and the kernel stack. Wired state is stored in p->p_flag's * P_INMEM bit rather than in the vm_map_entry's wired count @@ -293,27 +306,15 @@ if (error) panic("uvm_fork: uvm_fault_wire failed: %d", error); /* - * p_stats currently points at a field in the user struct. Copy - * parts of p_stats, and zero out the rest. - */ - p2->p_stats = &up->u_stats; - memset(&up->u_stats.pstat_startzero, 0, - ((caddr_t)&up->u_stats.pstat_endzero - - (caddr_t)&up->u_stats.pstat_startzero)); - memcpy(&up->u_stats.pstat_startcopy, &p1->p_stats->pstat_startcopy, - ((caddr_t)&up->u_stats.pstat_endcopy - - (caddr_t)&up->u_stats.pstat_startcopy)); - - /* * cpu_fork() copy and update the pcb, and make the child ready - * to run. If this is a normal user fork, the child will exit + * to run. If this is a normal user fork, the child will exit * directly to user mode via child_return() on its first time * slice and will not return here. If this is a kernel thread, * the specified entry point will be executed. */ - cpu_fork(p1, p2, stack, stacksize, func, arg); + cpu_fork(l1, l2, stack, stacksize, func, arg); } /* * uvm_exit: exit a virtual address space @@ -323,18 +324,25 @@ * - we must run in a separate thread because freeing the vmspace * of the dead process may block. */ void -uvm_exit(p) +uvm_proc_exit(p) struct proc *p; { - vaddr_t va = (vaddr_t)p->p_addr; - uvmspace_free(p->p_vmspace); - p->p_flag &= ~P_INMEM; +} + +void +uvm_lwp_exit(l) + struct lwp *l; +{ + vaddr_t va = (vaddr_t)l->l_addr; + uvm_fault_unwire(kernel_map, va, va + USPACE); uvm_km_free(kernel_map, va, USPACE); - p->p_addr = NULL; + + l->l_flag &= ~L_INMEM; + l->l_addr = NULL; } /* * uvm_init_limit: init per-process VM limits @@ -372,30 +380,30 @@ * uvm_swapin: swap in a process's u-area. */ void -uvm_swapin(p) - struct proc *p; +uvm_swapin(l) + struct lwp *l; { vaddr_t addr; int s; - addr = (vaddr_t)p->p_addr; - /* make P_INMEM true */ + addr = (vaddr_t)l->l_addr; + /* make L_INMEM true */ uvm_fault_wire(kernel_map, addr, addr + USPACE, VM_PROT_READ | VM_PROT_WRITE); /* * Some architectures need to be notified when the user area has * moved to new physical page(s) (e.g. see mips/mips/vm_machdep.c). */ - cpu_swapin(p); + cpu_swapin(l); SCHED_LOCK(s); - if (p->p_stat == SRUN) - setrunqueue(p); - p->p_flag |= P_INMEM; + if (l->l_stat == LSRUN) + setrunqueue(l); + l->l_flag |= L_INMEM; SCHED_UNLOCK(s); - p->p_swtime = 0; + l->l_swtime = 0; ++uvmexp.swapins; } /* @@ -408,29 +416,28 @@ void uvm_scheduler() { - struct proc *p; + struct lwp *l, *ll; int pri; - struct proc *pp; int ppri; loop: #ifdef DEBUG while (!enableswap) tsleep(&proc0, PVM, "noswap", 0); #endif - pp = NULL; /* process to choose */ + ll = NULL; /* process to choose */ ppri = INT_MIN; /* its priority */ proclist_lock_read(); - LIST_FOREACH(p, &allproc, p_list) { + LIST_FOREACH(l, &alllwp, l_list) { /* is it a runnable swapped out process? */ - if (p->p_stat == SRUN && (p->p_flag & P_INMEM) == 0) { - pri = p->p_swtime + p->p_slptime - - (p->p_nice - NZERO) * 8; + if (l->l_stat == LSRUN && (l->l_flag & L_INMEM) == 0) { + pri = l->l_swtime + l->l_slptime - + (l->l_proc->p_nice - NZERO) * 8; if (pri > ppri) { /* higher priority? remember it. */ - pp = p; + ll = l; ppri = pri; } } } @@ -441,14 +448,14 @@ proclist_unlock_read(); #ifdef DEBUG if (swapdebug & SDB_FOLLOW) - printf("scheduler: running, procp %p pri %d\n", pp, ppri); + printf("scheduler: running, procp %p pri %d\n", ll, ppri); #endif /* * Nothing to do, back to sleep */ - if ((p = pp) == NULL) { + if ((l = ll) == NULL) { tsleep(&proc0, PVM, "scheduler", 0); goto loop; } @@ -462,11 +469,11 @@ if (uvmexp.free > atop(USPACE)) { #ifdef DEBUG if (swapdebug & SDB_SWAPIN) printf("swapin: pid %d(%s)@%p, pri %d free %d\n", - p->p_pid, p->p_comm, p->p_addr, ppri, uvmexp.free); + l->l_proc->p_pid, l->l_proc->p_comm, l->l_addr, ppri, uvmexp.free); #endif - uvm_swapin(p); + uvm_swapin(l); goto loop; } /* * not enough memory, jab the pageout daemon and wait til the coast @@ -474,9 +481,9 @@ */ #ifdef DEBUG if (swapdebug & SDB_FOLLOW) printf("scheduler: no room for pid %d(%s), free %d\n", - p->p_pid, p->p_comm, uvmexp.free); + l->l_proc->p_pid, l->l_proc->p_comm, uvmexp.free); #endif uvm_wait("schedpwait"); #ifdef DEBUG if (swapdebug & SDB_FOLLOW) @@ -485,14 +492,15 @@ goto loop; } /* - * swappable: is process "p" swappable? + * swappable: is LWP "l" swappable? */ -#define swappable(p) \ - (((p)->p_flag & (P_SYSTEM | P_INMEM | P_WEXIT)) == P_INMEM && \ - (p)->p_holdcnt == 0) +#define swappable(l) \ + (((l)->l_flag & (L_INMEM)) && \ + ((((l)->l_proc->p_flag) & (P_SYSTEM | P_WEXIT)) == 0) && \ + (l)->l_holdcnt == 0) /* * swapout_threads: find threads that can be swapped and unwire their * u-areas. @@ -505,10 +513,10 @@ */ void uvm_swapout_threads() { - struct proc *p; - struct proc *outp, *outp2; + struct lwp *l; + struct lwp *outl, *outl2; int outpri, outpri2; int didswap = 0; extern int maxslp; /* XXXCDC: should move off to uvmexp. or uvm., also in uvm_meter */ @@ -518,34 +526,34 @@ return; #endif /* - * outp/outpri : stop/sleep process with largest sleeptime < maxslp - * outp2/outpri2: the longest resident process (its swap time) + * outl/outpri : stop/sleep thread with largest sleeptime < maxslp + * outl2/outpri2: the longest resident thread (its swap time) */ - outp = outp2 = NULL; + outl = outl2 = NULL; outpri = outpri2 = 0; proclist_lock_read(); - LIST_FOREACH(p, &allproc, p_list) { - if (!swappable(p)) + LIST_FOREACH(l, &alllwp, l_list) { + if (!swappable(l)) continue; - switch (p->p_stat) { - case SRUN: - case SONPROC: - if (p->p_swtime > outpri2) { - outp2 = p; - outpri2 = p->p_swtime; + switch (l->l_stat) { + case LSRUN: + case LSONPROC: + if (l->l_swtime > outpri2) { + outl2 = l; + outpri2 = l->l_swtime; } continue; - case SSLEEP: - case SSTOP: - if (p->p_slptime >= maxslp) { - uvm_swapout(p); + case LSSLEEP: + case LSSTOP: + if (l->l_slptime >= maxslp) { + uvm_swapout(l); didswap++; - } else if (p->p_slptime > outpri) { - outp = p; - outpri = p->p_slptime; + } else if (l->l_slptime > outpri) { + outl = l; + outpri = l->l_slptime; } continue; } } @@ -557,63 +565,65 @@ * if we are real low on memory since we don't gain much by doing * it (USPACE bytes). */ if (didswap == 0 && uvmexp.free <= atop(round_page(USPACE))) { - if ((p = outp) == NULL) - p = outp2; + if ((l = outl) == NULL) + l = outl2; #ifdef DEBUG if (swapdebug & SDB_SWAPOUT) - printf("swapout_threads: no duds, try procp %p\n", p); + printf("swapout_threads: no duds, try procp %p\n", l); #endif - if (p) - uvm_swapout(p); + if (l) + uvm_swapout(l); } pmap_update(); } /* - * uvm_swapout: swap out process "p" + * uvm_swapout: swap out lwp "l" * * - currently "swapout" means "unwire U-area" and "pmap_collect()" * the pmap. * - XXXCDC: should deactivate all process' private anonymous memory */ static void -uvm_swapout(p) - struct proc *p; +uvm_swapout(l) + struct lwp *l; { vaddr_t addr; int s; + struct proc *p = l->l_proc; #ifdef DEBUG if (swapdebug & SDB_SWAPOUT) printf("swapout: pid %d(%s)@%p, stat %x pri %d free %d\n", - p->p_pid, p->p_comm, p->p_addr, p->p_stat, - p->p_slptime, uvmexp.free); + p->p_pid, p->p_comm, l->l_addr, l->l_stat, + l->l_slptime, uvmexp.free); #endif /* * Do any machine-specific actions necessary before swapout. * This can include saving floating point state, etc. */ - cpu_swapout(p); + cpu_swapout(l); /* * Mark it as (potentially) swapped out. */ SCHED_LOCK(s); - p->p_flag &= ~P_INMEM; - if (p->p_stat == SRUN) - remrunqueue(p); + s = splstatclock(); + l->l_flag &= ~L_INMEM; + if (l->l_stat == LSRUN) + remrunqueue(l); SCHED_UNLOCK(s); - p->p_swtime = 0; + l->l_swtime = 0; ++uvmexp.swapouts; /* * Unwire the to-be-swapped process's user struct and kernel stack. */ - addr = (vaddr_t)p->p_addr; + addr = (vaddr_t)l->l_addr; uvm_fault_unwire(kernel_map, addr, addr + USPACE); /* !P_INMEM */ pmap_collect(vm_map_pmap(&p->p_vmspace->vm_map)); } Index: sys/uvm/uvm_init.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/uvm/uvm_init.c,v retrieving revision 1.14 retrieving revision 1.14.2.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.14 -r1.14.2.1 --- sys/uvm/uvm_init.c 2000/06/27 17:29:23 1.14 +++ sys/uvm/uvm_init.c 2001/03/05 22:50:10 1.14.2.1 @@ -81,9 +81,8 @@ /* * step 1: zero the uvm structure */ - memset(&uvm, 0, sizeof(uvm)); averunnable.fscale = FSCALE; /* @@ -92,60 +91,52 @@ * locks). available memory will be put in the "free" queue. * kvm_start and kvm_end will be set to the area of kernel virtual * memory which is available for general use. */ - uvm_page_init(&kvm_start, &kvm_end); /* * step 3: init the map sub-system. allocates the static pool of * vm_map_entry structures that are used for "special" kernel maps * (e.g. kernel_map, kmem_map, etc...). */ - uvm_map_init(); /* * step 4: setup the kernel's virtual memory data structures. this * includes setting up the kernel_map/kernel_object and the kmem_map/ * kmem_object. */ - uvm_km_init(kvm_start, kvm_end); /* * step 5: init the pmap module. the pmap module is free to allocate * memory for its private use (e.g. pvlists). */ - pmap_init(); /* * step 6: init the kernel memory allocator. after this call the * kernel memory allocator (malloc) can be used. */ - kmeminit(); /* * step 7: init all pagers and the pager_map. */ - uvm_pager_init(); /* * step 8: init anonymous memory systems (both amap and anons) */ - amap_init(); /* init amap module */ uvm_anon_init(); /* allocate initial anons */ /* * the VM system is now up! now that malloc is up we can resize the * => hash table for general use and enable paging * of kernel objects. */ - uvm_page_rehash(); uao_create(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS, UAO_FLAG_KERNSWAP); Index: sys/uvm/uvm_map.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/uvm/uvm_map.c,v retrieving revision 1.94 retrieving revision 1.93.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.94 -r1.93.2.2 --- sys/uvm/uvm_map.c 2001/03/15 06:10:57 1.94 +++ sys/uvm/uvm_map.c 2001/04/09 01:59:16 1.93.2.2 @@ -76,8 +76,9 @@ #include #include #include +#include #include #include #include @@ -523,9 +524,8 @@ /* * step 0: sanity check of protection code */ - if ((prot & maxprot) != prot) { UVMHIST_LOG(maphist, "<- prot. failure: prot=0x%x, max=0x%x", prot, maxprot,0,0); return EACCES; @@ -533,9 +533,8 @@ /* * step 1: figure out where to put new VM range */ - if (vm_map_lock_try(map) == FALSE) { if (flags & UVM_FLAG_TRYLOCK) return EAGAIN; vm_map_lock(map); /* could sleep here */ @@ -556,9 +555,8 @@ if (map == kernel_map && uvm_maxkaddr < (*startp + size)) uvm_maxkaddr = pmap_growkernel(*startp + size); } #endif - UVMCNT_INCR(uvm_map_call); /* * if uobj is null, then uoffset is either a VAC hint for PMAP_PREFER @@ -2724,11 +2722,12 @@ * - XXX: no locking on vmspace */ void -uvmspace_unshare(p) - struct proc *p; +uvmspace_unshare(l) + struct lwp *l; { + struct proc *p = l->l_proc; struct vmspace *nvm, *ovm = p->p_vmspace; if (ovm->vm_refcnt == 1) /* nothing to do: vmspace isn't shared in the first place */ @@ -2736,11 +2735,11 @@ /* make a new vmspace, still holding old one */ nvm = uvmspace_fork(ovm); - pmap_deactivate(p); /* unbind old vmspace */ + pmap_deactivate(l); /* unbind old vmspace */ p->p_vmspace = nvm; - pmap_activate(p); /* switch to new vmspace */ + pmap_activate(l); /* switch to new vmspace */ uvmspace_free(ovm); /* drop reference to old vmspace */ } @@ -2750,12 +2749,13 @@ * - XXX: no locking on vmspace */ void -uvmspace_exec(p, start, end) - struct proc *p; +uvmspace_exec(l, start, end) + struct lwp *l; vaddr_t start, end; { + struct proc *p = l->l_proc; struct vmspace *nvm, *ovm = p->p_vmspace; vm_map_t map = &ovm->vm_map; #ifdef __sparc__ @@ -2815,11 +2815,11 @@ /* * install new vmspace and drop our ref to the old one. */ - pmap_deactivate(p); + pmap_deactivate(l); p->p_vmspace = nvm; - pmap_activate(p); + pmap_activate(l); uvmspace_free(ovm); } } Index: sys/uvm/uvm_map.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/uvm/uvm_map.h,v retrieving revision 1.25 retrieving revision 1.24.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.25 -r1.24.2.2 --- sys/uvm/uvm_map.h 2001/03/15 06:10:57 1.25 +++ sys/uvm/uvm_map.h 2001/04/09 01:59:18 1.24.2.2 @@ -379,8 +379,9 @@ #ifdef _KERNEL /* XXX: clean up later */ #include +#include #include /* for tsleep(), wakeup() */ #include /* for panic() */ static __inline boolean_t vm_map_lock_try __P((vm_map_t)); Index: sys/uvm/uvm_meter.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/uvm/uvm_meter.c,v retrieving revision 1.17 retrieving revision 1.16.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.17 -r1.16.2.2 --- sys/uvm/uvm_meter.c 2001/03/09 01:02:12 1.17 +++ sys/uvm/uvm_meter.c 2001/04/09 01:59:18 1.16.2.2 @@ -40,8 +40,9 @@ * from: Id: uvm_meter.c,v 1.1.2.1 1997/08/14 19:10:35 chuck Exp */ #include +#include #include #include #include #include @@ -80,9 +81,9 @@ uvm_meter() { if ((time.tv_sec % 5) == 0) uvm_loadav(&averunnable); - if (proc0.p_slptime > (maxslp / 2)) + if (lwp0.l_slptime > (maxslp / 2)) wakeup(&proc0); } /* @@ -93,21 +94,21 @@ uvm_loadav(avg) struct loadavg *avg; { int i, nrun; - struct proc *p; + struct lwp *l; proclist_lock_read(); nrun = 0; - LIST_FOREACH(p, &allproc, p_list) { - switch (p->p_stat) { - case SSLEEP: - if (p->p_priority > PZERO || p->p_slptime > 1) + LIST_FOREACH(l, &alllwp, l_list) { + switch (l->l_stat) { + case LSSLEEP: + if (l->l_priority > PZERO || l->l_slptime > 1) continue; /* fall through */ - case SRUN: - case SONPROC: - case SIDL: + case LSRUN: + case LSONPROC: + case LSIDL: nrun++; } } proclist_unlock_read(); @@ -296,9 +297,9 @@ static void uvm_total(totalp) struct vmtotal *totalp; { - struct proc *p; + struct lwp *l; #if 0 vm_map_entry_t entry; vm_map_t map; int paging; @@ -310,36 +311,36 @@ * calculate process statistics */ proclist_lock_read(); - LIST_FOREACH(p, &allproc, p_list) { - if (p->p_flag & P_SYSTEM) + LIST_FOREACH(l, &alllwp, l_list) { + if (l->l_proc->p_flag & P_SYSTEM) continue; - switch (p->p_stat) { + switch (l->l_stat) { case 0: continue; - case SSLEEP: - case SSTOP: - if (p->p_flag & P_INMEM) { - if (p->p_priority <= PZERO) + case LSSLEEP: + case LSSTOP: + if (l->l_flag & L_INMEM) { + if (l->l_priority <= PZERO) totalp->t_dw++; - else if (p->p_slptime < maxslp) + else if (l->l_slptime < maxslp) totalp->t_sl++; - } else if (p->p_slptime < maxslp) + } else if (l->l_slptime < maxslp) totalp->t_sw++; - if (p->p_slptime >= maxslp) + if (l->l_slptime >= maxslp) continue; break; - case SRUN: - case SONPROC: - case SIDL: - if (p->p_flag & P_INMEM) + case LSRUN: + case LSONPROC: + case LSIDL: + if (l->l_flag & L_INMEM) totalp->t_rq++; else totalp->t_sw++; - if (p->p_stat == SIDL) + if (l->l_stat == LSIDL) continue; break; } /* Index: sys/uvm/uvm_mmap.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/uvm/uvm_mmap.c,v retrieving revision 1.50 retrieving revision 1.49.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.50 -r1.49.2.2 --- sys/uvm/uvm_mmap.c 2001/03/15 06:10:57 1.50 +++ sys/uvm/uvm_mmap.c 2001/04/09 01:59:19 1.49.2.2 @@ -55,8 +55,9 @@ #include #include #include #include +#include #include #include #include #include @@ -80,10 +81,10 @@ */ /* ARGSUSED */ int -sys_sbrk(p, v, retval) - struct proc *p; +sys_sbrk(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #if 0 @@ -100,10 +101,10 @@ */ /* ARGSUSED */ int -sys_sstk(p, v, retval) - struct proc *p; +sys_sstk(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #if 0 @@ -120,18 +121,19 @@ */ /* ARGSUSED */ int -sys_mincore(p, v, retval) - struct proc *p; +sys_mincore(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_mincore_args /* { syscallarg(void *) addr; syscallarg(size_t) len; syscallarg(char *) vec; } */ *uap = v; + struct proc *p = l->l_proc; vm_page_t m; char *vec, pgi; struct uvm_object *uobj; struct vm_amap *amap; @@ -267,10 +269,10 @@ * and the return value is adjusted up by the page offset. */ int -sys_mmap(p, v, retval) - struct proc *p; +sys_mmap(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_mmap_args /* { @@ -281,8 +283,9 @@ syscallarg(int) fd; syscallarg(long) pad; syscallarg(off_t) pos; } */ *uap = v; + struct proc *p = l->l_proc; vaddr_t addr; struct vattr va; off_t pos; vsize_t size, pageoff; @@ -497,18 +500,19 @@ * sys___msync13: the msync system call (a front-end for flush) */ int -sys___msync13(p, v, retval) - struct proc *p; +sys___msync13(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys___msync13_args /* { syscallarg(caddr_t) addr; syscallarg(size_t) len; syscallarg(int) flags; } */ *uap = v; + struct proc *p = l->l_proc; vaddr_t addr; vsize_t size, pageoff; vm_map_t map; int error, rv, flags, uvmflags; @@ -593,17 +597,18 @@ * sys_munmap: unmap a users memory */ int -sys_munmap(p, v, retval) - struct proc *p; +sys_munmap(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_munmap_args /* { syscallarg(caddr_t) addr; syscallarg(size_t) len; } */ *uap = v; + struct proc *p = l->l_proc; vaddr_t addr; vsize_t size, pageoff; vm_map_t map; vaddr_t vm_min_address = VM_MIN_ADDRESS; @@ -663,18 +668,19 @@ * sys_mprotect: the mprotect system call */ int -sys_mprotect(p, v, retval) - struct proc *p; +sys_mprotect(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_mprotect_args /* { syscallarg(caddr_t) addr; syscallarg(int) len; syscallarg(int) prot; } */ *uap = v; + struct proc *p = l->l_proc; vaddr_t addr; vsize_t size, pageoff; vm_prot_t prot; int error; @@ -707,18 +713,19 @@ * sys_minherit: the minherit system call */ int -sys_minherit(p, v, retval) - struct proc *p; +sys_minherit(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_minherit_args /* { syscallarg(caddr_t) addr; syscallarg(int) len; syscallarg(int) inherit; } */ *uap = v; + struct proc *p = l->l_proc; vaddr_t addr; vsize_t size, pageoff; vm_inherit_t inherit; int error; @@ -748,18 +755,19 @@ */ /* ARGSUSED */ int -sys_madvise(p, v, retval) - struct proc *p; +sys_madvise(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_madvise_args /* { syscallarg(caddr_t) addr; syscallarg(size_t) len; syscallarg(int) behav; } */ *uap = v; + struct proc *p = l->l_proc; vaddr_t addr; vsize_t size, pageoff; int advice, error; @@ -851,17 +859,18 @@ * sys_mlock: memory lock */ int -sys_mlock(p, v, retval) - struct proc *p; +sys_mlock(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_mlock_args /* { syscallarg(const void *) addr; syscallarg(size_t) len; } */ *uap = v; + struct proc *p = l->l_proc; vaddr_t addr; vsize_t size, pageoff; int error; @@ -906,17 +915,18 @@ * sys_munlock: unlock wired pages */ int -sys_munlock(p, v, retval) - struct proc *p; +sys_munlock(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_munlock_args /* { syscallarg(const void *) addr; syscallarg(size_t) len; } */ *uap = v; + struct proc *p = l->l_proc; vaddr_t addr; vsize_t size, pageoff; int error; @@ -954,16 +964,17 @@ * sys_mlockall: lock all pages mapped into an address space. */ int -sys_mlockall(p, v, retval) - struct proc *p; +sys_mlockall(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_mlockall_args /* { syscallarg(int) flags; } */ *uap = v; + struct proc *p = l->l_proc; int error, flags; flags = SCARG(uap, flags); @@ -985,13 +996,14 @@ * sys_munlockall: unlock all pages mapped into an address space. */ int -sys_munlockall(p, v, retval) - struct proc *p; +sys_munlockall(l, v, retval) + struct lwp *l; void *v; register_t *retval; { + struct proc *p = l->l_proc; (void) uvm_map_pageable_all(&p->p_vmspace->vm_map, 0, 0); return (0); } Index: sys/uvm/uvm_pmap.h =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/uvm/uvm_pmap.h,v retrieving revision 1.1 retrieving revision 1.1.4.1 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.1 -r1.1.4.1 --- sys/uvm/uvm_pmap.h 2000/06/27 09:00:14 1.1 +++ sys/uvm/uvm_pmap.h 2001/03/05 22:50:11 1.1.4.1 @@ -71,9 +71,9 @@ #ifndef _PMAP_VM_ #define _PMAP_VM_ -struct proc; /* for pmap_activate()/pmap_deactivate() proto */ +struct lwp; /* for pmap_activate()/pmap_deactivate() proto */ /* * Each machine dependent implementation is expected to * keep certain statistics. They may do this anyway they @@ -99,10 +99,10 @@ #ifndef PMAP_EXCLUDE_DECLS /* Used in Sparc port to virtualize pmap mod */ #ifdef _KERNEL __BEGIN_DECLS void *pmap_bootstrap_alloc __P((int)); -void pmap_activate __P((struct proc *)); -void pmap_deactivate __P((struct proc *)); +void pmap_activate __P((struct lwp *)); +void pmap_deactivate __P((struct lwp *)); void pmap_unwire __P((pmap_t, vaddr_t)); #if !defined(pmap_clear_modify) boolean_t pmap_clear_modify __P((struct vm_page *)); Index: sys/uvm/uvm_swap.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/uvm/uvm_swap.c,v retrieving revision 1.47 retrieving revision 1.46.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.47 -r1.46.2.2 --- sys/uvm/uvm_swap.c 2001/03/10 22:46:51 1.47 +++ sys/uvm/uvm_swap.c 2001/04/09 01:59:23 1.46.2.2 @@ -39,8 +39,9 @@ #include #include #include #include +#include #include #include #include #include @@ -464,18 +465,19 @@ * sys_swapctl: main entry point for swapctl(2) system call * [with two helper functions: swap_on and swap_off] */ int -sys_swapctl(p, v, retval) - struct proc *p; +sys_swapctl(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_swapctl_args /* { syscallarg(int) cmd; syscallarg(void *) arg; syscallarg(int) misc; } */ *uap = (struct sys_swapctl_args *)v; + struct proc *p = l->l_proc; struct vnode *vp; struct nameidata nd; struct swappri *spp; struct swapdev *sdp; Index: sys/uvm/uvm_unix.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/uvm/uvm_unix.c,v retrieving revision 1.20 retrieving revision 1.18.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.20 -r1.18.2.2 --- sys/uvm/uvm_unix.c 2001/03/19 02:25:33 1.20 +++ sys/uvm/uvm_unix.c 2001/04/09 01:59:24 1.18.2.2 @@ -51,8 +51,9 @@ #include "opt_compat_netbsd32.h" #include #include +#include #include #include #include #include @@ -66,16 +67,17 @@ * sys_obreak: set break */ int -sys_obreak(p, v, retval) - struct proc *p; +sys_obreak(l, v, retval) + struct lwp *l; void *v; register_t *retval; { struct sys_obreak_args /* { syscallarg(char *) nsize; } */ *uap = v; + struct proc *p = l->l_proc; struct vmspace *vm = p->p_vmspace; vaddr_t new, old; ssize_t diff; int error; @@ -152,10 +154,10 @@ */ /* ARGSUSED */ int -sys_ovadvise(p, v, retval) - struct proc *p; +sys_ovadvise(l, v, retval) + struct lwp *l; void *v; register_t *retval; { #if 0 Index: sys/uvm/uvm_vnode.c =================================================================== RCS file: /raid/NetBSD/cvs/syssrc/sys/uvm/uvm_vnode.c,v retrieving revision 1.48 retrieving revision 1.46.2.2 diff -u -4 -I\$NetBSD:.*\$ -I\$Revision:.*\$ -r1.48 -r1.46.2.2 --- sys/uvm/uvm_vnode.c 2001/03/10 22:46:51 1.48 +++ sys/uvm/uvm_vnode.c 2001/04/09 01:59:24 1.46.2.2 @@ -54,8 +54,9 @@ */ #include #include +#include #include #include #include #include @@ -188,16 +189,17 @@ * * (2) All we want is the size, anyhow. */ result = (*bdevsw[major(vp->v_rdev)].d_ioctl)(vp->v_rdev, - DIOCGPART, (caddr_t)&pi, FREAD, curproc); + DIOCGPART, (caddr_t)&pi, FREAD, curproc->l_proc); if (result == 0) { /* XXX should remember blocksize */ used_vnode_size = (voff_t)pi.disklab->d_secsize * (voff_t)pi.part->p_size; } } else { - result = VOP_GETATTR(vp, &vattr, curproc->p_ucred, curproc); + result = VOP_GETATTR(vp, &vattr, curproc->l_proc->p_ucred, + curproc->l_proc); if (result == 0) used_vnode_size = vattr.va_size; }