4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
24 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 /* Copyright (c) 1988 AT&T */
29 /* All Rights Reserved */
31 #pragma ident "%Z%%M% %I% %E% SMI"
34 #include <sys/select.h>
35 #include <sys/types.h>
42 * Given an fd_set pointer and the number of bits to check in it,
43 * initialize the supplied pollfd array for RPC's use (RPC only
44 * polls for input events). We return the number of pollfd slots
49 int fdmax
, /* number of bits we must test */
50 fd_set
*fdset
, /* source fd_set array */
51 struct pollfd
*p0
) /* target pollfd array */
53 int j
; /* loop counter */
55 struct pollfd
*p
= p0
;
58 * For each fd, if the appropriate bit is set convert it into
59 * the appropriate pollfd struct.
61 j
= ((fdmax
>= FD_SETSIZE
) ? FD_SETSIZE
: fdmax
);
62 for (n
= 0; n
< j
; n
++) {
63 if (FD_ISSET(n
, fdset
)) {
74 * Arguments are similar to rpc_select_to_poll() except that
75 * the second argument is pointer to an array of pollfd_t
76 * which is the source array which will be compressed and
77 * copied to the target array in p0. The size of the
78 * source argument is given by pollfdmax. The array can be
79 * sparse. The space for the target is allocated before
80 * calling this function. It should have atleast pollfdmax
81 * elements. This function scans the source pollfd array
82 * and copies only the valid ones to the target p0.
85 __rpc_compress_pollfd(int pollfdmax
, pollfd_t
*srcp
, pollfd_t
*p0
)
90 for (n
= 0; n
< pollfdmax
; n
++) {
91 if (POLLFD_ISSET(n
, srcp
)) {
93 p
->events
= srcp
[n
].events
;
102 * Convert from timevals (used by select) to milliseconds (used by poll).
105 __rpc_timeval_to_msec(struct timeval
*t
)
110 * We're really returning t->tv_sec * 1000 + (t->tv_usec / 1000)
111 * but try to do so efficiently. Note: 1000 = 1024 - 16 - 8.
113 tmp
= (int)t
->tv_sec
<< 3;
118 t1
+= t
->tv_usec
/ 1000;