Xos.h revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/*
* $Xorg: Xos.h,v 1.6 2001/02/09 02:03:22 xorgcvs Exp $
*
*
Copyright 1987, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*
* The X Window System is a Trademark of The Open Group.
*
*/
/* This is a collection of things to try and minimize system dependencies
* in a "signficant" number of source files.
*/
#ifndef _XOS_H_
#define _XOS_H_
/*
* Get major data types (esp. caddr_t)
*/
#ifdef USG
#ifndef __TYPES__
#ifdef CRAY
#endif /* CRAY */
#define __TYPES__
#endif /* __TYPES__ */
#else /* USG */
#if defined(_POSIX_SOURCE) && defined(MOTOROLA)
#define _POSIX_SOURCE
#else
#endif
#endif /* USG */
#ifndef sgi
#if defined(__SCO__) || defined(__UNIXWARE__)
#include <stdint.h>
#endif
#endif
#ifdef _SEQUENT_
/*
* in_systm.h compatibility between SysV and BSD types u_char u_short u_long
* select.h for typedef of args to select, fd_set, may use SVR4 later
*/
#include <netinet/in_systm.h>
#endif /* _SEQUENT_ */
/*
* Just about everyone needs the strings routines. We provide both forms here,
* need to have #defines here.
*
* These macros are defined this way, rather than, e.g.:
* #defined index(s,c) strchr(s,c)
* because someone might be using them as function pointers, and such
* a change would break compatibility for anyone who's relying on them
* being the way they currently are. So we're stuck with them this way,
* which can be really inconvenient. :-(
*/
#ifndef X_NOT_STDC_ENV
#include <string.h>
#if defined(__SCO__) || defined(__UNIXWARE__)
#include <strings.h>
#else
#include <strings.h>
#endif
#ifdef __STDC__
#ifndef index
#endif
#ifndef rindex
#endif
#else
#ifndef index
#endif
#ifndef rindex
#endif
#endif
#endif
#else
#ifdef SYSV
#if defined(clipper) || defined(__clipper__)
#include <malloc.h>
#endif
#include <string.h>
#else
#include <strings.h>
#endif
#endif /* X_NOT_STDC_ENV */
/*
* strerror()
*/
#if (defined(X_NOT_STDC_ENV) || (defined(sun) && !defined(SVR4)) || defined(macII)) && !defined(__GLIBC__)
#ifndef strerror
extern char *sys_errlist[];
extern int sys_nerr;
#define strerror(n) \
#endif
#endif
/*
* Get open(2) constants
*/
#if defined(X_NOT_POSIX)
#include <fcntl.h>
#if defined(USL) || defined(CRAY) || defined(MOTOROLA) || (defined(i386) && (defined(SYSV) || defined(SVR4))) || defined(__sxg__)
#include <unistd.h>
#endif
#ifdef WIN32
#include <X11/Xw32defs.h>
#else
#endif
#else /* X_NOT_POSIX */
#if !defined(_POSIX_SOURCE) && defined(macII)
#define _POSIX_SOURCE
#include <fcntl.h>
#include <unistd.h>
#else
#include <fcntl.h>
#include <unistd.h>
#endif
#endif /* X_NOT_POSIX else */
/*
* Get struct timeval and struct tm
*/
#ifndef USL
#endif
#include <time.h>
#ifdef CRAY
#endif /* CRAY */
#if defined(USG) && !defined(CRAY) && !defined(MOTOROLA) && !defined(uniosu) && !defined(__sxg__) && !defined(clipper) && !defined(__clipper__)
struct timeval {
long tv_sec;
long tv_usec;
};
#ifndef USL_SHARELIB
struct timezone {
int tz_minuteswest;
int tz_dsttime;
};
#endif /* USL_SHARELIB */
#endif /* USG */
#ifdef _SEQUENT_
struct timezone {
int tz_minuteswest;
int tz_dsttime;
};
#endif /* _SEQUENT_ */
#else /* not SYSV */
#if defined(_POSIX_SOURCE) && defined(SVR4)
/* need to omit _POSIX_SOURCE in order to get what we want in SVR4 */
#define _POSIX_SOURCE
#include <time.h>
#if !defined(_WINSOCKAPI_) && !defined(_WILLWINSOCK_) && !defined(_TIMEVAL_DEFINED) && !defined(_STRUCT_TIMEVAL)
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
#define _TIMEVAL_DEFINED
#endif
#define gettimeofday(t) \
{ \
}
#include <time.h>
typedef unsigned long fd_mask;
/* Make sure we get 256 bit select masks */
#define FD_SETSIZE 256
#include <time.h>
#else
#include <time.h>
#endif /* defined(_POSIX_SOURCE) && defined(SVR4) */
#endif /* SYSV */
/* define X_GETTIMEOFDAY macro, a portable gettimeofday() */
#else
#define X_GETTIMEOFDAY(t) gettimeofday(t)
#else
#endif
#endif /* XPG4 else */
#ifdef __UNIXOS2__
typedef unsigned long fd_mask;
#include <limits.h>
#define MAX_PATH _POSIX_PATH_MAX
#endif
#ifdef __GNU__
#define PATH_MAX 4096
#define MAXPATHLEN 4096
#endif
/* use POSIX name for signal */
#endif
#ifdef ISC
#include <sys/bsdtypes.h>
#define NGROUPS 16
#endif
#if defined(ISC) || defined(__UNIXOS2__) || \
/*
* Some OS's may not have this
*/
#define X_NO_SYS_UN 1
struct sockaddr_un {
short sun_family;
char sun_path[108];
};
#endif
#endif /* _XOS_H_ */