]>
git.saurik.com Git - apple/xnu.git/blob - libsyscall/wrappers/select-base.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@
24 #if defined(__LP64__) && (defined(VARIANT_CANCELABLE) || defined(VARIANT_PRE1050))
25 #undef __DARWIN_NON_CANCELABLE
26 #define __DARWIN_NON_CANCELABLE 0
27 #endif /* __LP64__ && (VARIANT_CANCELABLE || VARIANT_PRE1050) */
29 #include <sys/select.h>
32 #if defined(VARIANT_CANCELABLE) || defined(VARIANT_PRE1050)
33 extern int __select(int, fd_set
* __restrict
, fd_set
* __restrict
,
34 fd_set
* __restrict
, struct timeval
* __restrict
);
35 #else /* !VARIANT_CANCELABLE && !VARIANT_PRE1050 */
36 int __select_nocancel(int, fd_set
* __restrict
, fd_set
* __restrict
,
37 fd_set
* __restrict
, struct timeval
* __restrict
);
38 #endif /* VARIANT_CANCELABLE || VARIANT_PRE1050 */
41 * select stub, return error if nfds > FD_SETSIZE
42 * add pthread cancelability
43 * mandated for conformance.
45 * This is only for (non DARWINEXTSN) UNIX03 (both cancelable and
46 * non-cancelable) and for legacy
49 select(int nfds
, fd_set
* __restrict readfds
, fd_set
* __restrict writefds
,
50 fd_set
* __restrict exceptfds
, struct timeval
* __restrict
51 #if defined(VARIANT_LEGACY) || defined(VARIANT_PRE1050)
53 #else /* !VARIANT_LEGACY && !VARIANT_PRE1050 */
55 #endif /* VARIANT_LEGACY || VARIANT_PRE1050 */
59 #if defined(VARIANT_LEGACY) || defined(VARIANT_PRE1050)
60 struct timeval tb
, *timeout
;
63 * Legacy select behavior is minimum 10 msec when tv_usec is non-zero
65 if (intimeout
&& intimeout
->tv_sec
== 0 && intimeout
->tv_usec
> 0 && intimeout
->tv_usec
< 10000) {
71 #else /* !VARIANT_LEGACY && !VARIANT_PRE1050 */
72 if (nfds
> FD_SETSIZE
) {
76 #endif /* VARIANT_LEGACY || VARIANT_PRE1050 */
77 #if defined(VARIANT_CANCELABLE) || defined(VARIANT_PRE1050)
78 return __select(nfds
, readfds
, writefds
, exceptfds
, timeout
);
79 #else /* !VARIANT_CANCELABLE && !VARIANT_PRE1050 */
80 return __select_nocancel(nfds
, readfds
, writefds
, exceptfds
, timeout
);
81 #endif /* VARIANT_CANCELABLE || VARIANT_PRE1050 */