* Copyright (c) 1982, 1986, 1991, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
* %sccs.include.redist.c%
* @(#)kern_subr.c 8.4 (Berkeley) %G%
register struct uio
*uio
;
register struct iovec
*iov
;
if (uio
->uio_rw
!= UIO_READ
&& uio
->uio_rw
!= UIO_WRITE
)
if (uio
->uio_segflg
== UIO_USERSPACE
&& uio
->uio_procp
!= curproc
)
while (n
> 0 && uio
->uio_resid
) {
switch (uio
->uio_segflg
) {
if (uio
->uio_rw
== UIO_READ
)
error
= copyout(cp
, iov
->iov_base
, cnt
);
error
= copyin(iov
->iov_base
, cp
, cnt
);
if (uio
->uio_rw
== UIO_READ
)
bcopy((caddr_t
)cp
, iov
->iov_base
, cnt
);
bcopy(iov
->iov_base
, (caddr_t
)cp
, cnt
);
* Give next character to user as result of read.
register struct uio
*uio
;
register struct iovec
*iov
;
panic("ureadc: non-positive resid");
if (uio
->uio_iovcnt
<= 0)
panic("ureadc: non-positive iovcnt");
switch (uio
->uio_segflg
) {
if (subyte(iov
->iov_base
, c
) < 0)
if (suibyte(iov
->iov_base
, c
) < 0)
#ifdef vax /* unused except by ct.c, other oddities XXX */
* Get next character written in by user from uio.
register struct iovec
*iov
;
if (uio
->uio_iovcnt
<= 0)
panic("uwritec: non-positive iovcnt");
if (--uio
->uio_iovcnt
== 0)
switch (uio
->uio_segflg
) {
c
= fubyte(iov
->iov_base
);
c
= *(u_char
*) iov
->iov_base
;
c
= fuibyte(iov
->iov_base
);
* General routine to allocate a hash table.
hashinit(elements
, type
, hashmask
)
LIST_HEAD(generic
, generic
) *hashtbl
;
panic("hashinit: bad cnt");
for (hashsize
= 1; hashsize
<= elements
; hashsize
<<= 1)
hashtbl
= malloc((u_long
)hashsize
* sizeof(*hashtbl
), type
, M_WAITOK
);
for (i
= 0; i
< hashsize
; i
++)
*hashmask
= hashsize
- 1;