1 | /*
|
---|
2 | * $XdotOrg: xc/include/Xos.h,v 1.4 2005/01/03 18:03:49 eich Exp $
|
---|
3 | * $Xorg: Xos.h,v 1.6 2001/02/09 02:03:22 xorgcvs Exp $
|
---|
4 | *
|
---|
5 | *
|
---|
6 | Copyright 1987, 1998 The Open Group
|
---|
7 |
|
---|
8 | Permission to use, copy, modify, distribute, and sell this software and its
|
---|
9 | documentation for any purpose is hereby granted without fee, provided that
|
---|
10 | the above copyright notice appear in all copies and that both that
|
---|
11 | copyright notice and this permission notice appear in supporting
|
---|
12 | documentation.
|
---|
13 |
|
---|
14 | The above copyright notice and this permission notice shall be included in
|
---|
15 | all copies or substantial portions of the Software.
|
---|
16 |
|
---|
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
---|
20 | OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
---|
21 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
22 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
23 |
|
---|
24 | Except as contained in this notice, the name of The Open Group shall not be
|
---|
25 | used in advertising or otherwise to promote the sale, use or other dealings
|
---|
26 | in this Software without prior written authorization from The Open Group.
|
---|
27 | *
|
---|
28 | * The X Window System is a Trademark of The Open Group.
|
---|
29 | *
|
---|
30 | */
|
---|
31 | /* $XFree86: xc/include/Xos.h,v 3.41tsi Exp $ */
|
---|
32 |
|
---|
33 | /* This is a collection of things to try and minimize system dependencies
|
---|
34 | * in a "signficant" number of source files.
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef _XOS_H_
|
---|
38 | #define _XOS_H_
|
---|
39 |
|
---|
40 | #include <X11/Xosdefs.h>
|
---|
41 |
|
---|
42 | /*
|
---|
43 | * Get major data types (esp. caddr_t)
|
---|
44 | */
|
---|
45 |
|
---|
46 | #ifdef USG
|
---|
47 | #ifndef __TYPES__
|
---|
48 | #ifdef CRAY
|
---|
49 | #define word word_t
|
---|
50 | #endif /* CRAY */
|
---|
51 | #include <sys/types.h> /* forgot to protect it... */
|
---|
52 | #define __TYPES__
|
---|
53 | #endif /* __TYPES__ */
|
---|
54 | #else /* USG */
|
---|
55 | #if defined(_POSIX_SOURCE) && defined(MOTOROLA)
|
---|
56 | #undef _POSIX_SOURCE
|
---|
57 | #include <sys/types.h>
|
---|
58 | #define _POSIX_SOURCE
|
---|
59 | #else
|
---|
60 | # include <sys/types.h>
|
---|
61 | #endif
|
---|
62 | #endif /* USG */
|
---|
63 |
|
---|
64 | #ifndef sgi
|
---|
65 | #if defined(__SCO__) || defined(__UNIXWARE__)
|
---|
66 | #include <stdint.h>
|
---|
67 | #endif
|
---|
68 | #endif
|
---|
69 |
|
---|
70 | #ifdef _SEQUENT_
|
---|
71 | /*
|
---|
72 | * in_systm.h compatibility between SysV and BSD types u_char u_short u_long
|
---|
73 | * select.h for typedef of args to select, fd_set, may use SVR4 later
|
---|
74 | */
|
---|
75 | #include <netinet/in_systm.h>
|
---|
76 | #include <sys/select.h>
|
---|
77 | #endif /* _SEQUENT_ */
|
---|
78 |
|
---|
79 | /*
|
---|
80 | * Just about everyone needs the strings routines. We provide both forms here,
|
---|
81 | * index/rindex and strchr/strrchr, so any systems that don't provide them all
|
---|
82 | * need to have #defines here.
|
---|
83 | *
|
---|
84 | * These macros are defined this way, rather than, e.g.:
|
---|
85 | * #defined index(s,c) strchr(s,c)
|
---|
86 | * because someone might be using them as function pointers, and such
|
---|
87 | * a change would break compatibility for anyone who's relying on them
|
---|
88 | * being the way they currently are. So we're stuck with them this way,
|
---|
89 | * which can be really inconvenient. :-(
|
---|
90 | */
|
---|
91 |
|
---|
92 | #ifndef X_NOT_STDC_ENV
|
---|
93 |
|
---|
94 | #include <string.h>
|
---|
95 | #if defined(__SCO__) || defined(__UNIXWARE__)
|
---|
96 | #include <strings.h>
|
---|
97 | #else
|
---|
98 | #if (defined(sun) && defined(__SVR4))
|
---|
99 | #include <strings.h>
|
---|
100 | #endif
|
---|
101 | #ifdef __STDC__
|
---|
102 | #ifndef index
|
---|
103 | #define index(s,c) (strchr((s),(c)))
|
---|
104 | #endif
|
---|
105 | #ifndef rindex
|
---|
106 | #define rindex(s,c) (strrchr((s),(c)))
|
---|
107 | #endif
|
---|
108 | #else
|
---|
109 | #ifndef index
|
---|
110 | #define index strchr
|
---|
111 | #endif
|
---|
112 | #ifndef rindex
|
---|
113 | #define rindex strrchr
|
---|
114 | #endif
|
---|
115 | #endif
|
---|
116 | #endif
|
---|
117 |
|
---|
118 | #else
|
---|
119 |
|
---|
120 | #ifdef SYSV
|
---|
121 | #if defined(clipper) || defined(__clipper__)
|
---|
122 | #include <malloc.h>
|
---|
123 | #endif
|
---|
124 | #include <string.h>
|
---|
125 | #define index strchr
|
---|
126 | #define rindex strrchr
|
---|
127 | #else
|
---|
128 | #include <strings.h>
|
---|
129 | #define strchr index
|
---|
130 | #define strrchr rindex
|
---|
131 | #endif
|
---|
132 |
|
---|
133 | #endif /* X_NOT_STDC_ENV */
|
---|
134 |
|
---|
135 | /*
|
---|
136 | * strerror()
|
---|
137 | */
|
---|
138 | #if (defined(X_NOT_STDC_ENV) || (defined(sun) && !defined(SVR4)) || defined(macII)) && !defined(__GLIBC__)
|
---|
139 | #ifndef strerror
|
---|
140 | extern char *sys_errlist[];
|
---|
141 | extern int sys_nerr;
|
---|
142 | #define strerror(n) \
|
---|
143 | (((n) >= 0 && (n) < sys_nerr) ? sys_errlist[n] : "unknown error")
|
---|
144 | #endif
|
---|
145 | #endif
|
---|
146 |
|
---|
147 | /*
|
---|
148 | * Get open(2) constants
|
---|
149 | */
|
---|
150 | #if defined(X_NOT_POSIX)
|
---|
151 | #include <fcntl.h>
|
---|
152 | #if defined(USL) || defined(CRAY) || defined(MOTOROLA) || (defined(i386) && (defined(SYSV) || defined(SVR4))) || defined(__sxg__)
|
---|
153 | #include <unistd.h>
|
---|
154 | #endif
|
---|
155 | #ifdef WIN32
|
---|
156 | #include <X11/Xw32defs.h>
|
---|
157 | #else
|
---|
158 | #include <sys/file.h>
|
---|
159 | #endif
|
---|
160 | #else /* X_NOT_POSIX */
|
---|
161 | #if !defined(_POSIX_SOURCE) && defined(macII)
|
---|
162 | #define _POSIX_SOURCE
|
---|
163 | #include <fcntl.h>
|
---|
164 | #include <unistd.h>
|
---|
165 | #undef _POSIX_SOURCE
|
---|
166 | #else
|
---|
167 | #include <fcntl.h>
|
---|
168 | #include <unistd.h>
|
---|
169 | #endif
|
---|
170 | #endif /* X_NOT_POSIX else */
|
---|
171 |
|
---|
172 | /*
|
---|
173 | * Get struct timeval and struct tm
|
---|
174 | */
|
---|
175 |
|
---|
176 | #if defined(SYSV) && !defined(_SEQUENT_)
|
---|
177 |
|
---|
178 | #ifndef USL
|
---|
179 | #include <sys/time.h>
|
---|
180 | #endif
|
---|
181 | #include <time.h>
|
---|
182 | #ifdef CRAY
|
---|
183 | #undef word
|
---|
184 | #endif /* CRAY */
|
---|
185 | #if defined(USG) && !defined(CRAY) && !defined(MOTOROLA) && !defined(uniosu) && !defined(__sxg__) && !defined(clipper) && !defined(__clipper__)
|
---|
186 | struct timeval {
|
---|
187 | long tv_sec;
|
---|
188 | long tv_usec;
|
---|
189 | };
|
---|
190 | #ifndef USL_SHARELIB
|
---|
191 | struct timezone {
|
---|
192 | int tz_minuteswest;
|
---|
193 | int tz_dsttime;
|
---|
194 | };
|
---|
195 | #endif /* USL_SHARELIB */
|
---|
196 | #endif /* USG */
|
---|
197 |
|
---|
198 | #ifdef _SEQUENT_
|
---|
199 | struct timezone {
|
---|
200 | int tz_minuteswest;
|
---|
201 | int tz_dsttime;
|
---|
202 | };
|
---|
203 | #endif /* _SEQUENT_ */
|
---|
204 |
|
---|
205 | #else /* not SYSV */
|
---|
206 |
|
---|
207 | #if defined(_POSIX_SOURCE) && defined(SVR4)
|
---|
208 | /* need to omit _POSIX_SOURCE in order to get what we want in SVR4 */
|
---|
209 | #undef _POSIX_SOURCE
|
---|
210 | #include <sys/time.h>
|
---|
211 | #define _POSIX_SOURCE
|
---|
212 | #elif defined(WIN32)
|
---|
213 | #include <time.h>
|
---|
214 | #if !defined(_WINSOCKAPI_) && !defined(_WILLWINSOCK_) && !defined(_TIMEVAL_DEFINED) && !defined(_STRUCT_TIMEVAL)
|
---|
215 | struct timeval {
|
---|
216 | long tv_sec; /* seconds */
|
---|
217 | long tv_usec; /* and microseconds */
|
---|
218 | };
|
---|
219 | #define _TIMEVAL_DEFINED
|
---|
220 | #endif
|
---|
221 | #include <sys/timeb.h>
|
---|
222 | #define gettimeofday(t) \
|
---|
223 | { \
|
---|
224 | struct _timeb _gtodtmp; \
|
---|
225 | _ftime (&_gtodtmp); \
|
---|
226 | (t)->tv_sec = _gtodtmp.time; \
|
---|
227 | (t)->tv_usec = _gtodtmp.millitm * 1000; \
|
---|
228 | }
|
---|
229 | #elif defined(_SEQUENT_) || defined(Lynx)
|
---|
230 | #include <time.h>
|
---|
231 | #elif defined (__QNX__)
|
---|
232 | typedef unsigned long fd_mask;
|
---|
233 | /* Make sure we get 256 bit select masks */
|
---|
234 | #define FD_SETSIZE 256
|
---|
235 | #include <sys/select.h>
|
---|
236 | #include <sys/time.h>
|
---|
237 | #include <time.h>
|
---|
238 | #else
|
---|
239 | #include <sys/time.h>
|
---|
240 | #include <time.h>
|
---|
241 | #endif /* defined(_POSIX_SOURCE) && defined(SVR4) */
|
---|
242 |
|
---|
243 | #endif /* SYSV */
|
---|
244 |
|
---|
245 | /* define X_GETTIMEOFDAY macro, a portable gettimeofday() */
|
---|
246 | #if defined(_XOPEN_XPG4) || defined(_XOPEN_UNIX) /* _XOPEN_UNIX is XPG4.2 */
|
---|
247 | #define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)
|
---|
248 | #else
|
---|
249 | #if defined(SVR4) || defined(VMS) || defined(WIN32)
|
---|
250 | #define X_GETTIMEOFDAY(t) gettimeofday(t)
|
---|
251 | #else
|
---|
252 | #define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)
|
---|
253 | #endif
|
---|
254 | #endif /* XPG4 else */
|
---|
255 |
|
---|
256 | #ifdef __UNIXOS2__
|
---|
257 | typedef unsigned long fd_mask;
|
---|
258 | #include <limits.h>
|
---|
259 | #define MAX_PATH _POSIX_PATH_MAX
|
---|
260 | #endif
|
---|
261 |
|
---|
262 | #ifdef __GNU__
|
---|
263 | #define PATH_MAX 4096
|
---|
264 | #define MAXPATHLEN 4096
|
---|
265 | #define OPEN_MAX 256 /* We define a reasonable limit. */
|
---|
266 | #endif
|
---|
267 |
|
---|
268 | /* use POSIX name for signal */
|
---|
269 | #if defined(X_NOT_POSIX) && defined(SYSV) && !defined(SIGCHLD) && !defined(ISC)
|
---|
270 | #define SIGCHLD SIGCLD
|
---|
271 | #endif
|
---|
272 |
|
---|
273 | #ifdef ISC
|
---|
274 | #include <sys/bsdtypes.h>
|
---|
275 | #include <sys/limits.h>
|
---|
276 | #define NGROUPS 16
|
---|
277 | #endif
|
---|
278 |
|
---|
279 | #if defined(ISC) || defined(__UNIXOS2__) || \
|
---|
280 | (defined(__linux__) && !defined(__GLIBC__)) || \
|
---|
281 | (defined(__QNX__) && !defined(UNIXCONN))
|
---|
282 | /*
|
---|
283 | * Some OS's may not have this
|
---|
284 | */
|
---|
285 |
|
---|
286 | #define X_NO_SYS_UN 1
|
---|
287 |
|
---|
288 | struct sockaddr_un {
|
---|
289 | short sun_family;
|
---|
290 | char sun_path[108];
|
---|
291 | };
|
---|
292 | #endif
|
---|
293 |
|
---|
294 | #include <X11/Xarch.h>
|
---|
295 |
|
---|
296 | #endif /* _XOS_H_ */
|
---|