We live in a thread world!  Let's face it.

ok?

Index: sys/arch/amd64/amd64/db_trace.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/amd64/db_trace.c,v
retrieving revision 1.23
diff -u -p -r1.23 db_trace.c
--- sys/arch/amd64/amd64/db_trace.c     16 Sep 2016 19:13:16 -0000      1.23
+++ sys/arch/amd64/amd64/db_trace.c     24 Jan 2017 00:10:47 -0000
@@ -181,7 +181,7 @@ db_stack_trace_print(db_expr_t addr, boo
                callpc = (db_addr_t)ddb_regs.tf_rip;
        } else {
                if (trace_proc) {
-                       struct proc *p = pfind((pid_t)addr);
+                       struct proc *p = tfind((pid_t)addr);
                        if (p == NULL) {
                                (*pr) ("not found\n");
                                return;
Index: sys/arch/arm/arm/db_trace.c
===================================================================
RCS file: /cvs/src/sys/arch/arm/arm/db_trace.c,v
retrieving revision 1.9
diff -u -p -r1.9 db_trace.c
--- sys/arch/arm/arm/db_trace.c 20 Sep 2016 08:35:25 -0000      1.9
+++ sys/arch/arm/arm/db_trace.c 24 Jan 2017 00:10:47 -0000
@@ -104,7 +104,7 @@ db_stack_trace_print(db_expr_t addr, int
                        struct proc *p;
                        struct user *u;
                        (*pr) ("trace: pid %d ", (int)addr);
-                       p = pfind(addr);
+                       p = tfind(addr);
                        if (p == NULL) {
                                (*pr)("not found\n");
                                return;
Index: sys/arch/i386/i386/db_trace.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/i386/db_trace.c,v
retrieving revision 1.22
diff -u -p -r1.22 db_trace.c
--- sys/arch/i386/i386/db_trace.c       18 Sep 2016 13:38:01 -0000      1.22
+++ sys/arch/i386/i386/db_trace.c       24 Jan 2017 00:10:47 -0000
@@ -195,7 +195,7 @@ db_stack_trace_print(db_expr_t addr, boo
        } else if (trace_thread) {
                (*pr) ("%s: can't trace thread\n", __func__);
        } else if (trace_proc) {
-               struct proc *p = pfind((pid_t)addr);
+               struct proc *p = tfind((pid_t)addr);
                if (p == NULL) {
                        (*pr) ("not found\n");
                        return;
Index: sys/arch/powerpc/ddb/db_trace.c
===================================================================
RCS file: /cvs/src/sys/arch/powerpc/ddb/db_trace.c,v
retrieving revision 1.10
diff -u -p -r1.10 db_trace.c
--- sys/arch/powerpc/ddb/db_trace.c     10 Sep 2016 06:36:26 -0000      1.10
+++ sys/arch/powerpc/ddb/db_trace.c     24 Jan 2017 00:10:47 -0000
@@ -134,7 +134,7 @@ db_stack_trace_print(db_expr_t addr, int
                lr = ddb_regs.srr0;
        } else {
                if (trace_proc) {
-                       struct proc *p = pfind((pid_t)addr);
+                       struct proc *p = tfind((pid_t)addr);
                        if (p == NULL) {
                                (*pr) ("not found\n");
                                return;
Index: sys/arch/sparc64/sparc64/db_trace.c
===================================================================
RCS file: /cvs/src/sys/arch/sparc64/sparc64/db_trace.c,v
retrieving revision 1.12
diff -u -p -r1.12 db_trace.c
--- sys/arch/sparc64/sparc64/db_trace.c 11 Sep 2016 03:14:04 -0000      1.12
+++ sys/arch/sparc64/sparc64/db_trace.c 24 Jan 2017 00:10:47 -0000
@@ -78,7 +78,7 @@ db_stack_trace_print(db_expr_t addr, int
                        struct proc *p;
                        struct user *u;
                        (*pr)("trace: pid %d ", (int)addr);
-                       p = pfind(addr);
+                       p = tfind(addr);
                        if (p == NULL) {
                                (*pr)("not found\n");
                                return;
Index: sys/kern/kern_fork.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_fork.c,v
retrieving revision 1.192
diff -u -p -r1.192 kern_fork.c
--- sys/kern/kern_fork.c        7 Nov 2016 00:26:32 -0000       1.192
+++ sys/kern/kern_fork.c        24 Jan 2017 00:04:58 -0000
@@ -559,7 +559,7 @@ alloctid(void)
        do {
                /* (0 .. TID_MASK+1] */
                tid = 1 + (arc4random() & TID_MASK);
-       } while (pfind(tid) != NULL);
+       } while (tfind(tid) != NULL);
 
        return (tid);
 }
Index: sys/kern/kern_proc.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_proc.c,v
retrieving revision 1.72
diff -u -p -r1.72 kern_proc.c
--- sys/kern/kern_proc.c        21 Jan 2017 05:42:03 -0000      1.72
+++ sys/kern/kern_proc.c        24 Jan 2017 00:05:06 -0000
@@ -169,7 +169,7 @@ inferior(struct process *pr, struct proc
  * Locate a proc (thread) by number
  */
 struct proc *
-pfind(pid_t tid)
+tfind(pid_t tid)
 {
        struct proc *p;
 
Index: sys/kern/kern_sig.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_sig.c,v
retrieving revision 1.207
diff -u -p -r1.207 kern_sig.c
--- sys/kern/kern_sig.c 21 Jan 2017 05:42:03 -0000      1.207
+++ sys/kern/kern_sig.c 24 Jan 2017 00:05:12 -0000
@@ -617,7 +617,7 @@ sys_thrkill(struct proc *cp, void *v, re
        if (((u_int)signum) >= NSIG)
                return (EINVAL);
        if (tid > THREAD_PID_OFFSET) {
-               if ((p = pfind(tid - THREAD_PID_OFFSET)) == NULL)
+               if ((p = tfind(tid - THREAD_PID_OFFSET)) == NULL)
                        return (ESRCH);
 
                /* can only kill threads in the same process */
Index: sys/kern/kern_time.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_time.c,v
retrieving revision 1.98
diff -u -p -r1.98 kern_time.c
--- sys/kern/kern_time.c        3 Sep 2016 14:46:56 -0000       1.98
+++ sys/kern/kern_time.c        24 Jan 2017 00:05:16 -0000
@@ -141,7 +141,7 @@ clock_gettime(struct proc *p, clockid_t 
        default:
                /* check for clock from pthread_getcpuclockid() */
                if (__CLOCK_TYPE(clock_id) == CLOCK_THREAD_CPUTIME_ID) {
-                       q = pfind(__CLOCK_PTID(clock_id) - THREAD_PID_OFFSET);
+                       q = tfind(__CLOCK_PTID(clock_id) - THREAD_PID_OFFSET);
                        if (q == NULL || q->p_p != p->p_p)
                                return (ESRCH);
                        *tp = q->p_tu.tu_runtime;
@@ -232,7 +232,7 @@ sys_clock_getres(struct proc *p, void *v
        default:
                /* check for clock from pthread_getcpuclockid() */
                if (__CLOCK_TYPE(clock_id) == CLOCK_THREAD_CPUTIME_ID) {
-                       q = pfind(__CLOCK_PTID(clock_id) - THREAD_PID_OFFSET);
+                       q = tfind(__CLOCK_PTID(clock_id) - THREAD_PID_OFFSET);
                        if (q == NULL || q->p_p != p->p_p)
                                return (ESRCH);
                        ts.tv_sec = 0;
Index: sys/kern/sys_generic.c
===================================================================
RCS file: /cvs/src/sys/kern/sys_generic.c,v
retrieving revision 1.113
diff -u -p -r1.113 sys_generic.c
--- sys/kern/sys_generic.c      7 Nov 2016 00:26:33 -0000       1.113
+++ sys/kern/sys_generic.c      24 Jan 2017 00:05:21 -0000
@@ -783,7 +783,7 @@ selrecord(struct proc *selector, struct 
        mytid = selector->p_tid;
        if (sip->si_seltid == mytid)
                return;
-       if (sip->si_seltid && (p = pfind(sip->si_seltid)) &&
+       if (sip->si_seltid && (p = tfind(sip->si_seltid)) &&
            p->p_wchan == (caddr_t)&selwait)
                sip->si_flags |= SI_COLL;
        else
@@ -807,7 +807,7 @@ selwakeup(struct selinfo *sip)
                sip->si_flags &= ~SI_COLL;
                wakeup(&selwait);
        }
-       p = pfind(sip->si_seltid);
+       p = tfind(sip->si_seltid);
        sip->si_seltid = 0;
        if (p != NULL) {
                SCHED_LOCK(s);
Index: sys/kern/sys_process.c
===================================================================
RCS file: /cvs/src/sys/kern/sys_process.c,v
retrieving revision 1.74
diff -u -p -r1.74 sys_process.c
--- sys/kern/sys_process.c      7 Nov 2016 00:26:33 -0000       1.74
+++ sys/kern/sys_process.c      24 Jan 2017 00:05:25 -0000
@@ -156,7 +156,7 @@ sys_ptrace(struct proc *p, void *v, regi
        case PT_SETXMMREGS:
 #endif
                if (SCARG(uap, pid) > THREAD_PID_OFFSET) {
-                       t = pfind(SCARG(uap, pid) - THREAD_PID_OFFSET);
+                       t = tfind(SCARG(uap, pid) - THREAD_PID_OFFSET);
                        if (t == NULL)
                                return (ESRCH);
                        tr = t->p_p;
@@ -316,7 +316,7 @@ sys_ptrace(struct proc *p, void *v, regi
                        if (error)
                                return (error);
 
-                       t = pfind(pts.pts_tid - THREAD_PID_OFFSET);
+                       t = tfind(pts.pts_tid - THREAD_PID_OFFSET);
                        if (t == NULL || ISSET(t->p_flag, P_WEXIT))
                                return (ESRCH);
                        if (t->p_p != tr)
Index: sys/sys/proc.h
===================================================================
RCS file: /cvs/src/sys/sys/proc.h,v
retrieving revision 1.229
diff -u -p -r1.229 proc.h
--- sys/sys/proc.h      21 Jan 2017 05:42:03 -0000      1.229
+++ sys/sys/proc.h      24 Jan 2017 00:08:52 -0000
@@ -501,7 +501,7 @@ void        freepid(pid_t);
 
 struct process *prfind(pid_t); /* Find process by id. */
 struct process *zombiefind(pid_t); /* Find zombie process by id. */
-struct proc *pfind(pid_t);     /* Find thread by id. */
+struct proc *tfind(pid_t);     /* Find thread by id. */
 struct pgrp *pgfind(pid_t);    /* Find process group by id. */
 void   proc_printit(struct proc *p, const char *modif,
     int (*pr)(const char *, ...));
Index: share/man/man9/Makefile
===================================================================
RCS file: /cvs/src/share/man/man9/Makefile,v
retrieving revision 1.284
diff -u -p -r1.284 Makefile
--- share/man/man9/Makefile     20 Nov 2016 12:05:25 -0000      1.284
+++ share/man/man9/Makefile     24 Jan 2017 00:08:08 -0000
@@ -25,7 +25,7 @@ MAN=  aml_evalnode.9 atomic_add_int.9 ato
        malloc.9 membar_sync.9 mbuf.9 mbuf_tags.9 md5.9 mi_switch.9 \
        microtime.9 ml_init.9 mq_init.9 mutex.9 \
        namei.9 \
-       panic.9 pci_conf_read.9 pci_intr_map.9 pfind.9 physio.9 pmap.9 \
+       panic.9 pci_conf_read.9 pci_intr_map.9 physio.9 pmap.9 \
        pool.9 ppsratecheck.9 printf.9 psignal.9 \
        RBT_INIT.9 \
        radio.9 arc4random.9 rasops.9 ratecheck.9 refcnt_init.9 resettodr.9 \
@@ -34,7 +34,7 @@ MAN=  aml_evalnode.9 atomic_add_int.9 ato
        sensor_attach.9 \
        spl.9 srp_enter.9 srpl_rc_init.9 startuphook_establish.9 \
        socreate.9 sosplice.9 style.9 syscall.9 sysctl_int.9 \
-       task_add.9 tc_init.9 time_second.9 timeout.9 tsleep.9 tvtohz.9 \
+       task_add.9 tc_init.9 tfind.9 time_second.9 timeout.9 tsleep.9 tvtohz.9 \
        uiomove.9 uvm.9 usb_add_task.9 usbd_close_pipe.9 usbd_open_pipe.9 \
        usbd_ref_wait.9 usbd_transfer.9 vfs.9 vfs_busy.9 \
        vfs_cache.9 vaccess.9 vclean.9 vcount.9 vdevgone.9 vfinddev.9 vflush.9 \
Index: share/man/man9/pfind.9
===================================================================
RCS file: share/man/man9/pfind.9
diff -N share/man/man9/pfind.9
--- share/man/man9/pfind.9      4 Jun 2013 19:27:11 -0000       1.7
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,53 +0,0 @@
-.\"    $OpenBSD: pfind.9,v 1.7 2013/06/04 19:27:11 schwarze Exp $
-.\"
-.\" Copyright (c) 1999 Marc Espie
-.\" All rights reserved.
-.\"
-.\" 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.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
-.\"
-.Dd $Mdocdate: June 4 2013 $
-.Dt PFIND 9
-.Os
-.Sh NAME
-.Nm pfind ,
-.Nm pgfind
-.Nd find process / process group by number
-.Sh SYNOPSIS
-.In sys/cdefs.h
-.In sys/proc.h
-.Ft "struct proc *"
-.Fn pfind "pid_t pid"
-.Ft "struct pgrp *"
-.Fn pgfind "pid_t pgid"
-.Sh DESCRIPTION
-The
-.Fn pfind
-and
-.Fn pgfind
-functions retrieve process and progress group structures from process and
-process group IDs.
-.Pp
-Both functions return
-.Dv NULL
-if the requested ID can't be found.
-.Sh CODE REFERENCES
-Those functions are implemented in the file
-.Pa sys/kern/kern_proc.c .
Index: share/man/man9/tfind.9
===================================================================
RCS file: share/man/man9/tfind.9
diff -N share/man/man9/tfind.9
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ share/man/man9/tfind.9      24 Jan 2017 00:07:27 -0000
@@ -0,0 +1,53 @@
+.\"    $OpenBSD: tfind.9,v 1.7 2013/06/04 19:27:11 schwarze Exp $
+.\"
+.\" Copyright (c) 1999 Marc Espie
+.\" All rights reserved.
+.\"
+.\" 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.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+.\"
+.Dd $Mdocdate: June 4 2013 $
+.Dt tfind 9
+.Os
+.Sh NAME
+.Nm tfind ,
+.Nm pgfind
+.Nd find thread / process group by number
+.Sh SYNOPSIS
+.In sys/cdefs.h
+.In sys/proc.h
+.Ft "struct proc *"
+.Fn tfind "pid_t tid"
+.Ft "struct pgrp *"
+.Fn pgfind "pid_t pgid"
+.Sh DESCRIPTION
+The
+.Fn tfind
+and
+.Fn pgfind
+functions retrieve thread and progress group structures from thread and
+process group IDs.
+.Pp
+Both functions return
+.Dv NULL
+if the requested ID can't be found.
+.Sh CODE REFERENCES
+Those functions are implemented in the file
+.Pa sys/kern/kern_proc.c .

Reply via email to