]>
git.saurik.com Git - apple/libc.git/blob - sys/select.c
2 * Copyright (c) 2005, 2007 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 #if defined(__LP64__) && (defined(VARIANT_CANCELABLE) || defined(VARIANT_PRE1050))
24 #undef __DARWIN_NON_CANCELABLE
25 #define __DARWIN_NON_CANCELABLE 0
26 #endif /* __LP64__ && (VARIANT_CANCELABLE || VARIANT_PRE1050) */
27 #include <sys/select.h>
30 #if defined(VARIANT_CANCELABLE) || defined(VARIANT_PRE1050)
31 extern int __select(int, fd_set
* __restrict
, fd_set
* __restrict
,
32 fd_set
* __restrict
, struct timeval
* __restrict
);
33 #else /* !VARIANT_CANCELABLE && !VARIANT_PRE1050 */
34 int __select_nocancel(int, fd_set
* __restrict
, fd_set
* __restrict
,
35 fd_set
* __restrict
, struct timeval
* __restrict
);
36 #endif /* VARIANT_CANCELABLE || VARIANT_PRE1050 */
39 * select stub, return error if nfds > FD_SETSIZE
40 * add pthread cancelability
41 * mandated for conformance.
43 * This is only for (non DARWINEXTSN) UNIX03 (both cancelable and
44 * non-cancelable) and for legacy
47 select(int nfds
, fd_set
* __restrict readfds
, fd_set
* __restrict writefds
,
48 fd_set
* __restrict exceptfds
, struct timeval
* __restrict
49 #if defined(VARIANT_LEGACY) || defined(VARIANT_PRE1050)
51 #else /* !VARIANT_LEGACY && !VARIANT_PRE1050 */
53 #endif /* VARIANT_LEGACY || VARIANT_PRE1050 */
57 #if defined(VARIANT_LEGACY) || defined(VARIANT_PRE1050)
58 struct timeval tb
, *timeout
;
61 * Legacy select behavior is minimum 10 msec when tv_usec is non-zero
63 if (intimeout
&& intimeout
->tv_sec
== 0 && intimeout
->tv_usec
> 0 && intimeout
->tv_usec
< 10000) {
69 #else /* !VARIANT_LEGACY && !VARIANT_PRE1050 */
70 if (nfds
> FD_SETSIZE
) {
74 #endif /* VARIANT_LEGACY || VARIANT_PRE1050 */
75 #if defined(VARIANT_CANCELABLE) || defined(VARIANT_PRE1050)
76 return __select(nfds
, readfds
, writefds
, exceptfds
, timeout
);
77 #else /* !VARIANT_CANCELABLE && !VARIANT_PRE1050 */
78 return __select_nocancel(nfds
, readfds
, writefds
, exceptfds
, timeout
);
79 #endif /* VARIANT_CANCELABLE || VARIANT_PRE1050 */