117ca54c3Smrg/*
217ca54c3Smrg *
317ca54c3SmrgCopyright 1987, 1998  The Open Group
417ca54c3Smrg
517ca54c3SmrgPermission to use, copy, modify, distribute, and sell this software and its
617ca54c3Smrgdocumentation for any purpose is hereby granted without fee, provided that
717ca54c3Smrgthe above copyright notice appear in all copies and that both that
817ca54c3Smrgcopyright notice and this permission notice appear in supporting
917ca54c3Smrgdocumentation.
1017ca54c3Smrg
1117ca54c3SmrgThe above copyright notice and this permission notice shall be included in
1217ca54c3Smrgall copies or substantial portions of the Software.
1317ca54c3Smrg
1417ca54c3SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1517ca54c3SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1617ca54c3SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
1717ca54c3SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
1817ca54c3SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1917ca54c3SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2017ca54c3Smrg
2117ca54c3SmrgExcept as contained in this notice, the name of The Open Group shall not be
2217ca54c3Smrgused in advertising or otherwise to promote the sale, use or other dealings
2317ca54c3Smrgin this Software without prior written authorization from The Open Group.
2417ca54c3Smrg *
2517ca54c3Smrg * The X Window System is a Trademark of The Open Group.
2617ca54c3Smrg *
2717ca54c3Smrg */
2817ca54c3Smrg
2917ca54c3Smrg/* This is a collection of things to try and minimize system dependencies
3017ca54c3Smrg * in a "significant" number of source files.
3117ca54c3Smrg */
3217ca54c3Smrg
3317ca54c3Smrg#ifndef _XOS_H_
3417ca54c3Smrg# define _XOS_H_
3517ca54c3Smrg
3617ca54c3Smrg# include <X11/Xosdefs.h>
3717ca54c3Smrg
3817ca54c3Smrg/*
3917ca54c3Smrg * Get major data types (esp. caddr_t)
4017ca54c3Smrg */
4117ca54c3Smrg
4217ca54c3Smrg# include <sys/types.h>
4317ca54c3Smrg
4417ca54c3Smrg# if defined(__SCO__) || defined(__UNIXWARE__)
4517ca54c3Smrg#  include <stdint.h>
4617ca54c3Smrg# endif
4717ca54c3Smrg
4817ca54c3Smrg
4917ca54c3Smrg/*
5017ca54c3Smrg * Just about everyone needs the strings routines.  We provide both forms here,
5117ca54c3Smrg * index/rindex and strchr/strrchr, so any systems that don't provide them all
5217ca54c3Smrg * need to have #defines here.
5317ca54c3Smrg *
5417ca54c3Smrg * These macros are defined this way, rather than, e.g.:
5517ca54c3Smrg *    #defined index(s,c) strchr(s,c)
5617ca54c3Smrg * because someone might be using them as function pointers, and such
5717ca54c3Smrg * a change would break compatibility for anyone who's relying on them
5817ca54c3Smrg * being the way they currently are. So we're stuck with them this way,
5917ca54c3Smrg * which can be really inconvenient. :-(
6017ca54c3Smrg */
6117ca54c3Smrg
6217ca54c3Smrg# include <string.h>
6368872e7fSmrg# if defined(__SCO__) || defined(__UNIXWARE__) || defined(__sun) || defined(__CYGWIN__) || defined(_AIX) || defined(__APPLE__) || defined(__FreeBSD__)
6417ca54c3Smrg#  include <strings.h>
6517ca54c3Smrg# else
6617ca54c3Smrg#  ifndef index
6717ca54c3Smrg#   define index(s,c) (strchr((s),(c)))
6817ca54c3Smrg#  endif
6917ca54c3Smrg#  ifndef rindex
7017ca54c3Smrg#   define rindex(s,c) (strrchr((s),(c)))
7117ca54c3Smrg#  endif
7217ca54c3Smrg# endif
7317ca54c3Smrg
7417ca54c3Smrg/*
7517ca54c3Smrg * Get open(2) constants
7617ca54c3Smrg */
7717ca54c3Smrg# if defined(X_NOT_POSIX)
7817ca54c3Smrg#  include <fcntl.h>
7917ca54c3Smrg#  if defined(USL) || defined(__i386__) && (defined(SYSV) || defined(SVR4))
8017ca54c3Smrg#   include <unistd.h>
8117ca54c3Smrg#  endif
8217ca54c3Smrg#  ifdef WIN32
8317ca54c3Smrg#   include <X11/Xw32defs.h>
8417ca54c3Smrg#  else
8517ca54c3Smrg#   include <sys/file.h>
8617ca54c3Smrg#  endif
8717ca54c3Smrg# else /* X_NOT_POSIX */
8817ca54c3Smrg#  include <fcntl.h>
8917ca54c3Smrg#  include <unistd.h>
9017ca54c3Smrg# endif /* X_NOT_POSIX else */
9117ca54c3Smrg
9217ca54c3Smrg/*
9317ca54c3Smrg * Get struct timeval and struct tm
9417ca54c3Smrg */
9517ca54c3Smrg
9617ca54c3Smrg# if defined(_POSIX_SOURCE) && defined(SVR4)
9717ca54c3Smrg/* need to omit _POSIX_SOURCE in order to get what we want in SVR4 */
9817ca54c3Smrg#  undef _POSIX_SOURCE
9917ca54c3Smrg#  include <sys/time.h>
10017ca54c3Smrg#  define _POSIX_SOURCE
10117ca54c3Smrg# elif defined(WIN32)
10217ca54c3Smrg#  include <time.h>
10317ca54c3Smrg#  if !defined(_WINSOCKAPI_) && !defined(_WILLWINSOCK_) && !defined(_TIMEVAL_DEFINED) && !defined(_STRUCT_TIMEVAL)
10417ca54c3Smrgstruct timeval {
10517ca54c3Smrg    long    tv_sec;         /* seconds */
10617ca54c3Smrg    long    tv_usec;        /* and microseconds */
10717ca54c3Smrg};
10817ca54c3Smrg#   define _TIMEVAL_DEFINED
10917ca54c3Smrg#  endif
11017ca54c3Smrg#  include <sys/timeb.h>
11117ca54c3Smrg#  define gettimeofday(t) \
11217ca54c3Smrg{ \
11317ca54c3Smrg    struct _timeb _gtodtmp; \
11417ca54c3Smrg    _ftime (&_gtodtmp); \
11517ca54c3Smrg    (t)->tv_sec = _gtodtmp.time; \
11617ca54c3Smrg    (t)->tv_usec = _gtodtmp.millitm * 1000; \
11717ca54c3Smrg}
11817ca54c3Smrg# else
11917ca54c3Smrg#  include <sys/time.h>
12017ca54c3Smrg#  include <time.h>
12117ca54c3Smrg# endif /* defined(_POSIX_SOURCE) && defined(SVR4) */
12217ca54c3Smrg
12317ca54c3Smrg/* define X_GETTIMEOFDAY macro, a portable gettimeofday() */
12417ca54c3Smrg# if defined(_XOPEN_XPG4) || defined(_XOPEN_UNIX) /* _XOPEN_UNIX is XPG4.2 */
12517ca54c3Smrg#  define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)
12617ca54c3Smrg# else
12717ca54c3Smrg#  if defined(SVR4) || defined(__SVR4) || defined(WIN32)
12817ca54c3Smrg#   define X_GETTIMEOFDAY(t) gettimeofday(t)
12917ca54c3Smrg#  else
13017ca54c3Smrg#   define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)
13117ca54c3Smrg#  endif
13217ca54c3Smrg# endif /* XPG4 else */
13317ca54c3Smrg
13417ca54c3Smrg
13517ca54c3Smrg# ifdef __GNU__
13617ca54c3Smrg#  define PATH_MAX 4096
13717ca54c3Smrg#  define MAXPATHLEN 4096
13817ca54c3Smrg#  define OPEN_MAX 256 /* We define a reasonable limit.  */
13917ca54c3Smrg# endif
14017ca54c3Smrg
14117ca54c3Smrg/* use POSIX name for signal */
14217ca54c3Smrg# if defined(X_NOT_POSIX) && defined(SYSV) && !defined(SIGCHLD)
14317ca54c3Smrg#  define SIGCHLD SIGCLD
14417ca54c3Smrg# endif
14517ca54c3Smrg
14617ca54c3Smrg# include <X11/Xarch.h>
14717ca54c3Smrg
14817ca54c3Smrg#endif /* _XOS_H_ */
149