1 /* $XConsortium: fslibos.h /main/16 1996/11/13 14:45:15 lehors $ */
2 /* $XFree86: xc/lib/font/fc/fslibos.h,v 3.3 1996/12/23 06:02:08 dawes Exp $ */
4 * Copyright 1990 Network Computing Devices;
5 * Portions Copyright 1987 by Digital Equipment Corporation
10 Copyright (c) 1987, 1994 X Consortium
12 Permission is hereby granted, free of charge, to any person obtaining
13 a copy of this software and associated documentation files (the
14 "Software"), to deal in the Software without restriction, including
15 without limitation the rights to use, copy, modify, merge, publish,
16 distribute, sublicense, and/or sell copies of the Software, and to
17 permit persons to whom the Software is furnished to do so, subject to
18 the following conditions:
20 The above copyright notice and this permission notice shall be included
21 in all copies or substantial portions of the Software.
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
27 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
28 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29 OTHER DEALINGS IN THE SOFTWARE.
31 Except as contained in this notice, the name of the X Consortium shall
32 not be used in advertising or otherwise to promote the sale, use or
33 other dealings in this Software without prior written authorization
34 from the X Consortium.
39 * FSlib networking & os include file
42 #include <X11/Xtrans.h>
47 * makedepend screws up on #undef OPEN_MAX, so we define a new symbol
62 #if defined(SVR4) || defined(__EMX__)
64 #define OPEN_MAX sysconf(_SC_OPEN_MAX)
69 #include <sys/param.h>
75 #define OPEN_MAX NOFILE
77 #define OPEN_MAX NOFILES_MAX
85 #define FONT_OPEN_MAX 256
87 #define FONT_OPEN_MAX OPEN_MAX
90 #endif /* FONT_OPEN_MAX */
98 #define MSKCNT ((FONT_OPEN_MAX + NMSKBITS - 1) / NMSKBITS)
100 typedef unsigned long FdSet[MSKCNT];
101 typedef FdSet FdSetPtr;
104 #define BITMASK(i) (1 << (i))
109 #define BITMASK(i) (1 << ((i) & (NMSKBITS - 1)))
110 #define MASKIDX(i) ((i) / NMSKBITS)
113 #define MASKWORD(buf, i) buf[MASKIDX(i)]
114 #define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
115 #define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
116 #define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
119 #define COPYBITS(src, dst) dst[0] = src[0]
120 #define CLEARBITS(buf) buf[0] = 0
121 #define MASKANDSETBITS(dst, b1, b2) dst[0] = (b1[0] & b2[0])
122 #define ORBITS(dst, b1, b2) dst[0] = (b1[0] | b2[0])
123 #define UNSETBITS(dst, b1) (dst[0] &= ~b1[0])
124 #define ANYSET(src) (src[0])
128 #define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; }
129 #define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; }
130 #define MASKANDSETBITS(dst, b1, b2) {\
131 dst[0] = (b1[0] & b2[0]);\
132 dst[1] = (b1[1] & b2[1]); }
133 #define ORBITS(dst, b1, b2) {\
134 dst[0] = (b1[0] | b2[0]);\
135 dst[1] = (b1[1] | b2[1]); }
136 #define UNSETBITS(dst, b1) {\
139 #define ANYSET(src) (src[0] || src[1])
143 #define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; \
145 #define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; buf[2] = 0; }
146 #define MASKANDSETBITS(dst, b1, b2) {\
147 dst[0] = (b1[0] & b2[0]);\
148 dst[1] = (b1[1] & b2[1]);\
149 dst[2] = (b1[2] & b2[2]); }
150 #define ORBITS(dst, b1, b2) {\
151 dst[0] = (b1[0] | b2[0]);\
152 dst[1] = (b1[1] | b2[1]);\
153 dst[2] = (b1[2] | b2[2]); }
154 #define UNSETBITS(dst, b1) {\
158 #define ANYSET(src) (src[0] || src[1] || src[2])
162 #define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]; \
163 dst[2] = src[2]; dst[3] = src[3]
164 #define CLEARBITS(buf) buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 0
165 #define MASKANDSETBITS(dst, b1, b2) \
166 dst[0] = (b1[0] & b2[0]);\
167 dst[1] = (b1[1] & b2[1]);\
168 dst[2] = (b1[2] & b2[2]);\
169 dst[3] = (b1[3] & b2[3])
170 #define ORBITS(dst, b1, b2) \
171 dst[0] = (b1[0] | b2[0]);\
172 dst[1] = (b1[1] | b2[1]);\
173 dst[2] = (b1[2] | b2[2]);\
174 dst[3] = (b1[3] | b2[3])
175 #define UNSETBITS(dst, b1) \
180 #define ANYSET(src) (src[0] || src[1] || src[2] || src[3])
184 #define COPYBITS(src, dst) memmove((caddr_t) dst, (caddr_t) src,\
186 #define CLEARBITS(buf) bzero((caddr_t) buf, MSKCNT*sizeof(long))
187 #define MASKANDSETBITS(dst, b1, b2) \
189 for (cri=MSKCNT; --cri>=0; ) \
190 dst[cri] = (b1[cri] & b2[cri]); }
191 #define ORBITS(dst, b1, b2) \
193 for (cri=MSKCNT; --cri>=0; ) \
194 dst[cri] = (b1[cri] | b2[cri]); }
195 #define UNSETBITS(dst, b1) \
197 for (cri=MSKCNT; --cri>=0; ) \
198 dst[cri] &= ~b1[cri]; }
200 #define ANYSET(src) (src[0] || src[1] || src[2] || src[3] || \
201 src[4] || src[5] || src[6] || src[7])
205 #else /* not WIN32 */
207 #include <X11/Xwinsock.h>
208 #include <X11/Xw32defs.h>
210 typedef fd_set FdSet;
211 typedef FdSet *FdSetPtr;
213 #define CLEARBITS(set) FD_ZERO(&set)
214 #define BITSET(set,s) FD_SET(s,&set)
215 #define BITCLEAR(set,s) FD_CLR(s,&set)
216 #define GETBIT(set,s) FD_ISSET(s,&set)
217 #define ANYSET(set) set->fd_count