2 * Copyright 1990 Network Computing Devices;
3 * Portions Copyright 1987 by Digital Equipment Corporation
8 Copyright 1987, 1994, 1998 The Open Group
10 Permission to use, copy, modify, distribute, and sell this software and its
11 documentation for any purpose is hereby granted without fee, provided that
12 the above copyright notice appear in all copies and that both that
13 copyright notice and this permission notice appear in supporting
16 The above copyright notice and this permission notice shall be included
17 in all copies or substantial portions of the Software.
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 OTHER DEALINGS IN THE SOFTWARE.
27 Except as contained in this notice, the name of The Open Group shall
28 not be used in advertising or otherwise to promote the sale, use or
29 other dealings in this Software without prior written authorization
35 * FSlib networking & os include file
38 #include <X11/Xtrans/Xtrans.h>
43 * makedepend screws up on #undef OPEN_MAX, so we define a new symbol
52 # define _POSIX_SOURCE
59 # define SIZE_MAX ULONG_MAX
61 # define SIZE_MAX UINT_MAX
68 #include <sys/param.h>
74 #define OPEN_MAX NOFILE
76 #define OPEN_MAX NOFILES_MAX
84 #define FONT_OPEN_MAX 256
86 #define FONT_OPEN_MAX OPEN_MAX
89 #endif /* FONT_OPEN_MAX */
97 #define MSKCNT ((FONT_OPEN_MAX + NMSKBITS - 1) / NMSKBITS)
99 typedef unsigned long FdSet[MSKCNT];
100 typedef FdSet FdSetPtr;
103 #define BITMASK(i) (1 << (i))
108 #define BITMASK(i) (1 << ((i) & (NMSKBITS - 1)))
109 #define MASKIDX(i) ((i) / NMSKBITS)
112 #define MASKWORD(buf, i) buf[MASKIDX(i)]
113 #define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
114 #define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
115 #define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
118 #define COPYBITS(src, dst) dst[0] = src[0]
119 #define CLEARBITS(buf) buf[0] = 0
120 #define MASKANDSETBITS(dst, b1, b2) dst[0] = (b1[0] & b2[0])
121 #define ORBITS(dst, b1, b2) dst[0] = (b1[0] | b2[0])
122 #define UNSETBITS(dst, b1) (dst[0] &= ~b1[0])
123 #define ANYSET(src) (src[0])
127 #define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; }
128 #define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; }
129 #define MASKANDSETBITS(dst, b1, b2) {\
130 dst[0] = (b1[0] & b2[0]);\
131 dst[1] = (b1[1] & b2[1]); }
132 #define ORBITS(dst, b1, b2) {\
133 dst[0] = (b1[0] | b2[0]);\
134 dst[1] = (b1[1] | b2[1]); }
135 #define UNSETBITS(dst, b1) {\
138 #define ANYSET(src) (src[0] || src[1])
142 #define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; \
144 #define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; buf[2] = 0; }
145 #define MASKANDSETBITS(dst, b1, b2) {\
146 dst[0] = (b1[0] & b2[0]);\
147 dst[1] = (b1[1] & b2[1]);\
148 dst[2] = (b1[2] & b2[2]); }
149 #define ORBITS(dst, b1, b2) {\
150 dst[0] = (b1[0] | b2[0]);\
151 dst[1] = (b1[1] | b2[1]);\
152 dst[2] = (b1[2] | b2[2]); }
153 #define UNSETBITS(dst, b1) {\
157 #define ANYSET(src) (src[0] || src[1] || src[2])
161 #define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]; \
162 dst[2] = src[2]; dst[3] = src[3]
163 #define CLEARBITS(buf) buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 0
164 #define MASKANDSETBITS(dst, b1, b2) \
165 dst[0] = (b1[0] & b2[0]);\
166 dst[1] = (b1[1] & b2[1]);\
167 dst[2] = (b1[2] & b2[2]);\
168 dst[3] = (b1[3] & b2[3])
169 #define ORBITS(dst, b1, b2) \
170 dst[0] = (b1[0] | b2[0]);\
171 dst[1] = (b1[1] | b2[1]);\
172 dst[2] = (b1[2] | b2[2]);\
173 dst[3] = (b1[3] | b2[3])
174 #define UNSETBITS(dst, b1) \
179 #define ANYSET(src) (src[0] || src[1] || src[2] || src[3])
183 #define COPYBITS(src, dst) memmove((caddr_t) dst, (caddr_t) src,\
185 #define CLEARBITS(buf) bzero((caddr_t) buf, MSKCNT*sizeof(long))
186 #define MASKANDSETBITS(dst, b1, b2) \
188 for (cri=MSKCNT; --cri>=0; ) \
189 dst[cri] = (b1[cri] & b2[cri]); }
190 #define ORBITS(dst, b1, b2) \
192 for (cri=MSKCNT; --cri>=0; ) \
193 dst[cri] = (b1[cri] | b2[cri]); }
194 #define UNSETBITS(dst, b1) \
196 for (cri=MSKCNT; --cri>=0; ) \
197 dst[cri] &= ~b1[cri]; }
199 #define ANYSET(src) (src[0] || src[1] || src[2] || src[3] || \
200 src[4] || src[5] || src[6] || src[7])
204 #else /* not WIN32 */
206 #include <X11/Xwinsock.h>
207 #include <X11/Xw32defs.h>
209 typedef fd_set FdSet;
210 typedef FdSet *FdSetPtr;
212 #define CLEARBITS(set) FD_ZERO(&set)
213 #define BITSET(set,s) FD_SET(s,&set)
214 #define BITCLEAR(set,s) FD_CLR(s,&set)
215 #define GETBIT(set,s) FD_ISSET(s,&set)
216 #define ANYSET(set) set->fd_count