home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / rcs567s.zip / diff / system.h < prev    next >
C/C++ Source or Header  |  1995-03-03  |  5KB  |  248 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. #ifdef __WATCOMC__
  155. typedef int pid_t;
  156. #include <direct.h>
  157. #else
  158. #include <dirent.h>
  159. #endif
  160. #else /* ! (DIRENT || defined (_POSIX_VERSION)) */
  161. #if SYSNDIR
  162. #include <sys/ndir.h>
  163. #else
  164. #if SYSDIR
  165. #include <sys/dir.h>
  166. #else
  167. #include <ndir.h>
  168. #endif
  169. #endif
  170. #ifdef dirent
  171. #undef dirent
  172. #endif
  173. #define dirent direct
  174. #endif /* ! (DIRENT || defined (_POSIX_VERSION)) */
  175.  
  176. #if HAVE_VFORK_H
  177. #include <vfork.h>
  178. #else
  179. #define vfork fork
  180. #endif
  181.  
  182. #if HAVE_STDLIB_H
  183. #include <stdlib.h>
  184. #else
  185. VOID *malloc ();
  186. VOID *realloc ();
  187. #endif
  188. #ifndef getenv
  189. char *getenv ();
  190. #endif
  191.  
  192. #if HAVE_LIMITS_H
  193. #include <limits.h>
  194. #endif
  195. #ifndef INT_MAX
  196. #define INT_MAX 2147483647
  197. #endif
  198. #ifndef CHAR_BIT
  199. #define CHAR_BIT 8
  200. #endif
  201.  
  202. #if HAVE_STRING_H
  203. #include <string.h>
  204. #ifndef bzero
  205. #define bzero(s,n) memset (s,0,n)
  206. #endif
  207. #else /* !HAVE_STRING_H */
  208. #include <strings.h>
  209. #ifndef strchr
  210. #define strchr index
  211. #endif
  212. #ifndef strrchr
  213. #define strrchr rindex
  214. #endif
  215. #ifndef memcpy
  216. #define memcpy(d,s,n) bcopy (s,d,n)
  217. #endif
  218. #ifndef memcmp
  219. #define memcmp(s1,s2,n) bcmp (s1,s2,n)
  220. #endif
  221. #endif /* !HAVE_STRING_H */
  222. #if !HAVE_MEMCHR
  223. char *memchr ();
  224. #endif
  225.  
  226. #include <errno.h>
  227. #if !STDC_HEADERS
  228. extern int errno;
  229. #endif
  230.  
  231. #ifdef min
  232. #undef min
  233. #endif
  234. #ifdef max
  235. #undef max
  236. #endif
  237. #define min(a,b) ((a) <= (b) ? (a) : (b))
  238. #define max(a,b) ((a) >= (b) ? (a) : (b))
  239.  
  240. #ifdef OS2
  241. #include <process.h>
  242. /* typedef int pid_t; */
  243. #define DIFF_PROGRAM "diff.exe"
  244. #ifdef __EMX__
  245. #define main os2main
  246. #endif
  247. #endif
  248.