home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / online / source / c / compilers / DiffUtils.sit.hqx / DiffUtils / src / system.h < prev    next >
Text File  |  1993-11-15  |  5KB  |  235 lines

  1. /* System dependent declarations.
  2.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU DIFF.
  5.  
  6. GNU DIFF is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU DIFF is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU DIFF; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #ifdef macintosh
  21. #include <Types.h>
  22.  
  23. #include "config.h"
  24.  
  25. #include <sys/types.h>
  26. #include <sys/stat.h>
  27.  
  28. #define PARAMS(args) args
  29. #define VOID void
  30.  
  31. #else
  32. /* We must define `volatile' and `const' first (the latter inside config.h),
  33.    so that they're used consistently in all system includes.  */
  34. #if !__STDC__
  35. #ifndef volatile
  36. #define volatile
  37. #endif
  38. #endif
  39. #include <config.h>
  40.  
  41. #include <sys/types.h>
  42. #include <sys/stat.h>
  43.  
  44. #if __STDC__
  45. #define PARAMS(args) args
  46. #define VOID void
  47. #else
  48. #define PARAMS(args) ()
  49. #define VOID char
  50. #endif
  51.  
  52. #if STAT_MACROS_BROKEN
  53. #undef S_ISBLK
  54. #undef S_ISCHR
  55. #undef S_ISDIR
  56. #undef S_ISFIFO
  57. #undef S_ISREG
  58. #undef S_ISSOCK
  59. #endif
  60. #ifndef S_ISDIR
  61. #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
  62. #endif
  63. #ifndef S_ISREG
  64. #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
  65. #endif
  66. #if !defined(S_ISBLK) && defined(S_IFBLK)
  67. #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
  68. #endif
  69. #if !defined(S_ISCHR) && defined(S_IFCHR)
  70. #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
  71. #endif
  72. #if !defined(S_ISFIFO) && defined(S_IFFIFO)
  73. #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFFIFO)
  74. #endif
  75. #if !defined(S_ISSOCK) && defined(S_IFSOCK)
  76. #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
  77. #endif
  78. #endif
  79.  
  80. #ifndef S_IXOTH
  81. #define S_IXOTH 1
  82. #endif
  83. #ifndef S_IXGRP
  84. #define S_IXGRP (S_IXOTH << 3)
  85. #endif
  86. #ifndef S_IXUSR
  87. #define S_IXUSR (S_IXGRP << 3)
  88. #endif
  89.  
  90. #ifndef S_ISDIR
  91. #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
  92. #endif
  93. #ifndef S_ISREG
  94. #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
  95. #endif
  96.  
  97. #if HAVE_UNISTD_H
  98. #include <unistd.h>
  99. #endif
  100.  
  101. #ifndef STDIN_FILENO
  102. #define STDIN_FILENO 0
  103. #endif
  104. #ifndef STDOUT_FILENO
  105. #define STDOUT_FILENO 1
  106. #endif
  107. #ifndef STDERR_FILENO
  108. #define STDERR_FILENO 2
  109. #endif
  110.  
  111. #if HAVE_TIME_H
  112. #include <time.h>
  113. #else
  114. #include <sys/time.h>
  115. #endif
  116.  
  117. #if HAVE_FCNTL_H
  118. #include <fcntl.h>
  119. #else
  120. #include <sys/file.h>
  121. #endif
  122.  
  123. #if !HAVE_DUP2
  124. #define dup2(f,t)    (close (t),  fcntl (f,F_DUPFD,t))
  125. #endif
  126.  
  127. #ifndef O_RDONLY
  128. #define O_RDONLY 0
  129. #endif
  130.  
  131. #if HAVE_SYS_WAIT_H
  132. #ifndef _POSIX_VERSION
  133. /* Prevent the NeXT prototype using union wait from causing problems.  */
  134. #define wait system_wait
  135. #endif
  136. #include <sys/wait.h>
  137. #ifndef _POSIX_VERSION
  138. #undef wait
  139. #endif
  140. #endif /* HAVE_SYS_WAIT_H */
  141.  
  142. #ifndef WEXITSTATUS
  143. #define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
  144. #undef WIFEXITED        /* Avoid 4.3BSD incompatibility with Posix.  */
  145. #endif
  146. #ifndef WIFEXITED
  147. #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
  148. #endif
  149.  
  150. #if HAVE_ST_BLKSIZE
  151. #define STAT_BLOCKSIZE(s) (s).st_blksize
  152. #else
  153. #define STAT_BLOCKSIZE(s) (8 * 1024)
  154. #endif
  155.  
  156. #if DIRENT || defined (_POSIX_VERSION)
  157. #include <dirent.h>
  158. #else /* ! (DIRENT || defined (_POSIX_VERSION)) */
  159. #if SYSNDIR
  160. #include <sys/ndir.h>
  161. #else
  162. #if SYSDIR
  163. #include <sys/dir.h>
  164. #else
  165. #include <ndir.h>
  166. #endif
  167. #endif
  168. #ifdef dirent
  169. #undef dirent
  170. #endif
  171. #define dirent direct
  172. #endif /* ! (DIRENT || defined (_POSIX_VERSION)) */
  173.  
  174. #if HAVE_VFORK_H
  175. #include <vfork.h>
  176. #endif
  177.  
  178. #if HAVE_STDLIB_H
  179. #include <stdlib.h>
  180. #else
  181. VOID *malloc ();
  182. VOID *realloc ();
  183. #endif
  184. #ifndef getenv
  185. char *getenv ();
  186. #endif
  187.  
  188. #if HAVE_LIMITS_H
  189. #include <limits.h>
  190. #endif
  191. #ifndef INT_MAX
  192. #define INT_MAX 2147483647
  193. #endif
  194. #ifndef CHAR_BIT
  195. #define CHAR_BIT 8
  196. #endif
  197.  
  198. #if HAVE_STRING_H
  199. #include <string.h>
  200. #ifndef bzero
  201. #define bzero(s,n) memset (s,0,n)
  202. #endif
  203. #else /* !HAVE_STRING_H */
  204. #include <strings.h>
  205. #ifndef strchr
  206. #define strchr index
  207. #endif
  208. #ifndef strrchr
  209. #define strrchr rindex
  210. #endif
  211. #ifndef memcpy
  212. #define memcpy(d,s,n) bcopy (s,d,n)
  213. #endif
  214. #ifndef memcmp
  215. #define memcmp(s1,s2,n) bcmp (s1,s2,n)
  216. #endif
  217. #endif /* !HAVE_STRING_H */
  218. #if !HAVE_MEMCHR
  219. char *memchr ();
  220. #endif
  221.  
  222. #include <errno.h>
  223. #if !STDC_HEADERS
  224. extern int errno;
  225. #endif
  226.  
  227. #define min(a,b) ((a) <= (b) ? (a) : (b))
  228. #define max(a,b) ((a) >= (b) ? (a) : (b))
  229.  
  230. #ifdef macintosh
  231. #define OPEN(x,y,z)    open(x,y)
  232. #else
  233. #define OPEN(x,y,z)    open(x,y,z)
  234. #endif
  235.