equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * CDDL HEADER START |
2 * CDDL HEADER START |
3 * |
3 * |
4 * The contents of this file are subject to the terms of the |
4 * The contents of this file are subject to the terms of the |
5 * Common Development and Distribution License, Version 1.0 only |
5 * Common Development and Distribution License (the "License"). |
6 * (the "License"). You may not use this file except in compliance |
6 * You may not use this file except in compliance with the License. |
7 * with the License. |
|
8 * |
7 * |
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
10 * or http://www.opensolaris.org/os/licensing. |
9 * or http://www.opensolaris.org/os/licensing. |
11 * See the License for the specific language governing permissions |
10 * See the License for the specific language governing permissions |
12 * and limitations under the License. |
11 * and limitations under the License. |
17 * fields enclosed by brackets "[]" replaced with your own identifying |
16 * fields enclosed by brackets "[]" replaced with your own identifying |
18 * information: Portions Copyright [yyyy] [name of copyright owner] |
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
19 * |
18 * |
20 * CDDL HEADER END |
19 * CDDL HEADER END |
21 */ |
20 */ |
22 /* |
21 |
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. |
22 /* |
|
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
24 * Use is subject to license terms. |
24 * Use is subject to license terms. |
25 */ |
25 */ |
26 |
26 |
27 #pragma ident "%Z%%M% %I% %E% SMI" |
27 #pragma ident "%Z%%M% %I% %E% SMI" |
28 |
28 |
29 /* Copyright (c) 1988 AT&T */ |
29 /* Copyright (c) 1988 AT&T */ |
30 /* All Rights Reserved */ |
30 /* All Rights Reserved */ |
31 |
|
32 |
31 |
33 /* |
32 /* |
34 * Emulation of select() system call using _pollsys() system call. |
33 * Emulation of select() system call using _pollsys() system call. |
35 * |
34 * |
36 * Assumptions: |
35 * Assumptions: |
351 timespec_t *tsp; |
350 timespec_t *tsp; |
352 |
351 |
353 if (tv == NULL) |
352 if (tv == NULL) |
354 tsp = NULL; |
353 tsp = NULL; |
355 else { |
354 else { |
|
355 /* check timeval validity */ |
356 if (tv->tv_usec < 0 || tv->tv_usec >= MICROSEC) { |
356 if (tv->tv_usec < 0 || tv->tv_usec >= MICROSEC) { |
357 errno = EINVAL; |
357 errno = EINVAL; |
358 return (-1); |
358 return (-1); |
359 } |
359 } |
|
360 /* |
|
361 * Convert timeval to timespec. |
|
362 * To preserve compatibility with past behavior, |
|
363 * when select was built upon poll(2), which has a |
|
364 * minimum non-zero timeout of 1 millisecond, force |
|
365 * a minimum non-zero timeout of 500 microseconds. |
|
366 */ |
360 ts.tv_sec = tv->tv_sec; |
367 ts.tv_sec = tv->tv_sec; |
361 ts.tv_nsec = tv->tv_usec * 1000; |
368 ts.tv_nsec = tv->tv_usec * 1000; |
|
369 if (ts.tv_nsec != 0 && ts.tv_nsec < 500000) |
|
370 ts.tv_nsec = 500000; |
362 tsp = &ts; |
371 tsp = &ts; |
363 } |
372 } |
364 |
373 |
365 return (pselect_large_fdset(nfds, in0, out0, ex0, tsp, NULL)); |
374 return (pselect_large_fdset(nfds, in0, out0, ex0, tsp, NULL)); |
366 } |
375 } |