2 * $XdotOrg: proto/X11/Xos.h,v 1.9 2006/04/20 01:24:25 alanc Exp $
3 * $Xorg: Xos.h,v 1.6 2001/02/09 02:03:22 xorgcvs Exp $
6 Copyright 1987, 1998 The Open Group
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
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
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.
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.
28 * The X Window System is a Trademark of The Open Group.
31 /* $XFree86: xc/include/Xos.h,v 3.41tsi Exp $ */
33 /* This is a collection of things to try and minimize system dependencies
34 * in a "significant" number of source files.
40 #include <X11/Xosdefs.h>
43 * Get major data types (esp. caddr_t)
51 #include <sys/types.h> /* forgot to protect it... */
53 #endif /* __TYPES__ */
55 #if defined(_POSIX_SOURCE) && defined(MOTOROLA)
57 #include <sys/types.h>
60 # include <sys/types.h>
65 #if defined(__SCO__) || defined(__UNIXWARE__)
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
75 #include <netinet/in_systm.h>
76 #include <sys/select.h>
77 #endif /* _SEQUENT_ */
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.
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. :-(
92 #ifndef X_NOT_STDC_ENV
95 #if defined(__SCO__) || defined(__UNIXWARE__)
98 #if (defined(sun) && defined(__SVR4))
103 #define index(s,c) (strchr((s),(c)))
106 #define rindex(s,c) (strrchr((s),(c)))
113 #define rindex strrchr
121 #if defined(clipper) || defined(__clipper__)
126 #define rindex strrchr
130 #define strrchr rindex
133 #endif /* X_NOT_STDC_ENV */
138 #if (defined(X_NOT_STDC_ENV) || (defined(sun) && !defined(SVR4)) || defined(macII)) && !defined(__GLIBC__)
140 extern char *sys_errlist
[];
142 #define strerror(n) \
143 (((n) >= 0 && (n) < sys_nerr) ? sys_errlist[n] : "unknown error")
148 * Get open(2) constants
150 #if defined(X_NOT_POSIX)
152 #if defined(USL) || defined(CRAY) || defined(MOTOROLA) || (defined(i386) && (defined(SYSV) || defined(SVR4))) || defined(__sxg__)
156 #include <X11/Xw32defs.h>
158 #include <sys/file.h>
160 #else /* X_NOT_POSIX */
161 #if !defined(_POSIX_SOURCE) && defined(macII)
162 #define _POSIX_SOURCE
170 #endif /* X_NOT_POSIX else */
173 * Get struct timeval and struct tm
176 #if defined(SYSV) && !defined(_SEQUENT_)
179 #include <sys/time.h>
185 #if defined(USG) && !defined(CRAY) && !defined(MOTOROLA) && !defined(uniosu) && !defined(__sxg__) && !defined(clipper) && !defined(__clipper__)
195 #endif /* USL_SHARELIB */
203 #endif /* _SEQUENT_ */
207 #if defined(_POSIX_SOURCE) && defined(SVR4)
208 /* need to omit _POSIX_SOURCE in order to get what we want in SVR4 */
210 #include <sys/time.h>
211 #define _POSIX_SOURCE
214 #if !defined(_WINSOCKAPI_) && !defined(_WILLWINSOCK_) && !defined(_TIMEVAL_DEFINED) && !defined(_STRUCT_TIMEVAL)
216 long tv_sec
; /* seconds */
217 long tv_usec
; /* and microseconds */
219 #define _TIMEVAL_DEFINED
221 #include <sys/timeb.h>
222 #define gettimeofday(t) \
224 struct _timeb _gtodtmp; \
225 _ftime (&_gtodtmp); \
226 (t)->tv_sec = _gtodtmp.time; \
227 (t)->tv_usec = _gtodtmp.millitm * 1000; \
229 #elif defined(_SEQUENT_) || defined(Lynx)
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>
239 #include <sys/time.h>
241 #endif /* defined(_POSIX_SOURCE) && defined(SVR4) */
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)
249 #if defined(SVR4) || defined(VMS) || defined(WIN32)
250 #define X_GETTIMEOFDAY(t) gettimeofday(t)
252 #define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)
254 #endif /* XPG4 else */
257 typedef unsigned long fd_mask
;
259 #define MAX_PATH _POSIX_PATH_MAX
263 #define PATH_MAX 4096
264 #define MAXPATHLEN 4096
265 #define OPEN_MAX 256 /* We define a reasonable limit. */
268 /* use POSIX name for signal */
269 #if defined(X_NOT_POSIX) && defined(SYSV) && !defined(SIGCHLD) && !defined(ISC)
270 #define SIGCHLD SIGCLD
274 #include <sys/bsdtypes.h>
275 #include <sys/limits.h>
279 #if defined(ISC) || defined(__UNIXOS2__) || \
280 (defined(__linux__) && !defined(__GLIBC__)) || \
281 (defined(__QNX__) && !defined(UNIXCONN))
283 * Some OS's may not have this
286 #define X_NO_SYS_UN 1
294 #include <X11/Xarch.h>