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