joachim99@52
|
1 /* System dependent declarations.
|
joachim99@52
|
2
|
joachim99@52
|
3 Modified for KDiff3 by Joachim Eibl 2003.
|
joachim99@53
|
4 The original file was part of GNU DIFF.
|
joachim99@52
|
5
|
joachim99@52
|
6 Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1998, 2001, 2002
|
joachim99@52
|
7 Free Software Foundation, Inc.
|
joachim99@52
|
8
|
joachim99@52
|
9 GNU DIFF is free software; you can redistribute it and/or modify
|
joachim99@52
|
10 it under the terms of the GNU General Public License as published by
|
joachim99@52
|
11 the Free Software Foundation; either version 2, or (at your option)
|
joachim99@52
|
12 any later version.
|
joachim99@52
|
13
|
joachim99@52
|
14 GNU DIFF is distributed in the hope that it will be useful,
|
joachim99@52
|
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
joachim99@52
|
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
joachim99@52
|
17 GNU General Public License for more details.
|
joachim99@52
|
18
|
joachim99@52
|
19 You should have received a copy of the GNU General Public License
|
joachim99@52
|
20 along with this program; see the file COPYING.
|
joachim99@52
|
21 If not, write to the Free Software Foundation,
|
joachim99@69
|
22 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. */
|
joachim99@52
|
23
|
joachim99@53
|
24 #ifndef GNUDIFF_SYSTEM_H
|
joachim99@53
|
25 #define GNUDIFF_SYSTEM_H
|
joachim99@53
|
26
|
joachim99@53
|
27
|
joachim99@53
|
28
|
joachim99@52
|
29 /* Don't bother to support K&R C compilers any more; it's not worth
|
joachim99@52
|
30 the trouble. These macros prevent some library modules from being
|
joachim99@52
|
31 compiled in K&R C mode. */
|
joachim99@52
|
32 #define PARAMS(Args) Args
|
joachim99@52
|
33 #define PROTOTYPES 1
|
joachim99@52
|
34
|
joachim99@52
|
35 /* Verify a requirement at compile-time (unlike assert, which is runtime). */
|
joachim99@52
|
36 #define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
|
joachim99@52
|
37
|
joachim99@52
|
38
|
joachim99@52
|
39 /* Determine whether an integer type is signed, and its bounds.
|
joachim99@52
|
40 This code assumes two's (or one's!) complement with no holes. */
|
joachim99@52
|
41
|
joachim99@52
|
42 /* The extra casts work around common compiler bugs,
|
joachim99@52
|
43 e.g. Cray C 5.0.3.0 when t == time_t. */
|
joachim99@52
|
44 #ifndef TYPE_SIGNED
|
joachim99@52
|
45 # define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
joachim99@52
|
46 #endif
|
joachim99@52
|
47 #ifndef TYPE_MINIMUM
|
joachim99@52
|
48 # define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
|
joachim99@52
|
49 ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
|
joachim99@52
|
50 : (t) 0))
|
joachim99@52
|
51 #endif
|
joachim99@52
|
52 #ifndef TYPE_MAXIMUM
|
joachim99@52
|
53 # define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
|
joachim99@52
|
54 #endif
|
joachim99@52
|
55
|
joachim99@52
|
56 #include <sys/types.h>
|
joachim99@52
|
57 #include <sys/stat.h>
|
joachim99@52
|
58
|
joachim99@52
|
59
|
joachim99@52
|
60 # include <stdlib.h>
|
joachim99@52
|
61 #ifndef EXIT_SUCCESS
|
joachim99@52
|
62 # define EXIT_SUCCESS 0
|
joachim99@52
|
63 #endif
|
joachim99@52
|
64 #if !EXIT_FAILURE
|
joachim99@52
|
65 # undef EXIT_FAILURE /* Sony NEWS-OS 4.0C defines EXIT_FAILURE to 0. */
|
joachim99@52
|
66 # define EXIT_FAILURE 1
|
joachim99@52
|
67 #endif
|
joachim99@52
|
68 #define EXIT_TROUBLE 2
|
joachim99@52
|
69
|
joachim99@52
|
70 #include <limits.h>
|
joachim99@52
|
71 #ifndef SSIZE_MAX
|
joachim99@52
|
72 # define SSIZE_MAX TYPE_MAXIMUM (ssize_t)
|
joachim99@52
|
73 #endif
|
joachim99@52
|
74
|
joachim99@52
|
75 #ifndef PTRDIFF_MAX
|
joachim99@52
|
76 # define PTRDIFF_MAX TYPE_MAXIMUM (ptrdiff_t)
|
joachim99@52
|
77 #endif
|
joachim99@52
|
78 #ifndef SIZE_MAX
|
joachim99@52
|
79 # define SIZE_MAX TYPE_MAXIMUM (size_t)
|
joachim99@52
|
80 #endif
|
joachim99@52
|
81 #ifndef UINTMAX_MAX
|
joachim99@52
|
82 # define UINTMAX_MAX TYPE_MAXIMUM (uintmax_t)
|
joachim99@52
|
83 #endif
|
joachim99@52
|
84
|
joachim99@52
|
85 #include <stddef.h>
|
joachim99@52
|
86 #include <string.h>
|
joachim99@52
|
87 #include <ctype.h>
|
joachim99@52
|
88
|
joachim99@52
|
89 /* CTYPE_DOMAIN (C) is nonzero if the unsigned char C can safely be given
|
joachim99@52
|
90 as an argument to <ctype.h> macros like `isspace'. */
|
joachim99@52
|
91 # define CTYPE_DOMAIN(c) 1
|
joachim99@52
|
92 #define ISPRINT(c) (CTYPE_DOMAIN (c) && isprint (c))
|
joachim99@52
|
93 #define ISSPACE(c) (CTYPE_DOMAIN (c) && isspace (c))
|
joachim99@52
|
94
|
joachim99@52
|
95 # define TOLOWER(c) tolower (c)
|
joachim99@52
|
96
|
joachim99@52
|
97 /* ISDIGIT differs from isdigit, as follows:
|
joachim99@52
|
98 - Its arg may be any int or unsigned int; it need not be an unsigned char.
|
joachim99@52
|
99 - It's guaranteed to evaluate its argument exactly once.
|
joachim99@52
|
100 - It's typically faster.
|
joachim99@52
|
101 POSIX 1003.1-2001 says that only '0' through '9' are digits.
|
joachim99@52
|
102 Prefer ISDIGIT to isdigit unless it's important to use the locale's
|
joachim99@52
|
103 definition of `digit' even when the host does not conform to POSIX. */
|
joachim99@52
|
104 #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
|
joachim99@52
|
105
|
joachim99@52
|
106 #undef MIN
|
joachim99@52
|
107 #undef MAX
|
joachim99@52
|
108 #define MIN(a, b) ((a) <= (b) ? (a) : (b))
|
joachim99@52
|
109 #define MAX(a, b) ((a) >= (b) ? (a) : (b))
|
joachim99@52
|
110
|
joachim99@52
|
111
|
joachim99@52
|
112 /* The integer type of a line number. Since files are read into main
|
joachim99@52
|
113 memory, ptrdiff_t should be wide enough. */
|
joachim99@52
|
114
|
joachim99@52
|
115 typedef ptrdiff_t lin;
|
joachim99@52
|
116 #define LIN_MAX PTRDIFF_MAX
|
joachim99@52
|
117 verify (lin_is_signed, TYPE_SIGNED (lin));
|
joachim99@52
|
118 verify (lin_is_wide_enough, sizeof (ptrdiff_t) <= sizeof (lin));
|
joachim99@52
|
119 verify (lin_is_printable_as_long, sizeof (lin) <= sizeof (long));
|
joachim99@53
|
120
|
joachim99@53
|
121 #endif
|