1 | /* |
2 | * |
3 | Copyright 1987, 1998 The Open Group |
4 | |
5 | Permission to use, copy, modify, distribute, and sell this software and its |
6 | documentation for any purpose is hereby granted without fee, provided that |
7 | the above copyright notice appear in all copies and that both that |
8 | copyright notice and this permission notice appear in supporting |
9 | documentation. |
10 | |
11 | The above copyright notice and this permission notice shall be included in |
12 | all copies or substantial portions of the Software. |
13 | |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
17 | OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
18 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
19 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
20 | |
21 | Except as contained in this notice, the name of The Open Group shall not be |
22 | used in advertising or otherwise to promote the sale, use or other dealings |
23 | in this Software without prior written authorization from The Open Group. |
24 | * |
25 | * The X Window System is a Trademark of The Open Group. |
26 | * |
27 | */ |
28 | |
29 | /* This is a collection of things to try and minimize system dependencies |
30 | * in a "significant" number of source files. |
31 | */ |
32 | |
33 | #ifndef _XOS_H_ |
34 | # define _XOS_H_ |
35 | |
36 | # include <X11/Xosdefs.h> |
37 | |
38 | /* |
39 | * Get major data types (esp. caddr_t) |
40 | */ |
41 | |
42 | # include <sys/types.h> |
43 | |
44 | # if defined(__SCO__) || defined(__UNIXWARE__) |
45 | # include <stdint.h> |
46 | # endif |
47 | |
48 | |
49 | /* |
50 | * Just about everyone needs the strings routines. We provide both forms here, |
51 | * index/rindex and strchr/strrchr, so any systems that don't provide them all |
52 | * need to have #defines here. |
53 | * |
54 | * These macros are defined this way, rather than, e.g.: |
55 | * #defined index(s,c) strchr(s,c) |
56 | * because someone might be using them as function pointers, and such |
57 | * a change would break compatibility for anyone who's relying on them |
58 | * being the way they currently are. So we're stuck with them this way, |
59 | * which can be really inconvenient. :-( |
60 | */ |
61 | |
62 | # include <string.h> |
63 | # if defined(__SCO__) || defined(__UNIXWARE__) || defined(__sun) || defined(__CYGWIN__) |
64 | # include <strings.h> |
65 | # else |
66 | # ifndef index |
67 | # define index(s,c) (strchr((s),(c))) |
68 | # endif |
69 | # ifndef rindex |
70 | # define rindex(s,c) (strrchr((s),(c))) |
71 | # endif |
72 | # endif |
73 | |
74 | /* |
75 | * Get open(2) constants |
76 | */ |
77 | # if defined(X_NOT_POSIX) |
78 | # include <fcntl.h> |
79 | # if defined(USL) || defined(__i386__) && (defined(SYSV) || defined(SVR4)) |
80 | # include <unistd.h> |
81 | # endif |
82 | # ifdef WIN32 |
83 | # include <X11/Xw32defs.h> |
84 | # else |
85 | # include <sys/file.h> |
86 | # endif |
87 | # else /* X_NOT_POSIX */ |
88 | # include <fcntl.h> |
89 | # include <unistd.h> |
90 | # endif /* X_NOT_POSIX else */ |
91 | |
92 | /* |
93 | * Get struct timeval and struct tm |
94 | */ |
95 | |
96 | # if defined(_POSIX_SOURCE) && defined(SVR4) |
97 | /* need to omit _POSIX_SOURCE in order to get what we want in SVR4 */ |
98 | # undef _POSIX_SOURCE |
99 | # include <sys/time.h> |
100 | # define _POSIX_SOURCE |
101 | # elif defined(WIN32) |
102 | # include <time.h> |
103 | # if !defined(_WINSOCKAPI_) && !defined(_WILLWINSOCK_) && !defined(_TIMEVAL_DEFINED) && !defined(_STRUCT_TIMEVAL) |
104 | struct timeval { |
105 | long tv_sec; /* seconds */ |
106 | long tv_usec; /* and microseconds */ |
107 | }; |
108 | # define _TIMEVAL_DEFINED |
109 | # endif |
110 | # include <sys/timeb.h> |
111 | # define gettimeofday(t) \ |
112 | { \ |
113 | struct _timeb _gtodtmp; \ |
114 | _ftime (&_gtodtmp); \ |
115 | (t)->tv_sec = _gtodtmp.time; \ |
116 | (t)->tv_usec = _gtodtmp.millitm * 1000; \ |
117 | } |
118 | # else |
119 | # include <sys/time.h> |
120 | # include <time.h> |
121 | # endif /* defined(_POSIX_SOURCE) && defined(SVR4) */ |
122 | |
123 | /* define X_GETTIMEOFDAY macro, a portable gettimeofday() */ |
124 | # if defined(_XOPEN_XPG4) || defined(_XOPEN_UNIX) /* _XOPEN_UNIX is XPG4.2 */ |
125 | # define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0) |
126 | # else |
127 | # if defined(SVR4) || defined(__SVR4) || defined(WIN32) |
128 | # define X_GETTIMEOFDAY(t) gettimeofday(t) |
129 | # else |
130 | # define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0) |
131 | # endif |
132 | # endif /* XPG4 else */ |
133 | |
134 | |
135 | # ifdef __GNU__ |
136 | # define PATH_MAX 4096 |
137 | # define MAXPATHLEN 4096 |
138 | # define OPEN_MAX 256 /* We define a reasonable limit. */ |
139 | # endif |
140 | |
141 | /* use POSIX name for signal */ |
142 | # if defined(X_NOT_POSIX) && defined(SYSV) && !defined(SIGCHLD) |
143 | # define SIGCHLD SIGCLD |
144 | # endif |
145 | |
146 | # include <X11/Xarch.h> |
147 | |
148 | #endif /* _XOS_H_ */ |
149 | |