+int
+proc_isinferior(int pid1, int pid2)
+{
+ proc_t p;
+ proc_t t;
+
+ if (((p = pfind(pid1)) != (struct proc *)0 ) && ((t = pfind(pid2)) != (struct proc *)0))
+ return (isinferior(p, t));
+ return(0);
+}
+
+proc_t
+proc_find(int pid)
+{
+ return(pfind(pid));
+}
+
+int
+proc_rele(__unused proc_t p)
+{
+ return(0);
+}
+
+proc_t
+proc_self()
+{
+ return(current_proc());
+}
+
+proc_t
+proc_findref(int pid)
+{
+ boolean_t funnel_state;
+ proc_t p;
+
+ funnel_state = thread_funnel_set(kernel_flock,TRUE);
+ p = pfind(pid);
+
+ if (p != proc_refinternal(p, 1))
+ p = PROC_NULL;
+
+ thread_funnel_set(kernel_flock, funnel_state);
+ return(p);
+}
+
+void
+proc_dropref(proc_t p)
+{
+
+ proc_dropinternal(p, 0);
+}
+
+
+proc_t
+proc_refinternal(proc_t p, int funneled)
+{
+
+ proc_t p1 = p;
+ boolean_t funnel_state = TRUE; /* need to init just to avoid warnings and build failure */
+
+ if (funneled == 0)
+ funnel_state = thread_funnel_set(kernel_flock,TRUE);
+
+ if ((p != PROC_NULL) &&(p->p_stat != SZOMB) && ((p->p_lflag & (P_LREFDRAINWAIT | P_LREFDRAIN | P_LREFDEAD)) == 0))
+ p->p_internalref++;
+ else
+ p1 = PROC_NULL;
+
+ if (funneled == 0)
+ thread_funnel_set(kernel_flock,funnel_state);
+ return(p1);
+}
+
+void
+proc_dropinternal(proc_t p, int funneled)
+{
+ boolean_t funnel_state = TRUE; /* need to init just to avoid warnings and build failure */
+
+ if (funneled == 0)
+ funnel_state = thread_funnel_set(kernel_flock,TRUE);
+
+ if (p->p_internalref > 0) {
+ p->p_internalref--;
+ if ((p->p_internalref == 0) && ((p->p_lflag & P_LREFDRAINWAIT) == P_LREFDRAINWAIT)) {
+ p->p_lflag &= ~P_LREFDRAINWAIT;
+ wakeup(&p->p_internalref);
+ }
+ } else
+ printf("proc_dropreg -ve ref\n");
+
+ if (funneled == 0)
+ thread_funnel_set(kernel_flock,funnel_state);
+}
+
+
+int
+proc_pid(proc_t p)
+{
+ return(p->p_pid);
+}
+
+int
+proc_ppid(proc_t p)
+{
+ if (p->p_pptr != (struct proc *)0)
+ return(p->p_pptr->p_pid);
+ return(0);
+}
+
+int
+proc_selfpid(void)
+{
+ struct proc *p = current_proc();
+ return(p->p_pid);
+}
+
+
+int
+proc_selfppid(void)
+{
+ struct proc *p = current_proc();
+ if (p->p_pptr)
+ return(p->p_pptr->p_pid);
+ else
+ return(0);
+}
+
+void
+proc_name(int pid, char * buf, int size)
+{
+ struct proc *p;
+
+ if ((p = pfind(pid))!= (struct proc *)0) {
+ strncpy(buf, &p->p_comm[0], size);
+ buf[size-1] = 0;
+ }
+}
+
+void
+proc_selfname(char * buf, int size)
+{
+ struct proc *p;
+
+ if ((p = current_proc())!= (struct proc *)0) {
+ strncpy(buf, &p->p_comm[0], size);
+ buf[size-1] = 0;
+ }
+}
+
+void
+proc_signal(int pid, int signum)
+{
+ proc_t p;
+
+ if ((p = pfind(pid))!= (struct proc *)0) {
+ psignal(p, signum);
+ }
+}
+
+int
+proc_issignal(int pid, sigset_t mask)
+{
+ proc_t p;
+
+ if ((p = pfind(pid))!= (struct proc *)0) {
+ return(proc_pendingsignals(p, mask));
+ }
+ return(0);
+}
+
+int
+proc_noremotehang(proc_t p)
+{
+ int retval = 0;
+
+ if (p)
+ retval = p->p_flag & P_NOREMOTEHANG;
+ return(retval? 1: 0);
+
+}
+
+int
+proc_exiting(proc_t p)
+{
+ int retval = 0;
+
+ if (p)
+ retval = p->p_flag & P_WEXIT;
+ return(retval? 1: 0);
+}
+
+
+int
+proc_forcequota(proc_t p)
+{
+ int retval = 0;
+
+ if (p)
+ retval = p->p_flag & P_FORCEQUOTA;
+ return(retval? 1: 0);
+
+}
+
+int
+proc_tbe(proc_t p)
+{
+ int retval = 0;
+
+ if (p)
+ retval = p->p_flag & P_TBE;
+ return(retval? 1: 0);
+
+}
+
+int
+proc_suser(proc_t p)
+{
+ return(suser(p->p_ucred, NULL));
+
+}
+
+kauth_cred_t
+proc_ucred(proc_t p)
+{
+ return(p->p_ucred);
+}
+
+
+int
+proc_is64bit(proc_t p)
+{
+ return(IS_64BIT_PROCESS(p));
+}
+
+/* LP64todo - figure out how to identify 64-bit processes if NULL procp */
+int
+IS_64BIT_PROCESS(proc_t p)
+{
+ if (p && (p->p_flag & P_LP64))
+ return(1);
+ else
+ return(0);
+}
+
+