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)
64 #if !defined(S_ISSOCK) && defined(S_IFSOCK)
65 #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
80 #define STDIN_FILENO 0
83 #define STDOUT_FILENO 1
86 #define STDERR_FILENO 2
89 /* I believe that all relevant systems have
90 time.h. It is in ANSI, for example. The
91 code below looks quite bogus as I don't think
92 sys/time.h is ever a substitute for time.h;
93 it is something different. */
106 #include <sys/file.h>
115 #include <sys/wait.h>
118 #define WEXITSTATUS(stat_val) ((unsigned) (stat_val) >> 8)
121 #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
124 #ifndef STAT_BLOCKSIZE
126 #define STAT_BLOCKSIZE(s) (s).st_blksize
128 #define STAT_BLOCKSIZE(s) (8 * 1024)
134 # define NAMLEN(dirent) strlen((dirent)->d_name)
136 # define dirent direct
137 # define NAMLEN(dirent) ((dirent)->d_namlen)
139 # include <sys/ndir.h>
142 # include <sys/dir.h>
153 #if HAVE_STDLIB_H || defined(STDC_HEADERS)
167 #define INT_MAX 2147483647
173 #if STDC_HEADERS || HAVE_STRING_H
176 # define bzero(s, n) memset (s, 0, n)
180 # define strchr index
181 # define strrchr rindex
183 char *strchr (), *strrchr ();
185 # define memcmp(s1, s2, n) bcmp (s1, s2, n)
186 # define memcpy(d, s, n) bcopy (s, d, n)
192 /* CTYPE_DOMAIN (C) is nonzero if the unsigned char C can safely be given
193 as an argument to <ctype.h> macros like `isspace'. */
195 #define CTYPE_DOMAIN(c) 1
197 #define CTYPE_DOMAIN(c) ((unsigned) (c) <= 0177)
200 #define ISPRINT(c) (CTYPE_DOMAIN (c) && isprint (c))
203 #define ISSPACE(c) (CTYPE_DOMAIN (c) && isspace (c))
206 #define ISUPPER(c) (CTYPE_DOMAIN (c) && isupper (c))
210 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
224 #define min(a,b) ((a) <= (b) ? (a) : (b))
225 #define max(a,b) ((a) >= (b) ? (a) : (b))
227 /* This section contains Posix-compliant defaults for macros
228 that are meant to be overridden by hand in config.h as needed. */
231 #define filename_cmp(a, b) strcmp (a, b)
234 #ifndef filename_lastdirchar
235 #define filename_lastdirchar(filename) strrchr (filename, '/')
243 #define HAVE_SETMODE 0
246 #ifndef initialize_main
247 #define initialize_main(argcp, argvp)
250 /* Do struct stat *S, *T describe the same file? Answer -1 if unknown. */
252 #define same_file(s,t) ((s)->st_ino==(t)->st_ino && (s)->st_dev==(t)->st_dev)
255 /* Place into Q a quoted version of A suitable for `popen' or `system',
256 incrementing Q and junking A.
257 Do not increment Q by more than 4 * strlen (A) + 2. */
258 #ifndef SYSTEM_QUOTE_ARG
259 #define SYSTEM_QUOTE_ARG(q, a) \
262 for (; *(a); *(q)++ = *(a)++) \
273 /* these come from CVS's lib/system.h, but I wasn't sure how to include that
274 * properly or even if I really should
277 #define CVS_OPENDIR opendir
280 #define CVS_READDIR readdir
283 #define CVS_CLOSEDIR closedir