| 1 |
/* |
| 2 |
* $XdotOrg: xc/include/Xos.h,v 1.8 2005/11/08 06:33:25 jkj 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 |
|
| 32 |
/* This is a collection of things to try and minimize system dependencies |
| 33 |
* in a "signficant" number of source files. |
| 34 |
*/ |
| 35 |
|
| 36 |
#ifndef _XOS_H_ |
| 37 |
#define _XOS_H_ |
| 38 |
|
| 39 |
#include <nx-X11/Xosdefs.h> |
| 40 |
|
| 41 |
/* |
| 42 |
* Get major data types (esp. caddr_t) |
| 43 |
*/ |
| 44 |
|
| 45 |
#ifdef USG |
| 46 |
#ifndef __TYPES__ |
| 47 |
#include <sys/types.h> /* forgot to protect it... */ |
| 48 |
#define __TYPES__ |
| 49 |
#endif /* __TYPES__ */ |
| 50 |
#else /* USG */ |
| 51 |
#if defined(_POSIX_SOURCE) && defined(MOTOROLA) |
| 52 |
#undef _POSIX_SOURCE |
| 53 |
#include <sys/types.h> |
| 54 |
#define _POSIX_SOURCE |
| 55 |
#else |
| 56 |
# include <sys/types.h> |
| 57 |
#endif |
| 58 |
#endif /* USG */ |
| 59 |
|
| 60 |
#if defined(__SCO__) || defined(__UNIXWARE__) |
| 61 |
#include <stdint.h> |
| 62 |
#endif |
| 63 |
|
| 64 |
#ifdef _SEQUENT_ |
| 65 |
/* |
| 66 |
* in_systm.h compatibility between SysV and BSD types u_char u_short u_long |
| 67 |
* select.h for typedef of args to select, fd_set, may use SVR4 later |
| 68 |
*/ |
| 69 |
#include <netinet/in_systm.h> |
| 70 |
#include <sys/select.h> |
| 71 |
#endif /* _SEQUENT_ */ |
| 72 |
|
| 73 |
/* |
| 74 |
* Just about everyone needs the strings routines. We provide both forms here, |
| 75 |
* index/rindex and strchr/strrchr, so any systems that don't provide them all |
| 76 |
* need to have #defines here. |
| 77 |
* |
| 78 |
* These macros are defined this way, rather than, e.g.: |
| 79 |
* #defined index(s,c) strchr(s,c) |
| 80 |
* because someone might be using them as function pointers, and such |
| 81 |
* a change would break compatibility for anyone who's relying on them |
| 82 |
* being the way they currently are. So we're stuck with them this way, |
| 83 |
* which can be really inconvenient. :-( |
| 84 |
*/ |
| 85 |
|
| 86 |
#ifndef X_NOT_STDC_ENV |
| 87 |
|
| 88 |
#include <string.h> |
| 89 |
#if defined(__SCO__) || defined(__UNIXWARE__) |
| 90 |
#include <strings.h> |
| 91 |
#else |
| 92 |
#if (defined(sun) && defined(__SVR4)) |
| 93 |
#include <strings.h> |
| 94 |
#endif |
| 95 |
#ifdef __STDC__ |
| 96 |
#ifndef index |
| 97 |
#define index(s,c) (strchr((s),(c))) |
| 98 |
#endif |
| 99 |
#ifndef rindex |
| 100 |
#define rindex(s,c) (strrchr((s),(c))) |
| 101 |
#endif |
| 102 |
#else |
| 103 |
#ifndef index |
| 104 |
#define index strchr |
| 105 |
#endif |
| 106 |
#ifndef rindex |
| 107 |
#define rindex strrchr |
| 108 |
#endif |
| 109 |
#endif |
| 110 |
#endif |
| 111 |
|
| 112 |
#else |
| 113 |
|
| 114 |
#ifdef SYSV |
| 115 |
#if defined(clipper) || defined(__clipper__) |
| 116 |
#include <malloc.h> |
| 117 |
#endif |
| 118 |
#include <string.h> |
| 119 |
#define index strchr |
| 120 |
#define rindex strrchr |
| 121 |
#else |
| 122 |
#include <strings.h> |
| 123 |
#define strchr index |
| 124 |
#define strrchr rindex |
| 125 |
#endif |
| 126 |
|
| 127 |
#endif /* X_NOT_STDC_ENV */ |
| 128 |
|
| 129 |
/* |
| 130 |
* strerror() |
| 131 |
*/ |
| 132 |
#if (defined(X_NOT_STDC_ENV) || (defined(sun) && !defined(SVR4)) || defined(macII)) && !defined(__GLIBC__) |
| 133 |
#ifndef strerror |
| 134 |
extern char *sys_errlist[]; |
| 135 |
extern int sys_nerr; |
| 136 |
#define strerror(n) \ |
| 137 |
(((n) >= 0 && (n) < sys_nerr) ? sys_errlist[n] : "unknown error") |
| 138 |
#endif |
| 139 |
#endif |
| 140 |
|
| 141 |
/* |
| 142 |
* Get open(2) constants |
| 143 |
*/ |
| 144 |
#if defined(X_NOT_POSIX) |
| 145 |
#include <fcntl.h> |
| 146 |
#if defined(USL) || defined(MOTOROLA) || (defined(i386) && (defined(SYSV) || defined(SVR4))) || defined(__sxg__) |
| 147 |
#include <unistd.h> |
| 148 |
#endif |
| 149 |
#ifdef WIN32 |
| 150 |
#include <nx-X11/Xw32defs.h> |
| 151 |
#else |
| 152 |
#include <sys/file.h> |
| 153 |
#endif |
| 154 |
#else /* X_NOT_POSIX */ |
| 155 |
#if !defined(_POSIX_SOURCE) && defined(macII) |
| 156 |
#define _POSIX_SOURCE |
| 157 |
#include <fcntl.h> |
| 158 |
#include <unistd.h> |
| 159 |
#undef _POSIX_SOURCE |
| 160 |
#else |
| 161 |
#include <fcntl.h> |
| 162 |
#include <unistd.h> |
| 163 |
#endif |
| 164 |
#endif /* X_NOT_POSIX else */ |
| 165 |
|
| 166 |
/* |
| 167 |
* Get struct timeval and struct tm |
| 168 |
*/ |
| 169 |
|
| 170 |
#if defined(SYSV) && !defined(_SEQUENT_) |
| 171 |
|
| 172 |
#ifndef USL |
| 173 |
#include <sys/time.h> |
| 174 |
#endif |
| 175 |
#include <time.h> |
| 176 |
#if defined(USG) && !defined(MOTOROLA) && !defined(uniosu) && !defined(__sxg__) && !defined(clipper) && !defined(__clipper__) |
| 177 |
struct timeval { |
| 178 |
long tv_sec; |
| 179 |
long tv_usec; |
| 180 |
}; |
| 181 |
#ifndef USL_SHARELIB |
| 182 |
struct timezone { |
| 183 |
int tz_minuteswest; |
| 184 |
int tz_dsttime; |
| 185 |
}; |
| 186 |
#endif /* USL_SHARELIB */ |
| 187 |
#endif /* USG */ |
| 188 |
|
| 189 |
#ifdef _SEQUENT_ |
| 190 |
struct timezone { |
| 191 |
int tz_minuteswest; |
| 192 |
int tz_dsttime; |
| 193 |
}; |
| 194 |
#endif /* _SEQUENT_ */ |
| 195 |
|
| 196 |
#else /* not SYSV */ |
| 197 |
|
| 198 |
#if defined(_POSIX_SOURCE) && defined(SVR4) |
| 199 |
/* need to omit _POSIX_SOURCE in order to get what we want in SVR4 */ |
| 200 |
#undef _POSIX_SOURCE |
| 201 |
#include <sys/time.h> |
| 202 |
#define _POSIX_SOURCE |
| 203 |
#elif defined(WIN32) |
| 204 |
#include <time.h> |
| 205 |
#if !defined(_WINSOCKAPI_) && !defined(_WILLWINSOCK_) && !defined(_TIMEVAL_DEFINED) && !defined(_STRUCT_TIMEVAL) |
| 206 |
struct timeval { |
| 207 |
long tv_sec; /* seconds */ |
| 208 |
long tv_usec; /* and microseconds */ |
| 209 |
}; |
| 210 |
#define _TIMEVAL_DEFINED |
| 211 |
#endif |
| 212 |
#include <sys/timeb.h> |
| 213 |
#define gettimeofday(t) \ |
| 214 |
{ \ |
| 215 |
struct _timeb _gtodtmp; \ |
| 216 |
_ftime (&_gtodtmp); \ |
| 217 |
(t)->tv_sec = _gtodtmp.time; \ |
| 218 |
(t)->tv_usec = _gtodtmp.millitm * 1000; \ |
| 219 |
} |
| 220 |
#elif defined(_SEQUENT_) |
| 221 |
#include <time.h> |
| 222 |
#else |
| 223 |
#include <sys/time.h> |
| 224 |
#include <time.h> |
| 225 |
#endif /* defined(_POSIX_SOURCE) && defined(SVR4) */ |
| 226 |
|
| 227 |
#endif /* SYSV */ |
| 228 |
|
| 229 |
/* define X_GETTIMEOFDAY macro, a portable gettimeofday() */ |
| 230 |
#if defined(_XOPEN_XPG4) || defined(_XOPEN_UNIX) /* _XOPEN_UNIX is XPG4.2 */ |
| 231 |
#define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0) |
| 232 |
#else |
| 233 |
#if defined(SVR4) || defined(VMS) || defined(WIN32) |
| 234 |
#define X_GETTIMEOFDAY(t) gettimeofday(t) |
| 235 |
#else |
| 236 |
#define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0) |
| 237 |
#endif |
| 238 |
#endif /* XPG4 else */ |
| 239 |
|
| 240 |
#ifdef __GNU__ |
| 241 |
#define PATH_MAX 4096 |
| 242 |
#define MAXPATHLEN 4096 |
| 243 |
#define OPEN_MAX 256 /* We define a reasonable limit. */ |
| 244 |
#endif |
| 245 |
|
| 246 |
/* use POSIX name for signal */ |
| 247 |
#if defined(X_NOT_POSIX) && defined(SYSV) && !defined(SIGCHLD) && !defined(ISC) |
| 248 |
#define SIGCHLD SIGCLD |
| 249 |
#endif |
| 250 |
|
| 251 |
#ifdef ISC |
| 252 |
#include <sys/bsdtypes.h> |
| 253 |
#include <sys/limits.h> |
| 254 |
#define NGROUPS 16 |
| 255 |
#endif |
| 256 |
|
| 257 |
#if defined(ISC) || \ |
| 258 |
(defined(__linux__) && !defined(__GLIBC__)) |
| 259 |
/* |
| 260 |
* Some OS's may not have this |
| 261 |
*/ |
| 262 |
|
| 263 |
#define X_NO_SYS_UN 1 |
| 264 |
|
| 265 |
struct sockaddr_un { |
| 266 |
short sun_family; |
| 267 |
char sun_path[108]; |
| 268 |
}; |
| 269 |
#endif |
| 270 |
|
| 271 |
#include <nx-X11/Xarch.h> |
| 272 |
|
| 273 |
#endif /* _XOS_H_ */ |