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