home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-bin / x11r6.1 / include / x11 / xos.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-17  |  5.2 KB  |  220 lines

  1. /*
  2.  * $XConsortium: Xos.h,v 1.68 95/06/02 16:51:21 gildea Exp $
  3.  * 
  4.  * 
  5. Copyright (c) 1987  X Consortium
  6.  
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  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. X CONSORTIUM 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 X Consortium 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 X Consortium.
  27.  *
  28.  * The X Window System is a Trademark of X Consortium.
  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 <X11/Xosdefs.h>
  40.  
  41. /*
  42.  * Get major data types (esp. caddr_t)
  43.  */
  44.  
  45. #ifdef USG
  46. #ifndef __TYPES__
  47. #ifdef CRAY
  48. #define word word_t
  49. #endif /* CRAY */
  50. #include <sys/types.h>            /* forgot to protect it... */
  51. #define __TYPES__
  52. #endif /* __TYPES__ */
  53. #else /* USG */
  54. #if defined(_POSIX_SOURCE) && (defined(MOTOROLA) || defined(AMOEBA))
  55. #undef _POSIX_SOURCE
  56. #include <sys/types.h>
  57. #define _POSIX_SOURCE
  58. #else
  59. #include <sys/types.h>
  60. #endif
  61. #endif /* USG */
  62.  
  63.  
  64. /*
  65.  * Just about everyone needs the strings routines.  We provide both forms here,
  66.  * index/rindex and strchr/strrchr, so any systems that don't provide them all
  67.  * need to have #defines here.
  68.  */
  69.  
  70. #ifndef X_NOT_STDC_ENV
  71.  
  72. #include <string.h>
  73. #ifndef index
  74. #define index strchr
  75. #endif
  76. #ifndef rindex
  77. #define rindex strrchr
  78. #endif
  79.  
  80. #else
  81.  
  82. #ifdef SYSV
  83. #include <string.h>
  84. #define index strchr
  85. #define rindex strrchr
  86. #else
  87. #include <strings.h>
  88. #define strchr index
  89. #define strrchr rindex
  90. #endif
  91.  
  92. #endif /* X_NOT_STDC_ENV */
  93.  
  94. /*
  95.  * strerror()
  96.  */
  97. #if defined(X_NOT_STDC_ENV) || (defined(sun) && !defined(SVR4)) || defined(macII)
  98. #ifndef strerror
  99. extern char *sys_errlist[];
  100. extern int sys_nerr;
  101. #define strerror(n) \
  102.     (((n) >= 0 && (n) < sys_nerr) ? sys_errlist[n] : "unknown error")
  103. #endif
  104. #endif
  105.  
  106. /*
  107.  * Get open(2) constants
  108.  */
  109. #ifdef X_NOT_POSIX
  110. #include <fcntl.h>
  111. #if defined(USL) || defined(CRAY) || defined(MOTOROLA) || (defined(i386) && (defined(SYSV) || defined(SVR4))) || defined(__sxg__)
  112. #include <unistd.h>
  113. #endif
  114. #ifdef WIN32
  115. #include <X11/Xw32defs.h>
  116. #else
  117. #include <sys/file.h>
  118. #endif
  119. #else /* X_NOT_POSIX */
  120. #if !defined(_POSIX_SOURCE) && defined(macII)
  121. #define _POSIX_SOURCE
  122. #include <fcntl.h>
  123. #include <unistd.h>
  124. #undef _POSIX_SOURCE
  125. #else
  126. #include <fcntl.h>
  127. #include <unistd.h>
  128. #endif
  129. #endif /* X_NOT_POSIX else */
  130.  
  131. /*
  132.  * Get struct timeval
  133.  */
  134.  
  135. #ifdef SYSV
  136.  
  137. #ifndef USL
  138. #include <sys/time.h>
  139. #endif
  140. #include <time.h>
  141. #ifdef CRAY
  142. #undef word
  143. #endif /* CRAY */
  144. #if defined(USG) && !defined(CRAY) && !defined(MOTOROLA) && !defined(uniosu) && !defined(__sxg__)
  145. struct timeval {
  146.     long tv_sec;
  147.     long tv_usec;
  148. };
  149. #ifndef USL_SHARELIB
  150. struct timezone {
  151.     int tz_minuteswest;
  152.     int tz_dsttime;
  153. };
  154. #endif /* USL_SHARELIB */
  155. #endif /* USG */
  156.  
  157. #ifdef _SEQUENT_
  158. struct timezone {
  159.     int tz_minuteswest;
  160.     int tz_dsttime;
  161. };
  162. #endif /* _SEQUENT_ */
  163.  
  164. #else /* not SYSV */
  165.  
  166. #if defined(_POSIX_SOURCE) && defined(SVR4)
  167. /* need to omit _POSIX_SOURCE in order to get what we want in SVR4 */
  168. #undef _POSIX_SOURCE
  169. #include <sys/time.h>
  170. #define _POSIX_SOURCE
  171. #else /* defined(_POSIX_SOURCE) && defined(SVR4) */
  172. #ifdef WIN32
  173. #include <time.h>
  174. #if !defined(_WINSOCKAPI_) && !defined(_WILLWINSOCK_)
  175. struct timeval {
  176.     long    tv_sec;         /* seconds */
  177.     long    tv_usec;        /* and microseconds */
  178. };
  179. #endif
  180. #include <sys/timeb.h>
  181. #define gettimeofday(t) \
  182. { \
  183.     struct _timeb _gtodtmp; \
  184.     _ftime (&_gtodtmp); \
  185.     (t)->tv_sec = _gtodtmp.time; \
  186.     (t)->tv_usec = _gtodtmp.millitm * 1000; \
  187. }
  188. #else /* WIN32 */
  189. #ifdef _SEQUENT_
  190. #include <time.h>
  191. #else /* _SEQUENT_ */
  192. #include <sys/time.h>
  193. #endif /* _SEQUENT_ */
  194. #endif /* WIN32 else */
  195. #endif /* defined(_POSIX_SOURCE) && defined(SVR4) */
  196.  
  197. #endif /* SYSV */
  198.  
  199. /* define X_GETTIMEOFDAY macro, a portable gettimeofday() */
  200. #if defined(_XOPEN_XPG4) || defined(_XOPEN_UNIX) /* _XOPEN_UNIX is XPG4.2 */
  201. #define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)
  202. #else
  203. #if defined(SVR4) || defined(VMS) || defined(WIN32)
  204. #define X_GETTIMEOFDAY(t) gettimeofday(t)
  205. #else
  206. #define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)
  207. #endif
  208. #endif /* XPG4 else */
  209.  
  210. /* use POSIX name for signal */
  211. #if defined(X_NOT_POSIX) && defined(SYSV) && !defined(SIGCHLD)
  212. #define SIGCHLD SIGCLD
  213. #endif
  214.  
  215. #ifdef ISC
  216. #include <sys/bsdtypes.h>
  217. #endif
  218.  
  219. #endif /* _XOS_H_ */
  220.