1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/openenvcore/include/sys/select.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,107 @@
1.4 +/*-
1.5 + * Copyright (c) 1992, 1993
1.6 + * The Regents of the University of California. All rights reserved.
1.7 + *
1.8 + * Redistribution and use in source and binary forms, with or without
1.9 + * modification, are permitted provided that the following conditions
1.10 + * are met:
1.11 + * 1. Redistributions of source code must retain the above copyright
1.12 + * notice, this list of conditions and the following disclaimer.
1.13 + * 2. Redistributions in binary form must reproduce the above copyright
1.14 + * notice, this list of conditions and the following disclaimer in the
1.15 + * documentation and/or other materials provided with the distribution.
1.16 + * 4. Neither the name of the University nor the names of its contributors
1.17 + * may be used to endorse or promote products derived from this software
1.18 + * without specific prior written permission.
1.19 + *
1.20 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1.21 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.22 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1.23 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1.24 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1.25 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1.26 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.27 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1.28 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1.29 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1.30 + * SUCH DAMAGE.
1.31 + *
1.32 + * $FreeBSD: src/sys/sys/select.h,v 1.19 2004/04/07 04:19:49 imp Exp $
1.33 + */
1.34 +
1.35 +#ifndef _SYS_SELECT_H_
1.36 +#define _SYS_SELECT_H_
1.37 +
1.38 +#include <sys/cdefs.h>
1.39 +#include <sys/_types.h>
1.40 +
1.41 +#include <sys/_sigset.h>
1.42 +#include <sys/_timeval.h>
1.43 +#include <sys/timespec.h>
1.44 +
1.45 +
1.46 +typedef unsigned long __fd_mask;
1.47 +#if __BSD_VISIBLE
1.48 +typedef __fd_mask fd_mask;
1.49 +#endif
1.50 +
1.51 +#ifndef _SIGSET_T_DECLARED
1.52 +#define _SIGSET_T_DECLARED
1.53 +typedef __uint64_t sigset_t;
1.54 +#endif
1.55 +
1.56 +/*
1.57 + * Select uses bit masks of file descriptors in longs. These macros
1.58 + * manipulate such bit fields (the filesystem macros use chars).
1.59 + * FD_SETSIZE may be defined by the user, but the default here should
1.60 + * be enough for most uses.
1.61 + */
1.62 +#ifndef FD_SETSIZE
1.63 +#define FD_SETSIZE 1024U
1.64 +#endif
1.65 +
1.66 +#define _NFDBITS (sizeof(__fd_mask) * 8) /* bits per mask */
1.67 +#if __BSD_VISIBLE
1.68 +#define NFDBITS _NFDBITS
1.69 +#endif
1.70 +
1.71 +#ifndef _howmany
1.72 +#define _howmany(x, y) (((x) + ((y) - 1)) / (y))
1.73 +#endif
1.74 +
1.75 +typedef struct fd_set {
1.76 + __fd_mask __fds_bits[_howmany(FD_SETSIZE, _NFDBITS)];
1.77 +} fd_set;
1.78 +#if __BSD_VISIBLE
1.79 +#define fds_bits __fds_bits
1.80 +#endif
1.81 +
1.82 +#define __fdset_mask(n) ((__fd_mask)1 << ((n) % _NFDBITS))
1.83 +#define FD_CLR(n, p) ((p)->__fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n))
1.84 +#if __BSD_VISIBLE
1.85 +#define FD_COPY(f, t) (void)(*(t) = *(f))
1.86 +#endif
1.87 +#define FD_ISSET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] & __fdset_mask(n))
1.88 +#define FD_SET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] |= __fdset_mask(n))
1.89 +#define FD_ZERO(p) do { \
1.90 + fd_set *_p; \
1.91 + __size_t _n; \
1.92 + \
1.93 + _p = (p); \
1.94 + _n = _howmany(FD_SETSIZE, _NFDBITS); \
1.95 + while (_n > 0) \
1.96 + _p->__fds_bits[--_n] = 0; \
1.97 +} while (0)
1.98 +
1.99 +#ifndef _KERNEL
1.100 +
1.101 +__BEGIN_DECLS
1.102 +#ifndef _SELECT_DECLARED
1.103 +#define _SELECT_DECLARED
1.104 +/* XXX missing restrict type-qualifier */
1.105 +IMPORT_C int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
1.106 +#endif
1.107 +__END_DECLS
1.108 +#endif /* !_KERNEL */
1.109 +
1.110 +#endif /* _SYS_SELECT_H_ */