xref: /386bsd/usr/X386/lib/Server/include/Xos.h (revision a2142627)
1 /*
2  * $XFree86: mit/include/Xos.h,v 2.3 1993/09/22 15:31:01 dawes Exp $
3  * $XConsortium: Xos.h,v 1.47 91/08/17 17:14:38 rws Exp $
4  *
5  * Copyright 1987 by the Massachusetts Institute of Technology
6  *
7  * Permission to use, copy, modify, and distribute this software and its
8  * documentation for any purpose and without fee is hereby granted, provided
9  * that the above copyright notice appear in all copies and that both that
10  * copyright notice and this permission notice appear in supporting
11  * documentation, and that the name of M.I.T. not be used in advertising
12  * or publicity pertaining to distribution of the software without specific,
13  * written prior permission. M.I.T. makes no representations about the
14  * suitability of this software for any purpose.  It is provided "as is"
15  * without express or implied warranty.
16  *
17  * The X Window System is a Trademark of MIT.
18  *
19  */
20 
21 /* This is a collection of things to try and minimize system dependencies
22  * in a "signficant" number of source files.
23  */
24 
25 #ifndef _XOS_H_
26 #define _XOS_H_
27 
28 #ifdef _MINIX
29 #include <minix/posix.h>
30 #endif /* _MINIX */
31 
32 #ifdef SCO
33 #include <stdio.h>
34 #endif
35 
36 #include <X11/Xosdefs.h>
37 
38 /*
39  * Get major data types (esp. caddr_t)
40  */
41 
42 #if defined(USG) || defined(SYSV)
43 #ifndef __TYPES__
44 #ifdef CRAY
45 #define word word_t
46 #endif /* CRAY */
47 #ifdef ESIX
48 #define unchar u_char
49 #endif
50 #include <sys/types.h>			/* forgot to protect it... */
51 #define __TYPES__
52 #endif /* __TYPES__ */
53 #else /* USG || SYSV */
54 #if defined(_POSIX_SOURCE) && (defined(MOTOROLA) || defined(AMOEBA))
55 #undef _POSIX_SOURCE
56 #include <sys/types.h>
57 #define _POSIX_SOURCE
58 #else
59 #include <sys/types.h>
60 #endif
61 #endif /* USG || SYSV */
62 
63 
64 /*
65  * Just about everyone needs the strings routines.  We provide both forms here,
66  * index/rindex and strchr/strrchr, so any systems that don't provide them all
67  * need to have #defines here.
68  */
69 
70 #ifndef X_NOT_STDC_ENV
71 #include <string.h>
72 #define index strchr
73 #define rindex strrchr
74 #else
75 #ifdef SYSV
76 #include <string.h>
77 #define index strchr
78 #define rindex strrchr
79 #else
80 #include <strings.h>
81 #define strchr index
82 #define strrchr rindex
83 #endif
84 #endif
85 
86 
87 /*
88  * Get open(2) constants
89  */
90 #ifdef X_NOT_POSIX
91 #include <fcntl.h>
92 #ifdef USL
93 #include <unistd.h>
94 #endif /* USL */
95 #ifdef CRAY
96 #include <unistd.h>
97 #endif /* CRAY */
98 #ifdef MOTOROLA
99 #include <unistd.h>
100 #endif /* MOTOROLA */
101 #ifdef SYSV386
102 #include <unistd.h>
103 #endif /* SYSV386 */
104 
105 #if defined(ISC) && !defined(O_NDELAY)
106 #define O_NDELAY O_NONBLOCK
107 #endif /* ISC */
108 
109 #include <sys/file.h>
110 #else /* X_NOT_POSIX */
111 #if !defined(_POSIX_SOURCE) && defined(macII)
112 #define _POSIX_SOURCE
113 #include <fcntl.h>
114 #undef _POSIX_SOURCE
115 #else
116 #include <fcntl.h>
117 #endif
118 #include <unistd.h>
119 #endif /* X_NOT_POSIX else */
120 
121 /*
122  * Get struct timeval
123  */
124 
125 #ifdef SYSV
126 
127 #ifndef USL
128 #include <sys/time.h>
129 #endif
130 #include <time.h>
131 #ifdef CRAY
132 #undef word
133 #endif /* CRAY */
134 #if defined(USG) && !defined(CRAY) && !defined(MOTOROLA)
135 struct timeval {
136     long tv_sec;
137     long tv_usec;
138 };
139 #ifndef USL_SHARELIB
140 struct timezone {
141     int tz_minuteswest;
142     int tz_dsttime;
143 };
144 #endif /* USL_SHARELIB */
145 #endif /* USG */
146 
147 #if defined(SCO) && !defined(SCO324)
148 /*
149  * Interval timer (for PEX)
150  * a dummy implementation lives in
151  * Berklib.c
152  */
153 
154 #define	ITIMER_REAL		0
155 #define	ITIMER_VIRTUAL	1
156 #define	ITIMER_PROF		2
157 
158 struct itimerval {
159     struct timeval it_interval;		/* timer interval */
160     struct timeval it_value;		/* current timer value */
161 };
162 #endif /* defined(SCO) && !defined(SCO324) */
163 
164 #else /* not SYSV */
165 
166 #if defined(_POSIX_SOURCE) && (defined(SVR4) || defined(AMOEBA))
167 /* need to omit _POSIX_SOURCE in order to get what we want in SVR4 */
168 #undef _POSIX_SOURCE
169 #include <sys/time.h>
170 #ifdef AMOEBA
171 #include <time.h>
172 
173 /*
174  * Interval timer (for PEX)
175  */
176 struct itimerval {
177     struct timeval it_interval;		/* timer interval */
178     struct timeval it_value;		/* current timer value */
179 };
180 #endif /* AMOEBA */
181 #define _POSIX_SOURCE
182 #else
183 #ifdef _MINIX
184 #include <time.h>
185 #else
186 #include <sys/time.h>
187 #endif
188 #endif
189 
190 #endif /* SYSV */
191 
192 /* use POSIX name for signal */
193 #if defined(X_NOT_POSIX) && defined(SYSV) && !defined(SIGCHLD)
194 #define SIGCHLD SIGCLD
195 #endif
196 
197 #ifdef ISC
198 #include <sys/bsdtypes.h>
199 #endif
200 
201 #ifdef __386BSD__
202 #include <machine/endian.h>
203 #endif
204 
205 #ifdef _MINIX
206 #include <net/hton.h>
207 #include <net/gen/in.h>
208 #include <net/gen/socket.h>   /* Get socket types. */
209 
210 #ifndef IOVEC_DEFINED
211 #define IOVEC_DEFINED
212 struct iovec
213 {
214 	char *iov_base;
215 	size_t iov_len;
216 };
217 #endif
218 
219 struct sockaddr
220 {
221 	union
222 	{
223 		int sa_family;
224 		struct sockaddr_in
225 		{
226 			int sin_family;
227 			ipaddr_t sin_addr;
228 			u16_t sin_port;
229 		} sa_in;
230 	} sa_u;
231 };
232 
233 #endif /* _MINIX */
234 
235 #endif /* _XOS_H_ */
236