epoc32/include/stdapis/sys/select.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 0 061f57f2323e
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
/*-
williamr@2
     2
 * Copyright (c) 1992, 1993
williamr@2
     3
 *	The Regents of the University of California.  All rights reserved.
williamr@2
     4
 *
williamr@2
     5
 * Redistribution and use in source and binary forms, with or without
williamr@2
     6
 * modification, are permitted provided that the following conditions
williamr@2
     7
 * are met:
williamr@2
     8
 * 1. Redistributions of source code must retain the above copyright
williamr@2
     9
 *    notice, this list of conditions and the following disclaimer.
williamr@2
    10
 * 2. Redistributions in binary form must reproduce the above copyright
williamr@2
    11
 *    notice, this list of conditions and the following disclaimer in the
williamr@2
    12
 *    documentation and/or other materials provided with the distribution.
williamr@2
    13
 * 4. Neither the name of the University nor the names of its contributors
williamr@2
    14
 *    may be used to endorse or promote products derived from this software
williamr@2
    15
 *    without specific prior written permission.
williamr@2
    16
 *
williamr@2
    17
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
williamr@2
    18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
williamr@2
    19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
williamr@2
    20
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
williamr@2
    21
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
williamr@2
    22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
williamr@2
    23
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
williamr@2
    24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
williamr@2
    25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
williamr@2
    26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
williamr@2
    27
 * SUCH DAMAGE.
williamr@2
    28
 *
williamr@2
    29
 * $FreeBSD: src/sys/sys/select.h,v 1.19 2004/04/07 04:19:49 imp Exp $
williamr@2
    30
 */
williamr@2
    31
williamr@2
    32
#ifndef _SYS_SELECT_H_
williamr@2
    33
#define	_SYS_SELECT_H_
williamr@2
    34
williamr@2
    35
#include <sys/cdefs.h>
williamr@2
    36
#include <sys/_types.h>
williamr@2
    37
williamr@2
    38
#include <sys/_sigset.h>
williamr@2
    39
#include <sys/_timeval.h>
williamr@2
    40
#include <sys/timespec.h>
williamr@2
    41
williamr@2
    42
williamr@2
    43
typedef	unsigned long	__fd_mask;
williamr@2
    44
#if __BSD_VISIBLE
williamr@2
    45
typedef	__fd_mask	fd_mask;
williamr@2
    46
#endif
williamr@2
    47
williamr@2
    48
#ifndef _SIGSET_T_DECLARED
williamr@2
    49
#define	_SIGSET_T_DECLARED
williamr@2
    50
typedef	__uint64_t sigset_t;
williamr@2
    51
#endif
williamr@2
    52
williamr@2
    53
/*
williamr@2
    54
 * Select uses bit masks of file descriptors in longs.  These macros
williamr@2
    55
 * manipulate such bit fields (the filesystem macros use chars).
williamr@2
    56
 * FD_SETSIZE may be defined by the user, but the default here should
williamr@2
    57
 * be enough for most uses.
williamr@2
    58
 */
williamr@2
    59
#ifndef	FD_SETSIZE
williamr@2
    60
#define	FD_SETSIZE	1024U
williamr@2
    61
#endif
williamr@2
    62
williamr@2
    63
#define	_NFDBITS	(sizeof(__fd_mask) * 8)	/* bits per mask */
williamr@2
    64
#if __BSD_VISIBLE
williamr@2
    65
#define	NFDBITS		_NFDBITS
williamr@2
    66
#endif
williamr@2
    67
williamr@2
    68
#ifndef _howmany
williamr@2
    69
#define	_howmany(x, y)	(((x) + ((y) - 1)) / (y))
williamr@2
    70
#endif
williamr@2
    71
williamr@2
    72
typedef	struct fd_set {
williamr@2
    73
	__fd_mask	__fds_bits[_howmany(FD_SETSIZE, _NFDBITS)];
williamr@2
    74
} fd_set;
williamr@2
    75
#if __BSD_VISIBLE
williamr@2
    76
#define	fds_bits	__fds_bits
williamr@2
    77
#endif
williamr@2
    78
williamr@2
    79
#define	__fdset_mask(n)	((__fd_mask)1 << ((n) % _NFDBITS))
williamr@2
    80
#define	FD_CLR(n, p)	((p)->__fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n))
williamr@2
    81
#if __BSD_VISIBLE
williamr@2
    82
#define	FD_COPY(f, t)	(void)(*(t) = *(f))
williamr@2
    83
#endif
williamr@2
    84
#define	FD_ISSET(n, p)	((p)->__fds_bits[(n)/_NFDBITS] & __fdset_mask(n))
williamr@2
    85
#define	FD_SET(n, p)	((p)->__fds_bits[(n)/_NFDBITS] |= __fdset_mask(n))
williamr@2
    86
#define	FD_ZERO(p) do {					\
williamr@2
    87
	fd_set *_p;					\
williamr@2
    88
	__size_t _n;					\
williamr@2
    89
							\
williamr@2
    90
	_p = (p);					\
williamr@2
    91
	_n = _howmany(FD_SETSIZE, _NFDBITS);		\
williamr@2
    92
	while (_n > 0)					\
williamr@2
    93
		_p->__fds_bits[--_n] = 0;		\
williamr@2
    94
} while (0)
williamr@2
    95
williamr@2
    96
#ifndef _KERNEL
williamr@2
    97
williamr@2
    98
__BEGIN_DECLS
williamr@2
    99
#ifndef _SELECT_DECLARED
williamr@2
   100
#define	_SELECT_DECLARED
williamr@2
   101
/* XXX missing restrict type-qualifier */
williamr@2
   102
IMPORT_C int	select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
williamr@2
   103
#endif
williamr@2
   104
__END_DECLS
williamr@2
   105
#endif /* !_KERNEL */
williamr@2
   106
williamr@2
   107
#endif /* _SYS_SELECT_H_ */