|
|
1.1 root 1: /* $Header: fd.h,v 1.1 87/09/11 07:59:18 toddb Exp $ */
2: /*
3: * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
4: *
5: * All Rights Reserved
6: *
7: * Permission to use, copy, modify, and distribute this software and its
8: * documentation for any purpose and without fee is hereby granted,
9: * provided that the above copyright notice appear in all copies and that
10: * both that copyright notice and this permission notice appear in
11: * supporting documentation, and that the name of Digital Equipment
12: * Corporation not be used in advertising or publicity pertaining to
13: * distribution of the software without specific, written prior permission.
14: *
15: *
16: * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
17: * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
18: * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
19: * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20: * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
21: * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
22: * SOFTWARE.
23: */
24:
25: #ifndef __fd_set
26: #define __fd_set
27: #ifndef NBBY
28: #define NBBY 8 /* number of bits in a byte */
29: #endif
30: /*
31: * Select uses bit masks of file descriptors in longs.
32: * These macros manipulate such bit fields (the filesystem macros use chars).
33: * FD_SETSIZE may be defined by the user, but the default here
34: * should be >= NOFILE (param.h).
35: */
36: #ifndef FD_SETSIZE
37: #define FD_SETSIZE 256
38: #endif
39:
40: typedef long fd_mask;
41: #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
42: #ifndef howmany
43: #define howmany(x, y) (((x)+((y)-1))/(y))
44: #endif
45:
46: typedef struct Fd_set {
47: fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
48: } Fd_set;
49:
50: #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
51: #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
52: #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
53:
54: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.