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.
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. */
20 /* We must define `volatile' and `const' first (the latter inside config.h),
21 so that they're used consistently in all system includes. */
29 #include <sys/types.h>
33 #define PARAMS(args) args
36 #define PARAMS(args) ()
40 #if STAT_MACROS_BROKEN
49 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
52 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
54 #if !defined(S_ISBLK) && defined(S_IFBLK)
55 #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
57 #if !defined(S_ISCHR) && defined(S_IFCHR)
58 #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
60 #if !defined(S_ISFIFO) && defined(S_IFFIFO)
61 #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFFIFO)
63 #if !defined(S_ISSOCK) && defined(S_IFSOCK)
64 #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
79 #define STDIN_FILENO 0
82 #define STDOUT_FILENO 1
85 #define STDERR_FILENO 2
103 #define dup2(f,t) (close (t), fcntl (f,F_DUPFD,t))
111 #include <sys/wait.h>
114 #define WEXITSTATUS(stat_val) ((unsigned) (stat_val) >> 8)
117 #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
120 #ifndef STAT_BLOCKSIZE
122 #define STAT_BLOCKSIZE(s) (s).st_blksize
124 #define STAT_BLOCKSIZE(s) (8 * 1024)
130 # define NAMLEN(dirent) strlen((dirent)->d_name)
132 # define dirent direct
133 # define NAMLEN(dirent) ((dirent)->d_namlen)
135 # include <sys/ndir.h>
138 # include <sys/dir.h>
163 #define INT_MAX 2147483647
169 #if STDC_HEADERS || HAVE_STRING_H
172 # define bzero(s, n) memset (s, 0, n)
176 # define strchr index
177 # define strrchr rindex
179 char *strchr (), *strrchr ();
181 # define memcmp(s1, s2, n) bcmp (s1, s2, n)
182 # define memcpy(d, s, n) bcopy (s, d, n)
188 /* CTYPE_DOMAIN (C) is nonzero if the unsigned char C can safely be given
189 as an argument to <ctype.h> macros like `isspace'. */
191 #define CTYPE_DOMAIN(c) 1
193 #define CTYPE_DOMAIN(c) ((unsigned) (c) <= 0177)
196 #define ISPRINT(c) (CTYPE_DOMAIN (c) && isprint (c))
199 #define ISSPACE(c) (CTYPE_DOMAIN (c) && isspace (c))
202 #define ISUPPER(c) (CTYPE_DOMAIN (c) && isupper (c))
206 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
220 #define min(a,b) ((a) <= (b) ? (a) : (b))
221 #define max(a,b) ((a) >= (b) ? (a) : (b))
223 /* This section contains Posix-compliant defaults for macros
224 that are meant to be overridden by hand in config.h as needed. */
227 #define filename_cmp(a, b) strcmp (a, b)
230 #ifndef filename_lastdirchar
231 #define filename_lastdirchar(filename) strrchr (filename, '/')
239 #define HAVE_SETMODE 0
242 #ifndef initialize_main
243 #define initialize_main(argcp, argvp)
246 /* Do struct stat *S, *T describe the same file? Answer -1 if unknown. */
248 #define same_file(s,t) ((s)->st_ino==(t)->st_ino && (s)->st_dev==(t)->st_dev)
251 /* Place into Q a quoted version of A suitable for `popen' or `system',
252 incrementing Q and junking A.
253 Do not increment Q by more than 4 * strlen (A) + 2. */
254 #ifndef SYSTEM_QUOTE_ARG
255 #define SYSTEM_QUOTE_ARG(q, a) \
258 for (; *(a); *(q)++ = *(a)++) \