1 /* System dependent declarations.
2 Copyright (C) 1988, 1989, 1992, 1993, 1994 Free Software Foundation, Inc.
4 This file is part of GNU DIFF.
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)
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.
18 /* We must define `volatile' and `const' first (the latter inside config.h),
19 so that they're used consistently in all system includes. */
27 #include <sys/types.h>
30 /* Note that PARAMS is just internal to the diff library; diffrun.h
31 has its own mechanism, which will hopefully be less likely to
32 conflict with the library's caller's namespace. */
34 #define PARAMS(args) args
37 #define PARAMS(args) ()
41 #if STAT_MACROS_BROKEN
50 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
53 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
55 #if !defined(S_ISBLK) && defined(S_IFBLK)
56 #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
58 #if !defined(S_ISCHR) && defined(S_IFCHR)
59 #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
61 #if !defined(S_ISFIFO) && defined(S_IFFIFO)
62 #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFFIFO)
66 # if defined( S_IFSOCK )
68 # define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
70 # define S_ISSOCK(mode) ((mode) & S_IFSOCK)
72 # elif defined( S_ISNAM )
73 /* SCO OpenServer 5.0.6a */
74 # define S_ISSOCK S_ISNAM
75 # endif /* !S_IFSOCK && S_ISNAM */
76 #endif /* !S_ISSOCK */
89 # include <sys/file.h>
100 #define STDIN_FILENO 0
102 #ifndef STDOUT_FILENO
103 #define STDOUT_FILENO 1
105 #ifndef STDERR_FILENO
106 #define STDERR_FILENO 2
109 /* I believe that all relevant systems have
110 time.h. It is in ANSI, for example. The
111 code below looks quite bogus as I don't think
112 sys/time.h is ever a substitute for time.h;
113 it is something different. */
114 #define HAVE_TIME_H 1
119 #include <sys/time.h>
126 #include <sys/file.h>
135 #include <sys/wait.h>
138 #define WEXITSTATUS(stat_val) ((unsigned) (stat_val) >> 8)
141 #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
144 #ifndef STAT_BLOCKSIZE
145 #if HAVE_STRUCT_STAT_ST_BLKSIZE
146 #define STAT_BLOCKSIZE(s) (s).st_blksize
148 #define STAT_BLOCKSIZE(s) (8 * 1024)
154 # define NAMLEN(dirent) strlen((dirent)->d_name)
156 # define dirent direct
157 # define NAMLEN(dirent) ((dirent)->d_namlen)
159 # include <sys/ndir.h>
162 # include <sys/dir.h>
173 #if HAVE_STDLIB_H || defined(STDC_HEADERS)
187 #define INT_MAX 2147483647
193 #if STDC_HEADERS || HAVE_STRING_H
196 # define bzero(s, n) memset (s, 0, n)
200 # define strchr index
201 # define strrchr rindex
203 char *strchr (), *strrchr ();
205 # define memcmp(s1, s2, n) bcmp (s1, s2, n)
206 # define memcpy(d, s, n) bcopy (s, d, n)
212 /* CTYPE_DOMAIN (C) is nonzero if the unsigned char C can safely be given
213 as an argument to <ctype.h> macros like `isspace'. */
215 #define CTYPE_DOMAIN(c) 1
217 #define CTYPE_DOMAIN(c) ((unsigned) (c) <= 0177)
220 #define ISPRINT(c) (CTYPE_DOMAIN (c) && isprint (c))
223 #define ISSPACE(c) (CTYPE_DOMAIN (c) && isspace (c))
226 #define ISUPPER(c) (CTYPE_DOMAIN (c) && isupper (c))
230 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
244 #define min(a,b) ((a) <= (b) ? (a) : (b))
245 #define max(a,b) ((a) >= (b) ? (a) : (b))
247 /* This section contains Posix-compliant defaults for macros
248 that are meant to be overridden by hand in config.h as needed. */
251 #define filename_cmp(a, b) strcmp (a, b)
254 #ifndef filename_lastdirchar
255 #define filename_lastdirchar(filename) strrchr (filename, '/')
263 #define HAVE_SETMODE 0
266 #ifndef initialize_main
267 #define initialize_main(argcp, argvp)
270 /* Do struct stat *S, *T describe the same file? Answer -1 if unknown. */
272 #define same_file(s,t) ((s)->st_ino==(t)->st_ino && (s)->st_dev==(t)->st_dev)
275 /* Place into Q a quoted version of A suitable for `popen' or `system',
276 incrementing Q and junking A.
277 Do not increment Q by more than 4 * strlen (A) + 2. */
278 #ifndef SYSTEM_QUOTE_ARG
279 #define SYSTEM_QUOTE_ARG(q, a) \
282 for (; *(a); *(q)++ = *(a)++) \
293 /* these come from CVS's lib/system.h, but I wasn't sure how to include that
294 * properly or even if I really should
297 #define CVS_OPENDIR opendir
300 #define CVS_READDIR readdir
303 #define CVS_CLOSEDIR closedir