home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / rcs567s.zip / diff / system.h < prev    next >
C/C++ Source or Header  |  1993-11-13  |  5KB  |  243 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. /* We must define `volatile' and `const' first (the latter inside config.h),
  21.    so that they're used consistently in all system includes.  */
  22. #if !__STDC__
  23. #ifndef volatile
  24. #define volatile
  25. #endif
  26. #endif
  27. #include <config.h>
  28.  
  29. #include <sys/types.h>
  30. #include <sys/stat.h>
  31.  
  32. #if __STDC__
  33. #define PARAMS(args) args
  34. #define VOID void
  35. #else
  36. #define PARAMS(args) ()
  37. #define VOID char
  38. #endif
  39.  
  40. #if STAT_MACROS_BROKEN
  41. #undef S_ISBLK
  42. #undef S_ISCHR
  43. #undef S_ISDIR
  44. #undef S_ISFIFO
  45. #undef S_ISREG
  46. #undef S_ISSOCK
  47. #endif
  48. #ifndef S_ISDIR
  49. #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
  50. #endif
  51. #ifndef S_ISREG
  52. #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
  53. #endif
  54. #if !defined(S_ISBLK) && defined(S_IFBLK)
  55. #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
  56. #endif
  57. #if !defined(S_ISCHR) && defined(S_IFCHR)
  58. #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
  59. #endif
  60. #if !defined(S_ISFIFO) && defined(S_IFFIFO)
  61. #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFFIFO)
  62. #endif
  63. #if !defined(S_ISSOCK) && defined(S_IFSOCK)
  64. #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
  65. #endif
  66.  
  67. #ifndef S_IXOTH
  68. #define S_IXOTH 1
  69. #endif
  70. #ifndef S_IXGRP
  71. #define S_IXGRP (S_IXOTH << 3)
  72. #endif
  73. #ifndef S_IXUSR
  74. #define S_IXUSR (S_IXGRP << 3)
  75. #endif
  76.  
  77. #if HAVE_UNISTD_H
  78. #include <unistd.h>
  79. #endif
  80.  
  81. #ifndef SEEK_SET
  82. #define SEEK_SET 0
  83. #endif
  84. #ifndef SEEK_CUR
  85. #define SEEK_CUR 1
  86. #endif
  87.  
  88. #ifndef STDIN_FILENO
  89. #define STDIN_FILENO 0
  90. #endif
  91. #ifndef STDOUT_FILENO
  92. #define STDOUT_FILENO 1
  93. #endif
  94. #ifndef STDERR_FILENO
  95. #define STDERR_FILENO 2
  96. #endif
  97.  
  98. #if HAVE_TIME_H
  99. #include <time.h>
  100. #else
  101. #ifdef __WATCOMC__
  102. #include <time.h>
  103. #else
  104. #include <sys/time.h>
  105. #endif
  106. #endif
  107.  
  108. #if HAVE_FCNTL_H
  109. #include <fcntl.h>
  110. #else
  111. #ifndef __WATCOMC__
  112. #include <sys/file.h>
  113. #endif
  114. #endif
  115.  
  116. #if !HAVE_DUP2
  117. #define dup2(f,t)    (close (t),  fcntl (f,F_DUPFD,t))
  118. #endif
  119.  
  120. #ifndef O_RDONLY
  121. #define O_RDONLY 0
  122. #endif
  123.  
  124. #if HAVE_SYS_WAIT_H
  125. #ifndef _POSIX_VERSION
  126. /* Prevent the NeXT prototype using union wait from causing problems.  */
  127. #define wait system_wait
  128. #endif
  129. #include <sys/wait.h>
  130. #ifndef _POSIX_VERSION
  131. #undef wait
  132. #endif
  133. #endif /* HAVE_SYS_WAIT_H */
  134.  
  135. #ifndef WEXITSTATUS
  136. #define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
  137. #undef WIFEXITED        /* Avoid 4.3BSD incompatibility with Posix.  */
  138. #endif
  139. #ifndef WIFEXITED
  140. #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
  141. #endif
  142.  
  143. #if HAVE_ST_BLKSIZE
  144. #define STAT_BLOCKSIZE(s) (s).st_blksize
  145. #else
  146. #ifdef OS2
  147. #define STAT_BLOCKSIZE(s) (64 * 1024)
  148. #else
  149. #define STAT_BLOCKSIZE(s) (8 * 1024)
  150. #endif
  151. #endif
  152.  
  153. #if DIRENT || defined (_POSIX_VERSION)
  154. #include <dirent.h>
  155. #else /* ! (DIRENT || defined (_POSIX_VERSION)) */
  156. #if SYSNDIR
  157. #include <sys/ndir.h>
  158. #else
  159. #if SYSDIR
  160. #include <sys/dir.h>
  161. #else
  162. #include <ndir.h>
  163. #endif
  164. #endif
  165. #ifdef dirent
  166. #undef dirent
  167. #endif
  168. #define dirent direct
  169. #endif /* ! (DIRENT || defined (_POSIX_VERSION)) */
  170.  
  171. #if HAVE_VFORK_H
  172. #include <vfork.h>
  173. #else
  174. #define vfork fork
  175. #endif
  176.  
  177. #if HAVE_STDLIB_H
  178. #include <stdlib.h>
  179. #else
  180. VOID *malloc ();
  181. VOID *realloc ();
  182. #endif
  183. #ifndef getenv
  184. char *getenv ();
  185. #endif
  186.  
  187. #if HAVE_LIMITS_H
  188. #include <limits.h>
  189. #endif
  190. #ifndef INT_MAX
  191. #define INT_MAX 2147483647
  192. #endif
  193. #ifndef CHAR_BIT
  194. #define CHAR_BIT 8
  195. #endif
  196.  
  197. #if HAVE_STRING_H
  198. #include <string.h>
  199. #ifndef bzero
  200. #define bzero(s,n) memset (s,0,n)
  201. #endif
  202. #else /* !HAVE_STRING_H */
  203. #include <strings.h>
  204. #ifndef strchr
  205. #define strchr index
  206. #endif
  207. #ifndef strrchr
  208. #define strrchr rindex
  209. #endif
  210. #ifndef memcpy
  211. #define memcpy(d,s,n) bcopy (s,d,n)
  212. #endif
  213. #ifndef memcmp
  214. #define memcmp(s1,s2,n) bcmp (s1,s2,n)
  215. #endif
  216. #endif /* !HAVE_STRING_H */
  217. #if !HAVE_MEMCHR
  218. char *memchr ();
  219. #endif
  220.  
  221. #include <errno.h>
  222. #if !STDC_HEADERS
  223. extern int errno;
  224. #endif
  225.  
  226. #ifdef min
  227. #undef min
  228. #endif
  229. #ifdef max
  230. #undef max
  231. #endif
  232. #define min(a,b) ((a) <= (b) ? (a) : (b))
  233. #define max(a,b) ((a) >= (b) ? (a) : (b))
  234.  
  235. #ifdef OS2
  236. #include <process.h>
  237. typedef int pid_t;
  238. #define DIFF_PROGRAM "diff.exe"
  239. #ifdef __EMX__
  240. #define main os2main
  241. #endif
  242. #endif
  243.