Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:34

0001 /*
0002  *
0003 Copyright 1987, 1998  The Open Group
0004 
0005 Permission to use, copy, modify, distribute, and sell this software and its
0006 documentation for any purpose is hereby granted without fee, provided that
0007 the above copyright notice appear in all copies and that both that
0008 copyright notice and this permission notice appear in supporting
0009 documentation.
0010 
0011 The above copyright notice and this permission notice shall be included in
0012 all copies or substantial portions of the Software.
0013 
0014 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
0017 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
0018 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0019 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0020 
0021 Except as contained in this notice, the name of The Open Group shall not be
0022 used in advertising or otherwise to promote the sale, use or other dealings
0023 in this Software without prior written authorization from The Open Group.
0024  *
0025  * The X Window System is a Trademark of The Open Group.
0026  *
0027  */
0028 
0029 /* This is a collection of things to try and minimize system dependencies
0030  * in a "significant" number of source files.
0031  */
0032 
0033 #ifndef _XOS_H_
0034 # define _XOS_H_
0035 
0036 # include <X11/Xosdefs.h>
0037 
0038 /*
0039  * Get major data types (esp. caddr_t)
0040  */
0041 
0042 # include <sys/types.h>
0043 
0044 # if defined(__SCO__) || defined(__UNIXWARE__)
0045 #  include <stdint.h>
0046 # endif
0047 
0048 
0049 /*
0050  * Just about everyone needs the strings routines.  We provide both forms here,
0051  * index/rindex and strchr/strrchr, so any systems that don't provide them all
0052  * need to have #defines here.
0053  *
0054  * These macros are defined this way, rather than, e.g.:
0055  *    #defined index(s,c) strchr(s,c)
0056  * because someone might be using them as function pointers, and such
0057  * a change would break compatibility for anyone who's relying on them
0058  * being the way they currently are. So we're stuck with them this way,
0059  * which can be really inconvenient. :-(
0060  */
0061 
0062 # include <string.h>
0063 # if defined(__SCO__) || defined(__UNIXWARE__) || defined(__sun) || defined(__CYGWIN__) || defined(_AIX) || defined(__APPLE__)
0064 #  include <strings.h>
0065 # else
0066 #  ifndef index
0067 #   define index(s,c) (strchr((s),(c)))
0068 #  endif
0069 #  ifndef rindex
0070 #   define rindex(s,c) (strrchr((s),(c)))
0071 #  endif
0072 # endif
0073 
0074 /*
0075  * Get open(2) constants
0076  */
0077 # if defined(X_NOT_POSIX)
0078 #  include <fcntl.h>
0079 #  if defined(USL) || defined(__i386__) && (defined(SYSV) || defined(SVR4))
0080 #   include <unistd.h>
0081 #  endif
0082 #  ifdef WIN32
0083 #   include <X11/Xw32defs.h>
0084 #  else
0085 #   include <sys/file.h>
0086 #  endif
0087 # else /* X_NOT_POSIX */
0088 #  include <fcntl.h>
0089 #  include <unistd.h>
0090 # endif /* X_NOT_POSIX else */
0091 
0092 /*
0093  * Get struct timeval and struct tm
0094  */
0095 
0096 # if defined(_POSIX_SOURCE) && defined(SVR4)
0097 /* need to omit _POSIX_SOURCE in order to get what we want in SVR4 */
0098 #  undef _POSIX_SOURCE
0099 #  include <sys/time.h>
0100 #  define _POSIX_SOURCE
0101 # elif defined(WIN32)
0102 #  include <time.h>
0103 #  if !defined(_WINSOCKAPI_) && !defined(_WILLWINSOCK_) && !defined(_TIMEVAL_DEFINED) && !defined(_STRUCT_TIMEVAL)
0104 struct timeval {
0105     long    tv_sec;         /* seconds */
0106     long    tv_usec;        /* and microseconds */
0107 };
0108 #   define _TIMEVAL_DEFINED
0109 #  endif
0110 #  include <sys/timeb.h>
0111 #  define gettimeofday(t) \
0112 { \
0113     struct _timeb _gtodtmp; \
0114     _ftime (&_gtodtmp); \
0115     (t)->tv_sec = _gtodtmp.time; \
0116     (t)->tv_usec = _gtodtmp.millitm * 1000; \
0117 }
0118 # else
0119 #  include <sys/time.h>
0120 #  include <time.h>
0121 # endif /* defined(_POSIX_SOURCE) && defined(SVR4) */
0122 
0123 /* define X_GETTIMEOFDAY macro, a portable gettimeofday() */
0124 # if defined(_XOPEN_XPG4) || defined(_XOPEN_UNIX) /* _XOPEN_UNIX is XPG4.2 */
0125 #  define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)
0126 # else
0127 #  if defined(SVR4) || defined(__SVR4) || defined(WIN32)
0128 #   define X_GETTIMEOFDAY(t) gettimeofday(t)
0129 #  else
0130 #   define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)
0131 #  endif
0132 # endif /* XPG4 else */
0133 
0134 
0135 # ifdef __GNU__
0136 #  define PATH_MAX 4096
0137 #  define MAXPATHLEN 4096
0138 #  define OPEN_MAX 256 /* We define a reasonable limit.  */
0139 # endif
0140 
0141 /* use POSIX name for signal */
0142 # if defined(X_NOT_POSIX) && defined(SYSV) && !defined(SIGCHLD)
0143 #  define SIGCHLD SIGCLD
0144 # endif
0145 
0146 # include <X11/Xarch.h>
0147 
0148 #endif /* _XOS_H_ */