Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Make copy{in, out}_proc work on all processes (inclu...



details:   https://anonhg.NetBSD.org/src/rev/542a30ed2643
branches:  trunk
changeset: 582813:542a30ed2643
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Jul 06 22:30:42 2005 +0000

description:
Make copy{in,out}_proc work on all processes (including curproc) by
special-casing the curproc case. Use copy{in,out}_proc directly instead
of checking for curproc each time. Discussed with thorpej.

diffstat:

 sys/kern/core_elf32.c |  12 ++++--------
 sys/kern/kern_subr.c  |  27 ++++++++++++---------------
 2 files changed, 16 insertions(+), 23 deletions(-)

diffs (95 lines):

diff -r a49cf211b8bd -r 542a30ed2643 sys/kern/core_elf32.c
--- a/sys/kern/core_elf32.c     Wed Jul 06 21:13:02 2005 +0000
+++ b/sys/kern/core_elf32.c     Wed Jul 06 22:30:42 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: core_elf32.c,v 1.20 2005/07/06 20:56:49 kleink Exp $   */
+/*     $NetBSD: core_elf32.c,v 1.21 2005/07/06 22:30:42 christos Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.20 2005/07/06 20:56:49 kleink Exp $");
+__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.21 2005/07/06 22:30:42 christos Exp $");
 
 /* If not included by core_elf64.c, ELFSIZE won't be defined. */
 #ifndef ELFSIZE
@@ -268,12 +268,8 @@
                int i;
 
                end -= slen;
-               if (__predict_true(p == curproc))
-                       error = copyin((void *) end, buf, slen);
-               else
-                       error = copyin_proc(p, (void *) end, buf, slen);
-               if (error)
-                       return (error);
+               if ((error = copyin_proc(p, (void *)end, buf, slen)) != 0)
+                       return error;
 
                ep = (const long *) &buf[slen / sizeof(buf[0])];
                for (i = 0, ep--; buf <= ep; ep--, i++) {
diff -r a49cf211b8bd -r 542a30ed2643 sys/kern/kern_subr.c
--- a/sys/kern/kern_subr.c      Wed Jul 06 21:13:02 2005 +0000
+++ b/sys/kern/kern_subr.c      Wed Jul 06 22:30:42 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_subr.c,v 1.117 2005/06/23 23:15:12 thorpej Exp $  */
+/*     $NetBSD: kern_subr.c,v 1.118 2005/07/06 22:30:42 christos Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
@@ -86,7 +86,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.117 2005/06/23 23:15:12 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.118 2005/07/06 22:30:42 christos Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -170,19 +170,10 @@
                        if (curcpu()->ci_schedstate.spc_flags &
                            SPCF_SHOULDYIELD)
                                preempt(1);
-                       if (__predict_true(p == curproc)) {
-                               if (uio->uio_rw == UIO_READ)
-                                       error = copyout(cp, iov->iov_base, cnt);
-                               else
-                                       error = copyin(iov->iov_base, cp, cnt);
-                       } else {
-                               if (uio->uio_rw == UIO_READ)
-                                       error = copyout_proc(p, cp,
-                                           iov->iov_base, cnt);
-                               else
-                                       error = copyin_proc(p, iov->iov_base,
-                                           cp, cnt);
-                       }
+                       if (uio->uio_rw == UIO_READ)
+                               error = copyout_proc(p, cp, iov->iov_base, cnt);
+                       else
+                               error = copyin_proc(p, iov->iov_base, cp, cnt);
                        if (error)
                                goto out;
                        break;
@@ -276,6 +267,9 @@
        if (len == 0)
                return (0);
 
+       if (__predict_true(p == curproc))
+               return copyin(uaddr, kaddr, len);
+
        iov.iov_base = kaddr;
        iov.iov_len = len;
        uio.uio_iov = &iov;
@@ -309,6 +303,9 @@
        if (len == 0)
                return (0);
 
+       if (__predict_true(p == curproc))
+               return copyout(kaddr, uaddr, len);
+
        iov.iov_base = __UNCONST(kaddr); /* XXXUNCONST cast away const */
        iov.iov_len = len;
        uio.uio_iov = &iov;



Home | Main Index | Thread Index | Old Index