sys_generic.c (31364) | sys_generic.c (34961) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)sys_generic.c 8.5 (Berkeley) 1/21/94 | 1/* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)sys_generic.c 8.5 (Berkeley) 1/21/94 |
39 * $Id: sys_generic.c,v 1.32 1997/11/06 19:29:20 phk Exp $ | 39 * $Id: sys_generic.c,v 1.33 1997/11/23 10:30:50 bde Exp $ |
40 */ 41 42#include "opt_ktrace.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/sysproto.h> 47#include <sys/filedesc.h> --- 486 unchanged lines hidden (view full) --- 534 * The magic 2048 here is chosen to be just enough for FD_SETSIZE 535 * infds with the new FD_SETSIZE of 1024, and more than enough for 536 * FD_SETSIZE infds, outfds and exceptfds with the old FD_SETSIZE 537 * of 256. 538 */ 539 fd_mask s_selbits[howmany(2048, NFDBITS)]; 540 fd_mask *ibits[3], *obits[3], *selbits, *sbp; 541 struct timeval atv; | 40 */ 41 42#include "opt_ktrace.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/sysproto.h> 47#include <sys/filedesc.h> --- 486 unchanged lines hidden (view full) --- 534 * The magic 2048 here is chosen to be just enough for FD_SETSIZE 535 * infds with the new FD_SETSIZE of 1024, and more than enough for 536 * FD_SETSIZE infds, outfds and exceptfds with the old FD_SETSIZE 537 * of 256. 538 */ 539 fd_mask s_selbits[howmany(2048, NFDBITS)]; 540 fd_mask *ibits[3], *obits[3], *selbits, *sbp; 541 struct timeval atv; |
542 int s, ncoll, error, timo; | 542 int s, ncoll, error, timo, term; |
543 u_int nbufbytes, ncpbytes, nfdbits; 544 545 if (uap->nd < 0) 546 return (EINVAL); 547 if (uap->nd > p->p_fd->fd_nfiles) 548 uap->nd = p->p_fd->fd_nfiles; /* forgiving; slightly wrong */ 549 550 /* --- 44 unchanged lines hidden (view full) --- 595 error = copyin((caddr_t)uap->tv, (caddr_t)&atv, 596 sizeof (atv)); 597 if (error) 598 goto done; 599 if (itimerfix(&atv)) { 600 error = EINVAL; 601 goto done; 602 } | 543 u_int nbufbytes, ncpbytes, nfdbits; 544 545 if (uap->nd < 0) 546 return (EINVAL); 547 if (uap->nd > p->p_fd->fd_nfiles) 548 uap->nd = p->p_fd->fd_nfiles; /* forgiving; slightly wrong */ 549 550 /* --- 44 unchanged lines hidden (view full) --- 595 error = copyin((caddr_t)uap->tv, (caddr_t)&atv, 596 sizeof (atv)); 597 if (error) 598 goto done; 599 if (itimerfix(&atv)) { 600 error = EINVAL; 601 goto done; 602 } |
603 s = splclock(); 604 timevaladd(&atv, &time); 605 timo = hzto(&atv); 606 splx(s); | 603 timo = tvtohz(&atv); |
607 } else 608 timo = 0; | 604 } else 605 timo = 0; |
606 if (timo) 607 term = timo + ticks; |
|
609retry: 610 ncoll = nselcoll; 611 p->p_flag |= P_SELECT; 612 error = selscan(p, ibits, obits, uap->nd); 613 if (error || p->p_retval[0]) 614 goto done; 615 s = splhigh(); | 608retry: 609 ncoll = nselcoll; 610 p->p_flag |= P_SELECT; 611 error = selscan(p, ibits, obits, uap->nd); 612 if (error || p->p_retval[0]) 613 goto done; 614 s = splhigh(); |
616 /* this should be timercmp(&time, &atv, >=) */ 617 if (uap->tv && (time.tv_sec > atv.tv_sec || 618 (time.tv_sec == atv.tv_sec && time.tv_usec >= atv.tv_usec))) { | 615 if (timo && term <= ticks) { |
619 splx(s); 620 goto done; 621 } 622 if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) { 623 splx(s); 624 goto retry; 625 } 626 p->p_flag &= ~P_SELECT; --- 74 unchanged lines hidden (view full) --- 701int 702poll(p, uap) 703 register struct proc *p; 704 register struct poll_args *uap; 705{ 706 caddr_t bits; 707 char smallbits[32 * sizeof(struct pollfd)]; 708 struct timeval atv; | 616 splx(s); 617 goto done; 618 } 619 if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) { 620 splx(s); 621 goto retry; 622 } 623 p->p_flag &= ~P_SELECT; --- 74 unchanged lines hidden (view full) --- 698int 699poll(p, uap) 700 register struct proc *p; 701 register struct poll_args *uap; 702{ 703 caddr_t bits; 704 char smallbits[32 * sizeof(struct pollfd)]; 705 struct timeval atv; |
709 int s, ncoll, error = 0, timo; | 706 int s, ncoll, error = 0, timo, term; |
710 size_t ni; 711 712 if (SCARG(uap, nfds) > p->p_fd->fd_nfiles) { 713 /* forgiving; slightly wrong */ 714 SCARG(uap, nfds) = p->p_fd->fd_nfiles; 715 } 716 ni = SCARG(uap, nfds) * sizeof(struct pollfd); 717 if (ni > sizeof(smallbits)) --- 5 unchanged lines hidden (view full) --- 723 goto done; 724 if (SCARG(uap, timeout) != INFTIM) { 725 atv.tv_sec = SCARG(uap, timeout) / 1000; 726 atv.tv_usec = (SCARG(uap, timeout) % 1000) * 1000; 727 if (itimerfix(&atv)) { 728 error = EINVAL; 729 goto done; 730 } | 707 size_t ni; 708 709 if (SCARG(uap, nfds) > p->p_fd->fd_nfiles) { 710 /* forgiving; slightly wrong */ 711 SCARG(uap, nfds) = p->p_fd->fd_nfiles; 712 } 713 ni = SCARG(uap, nfds) * sizeof(struct pollfd); 714 if (ni > sizeof(smallbits)) --- 5 unchanged lines hidden (view full) --- 720 goto done; 721 if (SCARG(uap, timeout) != INFTIM) { 722 atv.tv_sec = SCARG(uap, timeout) / 1000; 723 atv.tv_usec = (SCARG(uap, timeout) % 1000) * 1000; 724 if (itimerfix(&atv)) { 725 error = EINVAL; 726 goto done; 727 } |
731 s = splclock(); 732 timevaladd(&atv, &time); 733 timo = hzto(&atv); 734 splx(s); | 728 timo = tvtohz(&atv); |
735 } else 736 timo = 0; | 729 } else 730 timo = 0; |
731 if (timo) 732 term = timo + ticks; |
|
737retry: 738 ncoll = nselcoll; 739 p->p_flag |= P_SELECT; 740 error = pollscan(p, (struct pollfd *)bits, SCARG(uap, nfds)); 741 if (error || p->p_retval[0]) 742 goto done; | 733retry: 734 ncoll = nselcoll; 735 p->p_flag |= P_SELECT; 736 error = pollscan(p, (struct pollfd *)bits, SCARG(uap, nfds)); 737 if (error || p->p_retval[0]) 738 goto done; |
743 s = splhigh(); 744 if (timo && timercmp(&time, &atv, >=)) { | 739 s = splhigh(); 740 if (timo && term <= ticks) { |
745 splx(s); 746 goto done; 747 } 748 if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) { 749 splx(s); 750 goto retry; 751 } 752 p->p_flag &= ~P_SELECT; --- 140 unchanged lines hidden --- | 741 splx(s); 742 goto done; 743 } 744 if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) { 745 splx(s); 746 goto retry; 747 } 748 p->p_flag &= ~P_SELECT; --- 140 unchanged lines hidden --- |