joachim99@52: /* System dependent declarations. joachim99@52: joachim99@52: Modified for KDiff3 by Joachim Eibl 2003. joachim99@53: The original file was part of GNU DIFF. joachim99@52: joachim99@52: Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1998, 2001, 2002 joachim99@52: Free Software Foundation, Inc. joachim99@52: joachim99@52: GNU DIFF is free software; you can redistribute it and/or modify joachim99@52: it under the terms of the GNU General Public License as published by joachim99@52: the Free Software Foundation; either version 2, or (at your option) joachim99@52: any later version. joachim99@52: joachim99@52: GNU DIFF is distributed in the hope that it will be useful, joachim99@52: but WITHOUT ANY WARRANTY; without even the implied warranty of joachim99@52: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the joachim99@52: GNU General Public License for more details. joachim99@52: joachim99@52: You should have received a copy of the GNU General Public License joachim99@52: along with this program; see the file COPYING. joachim99@52: If not, write to the Free Software Foundation, joachim99@69: 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. */ joachim99@52: joachim99@53: #ifndef GNUDIFF_SYSTEM_H joachim99@53: #define GNUDIFF_SYSTEM_H joachim99@53: joachim99@53: joachim99@53: joachim99@52: /* Don't bother to support K&R C compilers any more; it's not worth joachim99@52: the trouble. These macros prevent some library modules from being joachim99@52: compiled in K&R C mode. */ joachim99@52: #define PARAMS(Args) Args joachim99@52: #define PROTOTYPES 1 joachim99@52: joachim99@52: /* Verify a requirement at compile-time (unlike assert, which is runtime). */ joachim99@52: #define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; } joachim99@52: joachim99@52: joachim99@52: /* Determine whether an integer type is signed, and its bounds. joachim99@52: This code assumes two's (or one's!) complement with no holes. */ joachim99@52: joachim99@52: /* The extra casts work around common compiler bugs, joachim99@52: e.g. Cray C 5.0.3.0 when t == time_t. */ joachim99@52: #ifndef TYPE_SIGNED joachim99@52: # define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) joachim99@52: #endif joachim99@52: #ifndef TYPE_MINIMUM joachim99@52: # define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \ joachim99@52: ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \ joachim99@52: : (t) 0)) joachim99@52: #endif joachim99@52: #ifndef TYPE_MAXIMUM joachim99@52: # define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t))) joachim99@52: #endif joachim99@52: joachim99@52: #include joachim99@52: #include joachim99@52: joachim99@52: joachim99@52: # include joachim99@52: #ifndef EXIT_SUCCESS joachim99@52: # define EXIT_SUCCESS 0 joachim99@52: #endif joachim99@52: #if !EXIT_FAILURE joachim99@52: # undef EXIT_FAILURE /* Sony NEWS-OS 4.0C defines EXIT_FAILURE to 0. */ joachim99@52: # define EXIT_FAILURE 1 joachim99@52: #endif joachim99@52: #define EXIT_TROUBLE 2 joachim99@52: joachim99@52: #include joachim99@52: #ifndef SSIZE_MAX joachim99@52: # define SSIZE_MAX TYPE_MAXIMUM (ssize_t) joachim99@52: #endif joachim99@52: joachim99@52: #ifndef PTRDIFF_MAX joachim99@52: # define PTRDIFF_MAX TYPE_MAXIMUM (ptrdiff_t) joachim99@52: #endif joachim99@52: #ifndef SIZE_MAX joachim99@52: # define SIZE_MAX TYPE_MAXIMUM (size_t) joachim99@52: #endif joachim99@52: #ifndef UINTMAX_MAX joachim99@52: # define UINTMAX_MAX TYPE_MAXIMUM (uintmax_t) joachim99@52: #endif joachim99@52: joachim99@52: #include joachim99@52: #include joachim99@52: #include joachim99@52: joachim99@52: /* CTYPE_DOMAIN (C) is nonzero if the unsigned char C can safely be given joachim99@52: as an argument to macros like `isspace'. */ joachim99@52: # define CTYPE_DOMAIN(c) 1 joachim99@52: #define ISPRINT(c) (CTYPE_DOMAIN (c) && isprint (c)) joachim99@52: #define ISSPACE(c) (CTYPE_DOMAIN (c) && isspace (c)) joachim99@52: joachim99@52: # define TOLOWER(c) tolower (c) joachim99@52: joachim99@52: /* ISDIGIT differs from isdigit, as follows: joachim99@52: - Its arg may be any int or unsigned int; it need not be an unsigned char. joachim99@52: - It's guaranteed to evaluate its argument exactly once. joachim99@52: - It's typically faster. joachim99@52: POSIX 1003.1-2001 says that only '0' through '9' are digits. joachim99@52: Prefer ISDIGIT to isdigit unless it's important to use the locale's joachim99@52: definition of `digit' even when the host does not conform to POSIX. */ joachim99@52: #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9) joachim99@52: joachim99@52: #undef MIN joachim99@52: #undef MAX joachim99@52: #define MIN(a, b) ((a) <= (b) ? (a) : (b)) joachim99@52: #define MAX(a, b) ((a) >= (b) ? (a) : (b)) joachim99@52: joachim99@52: joachim99@52: /* The integer type of a line number. Since files are read into main joachim99@52: memory, ptrdiff_t should be wide enough. */ joachim99@52: joachim99@52: typedef ptrdiff_t lin; joachim99@52: #define LIN_MAX PTRDIFF_MAX joachim99@52: verify (lin_is_signed, TYPE_SIGNED (lin)); joachim99@52: verify (lin_is_wide_enough, sizeof (ptrdiff_t) <= sizeof (lin)); joachim99@52: verify (lin_is_printable_as_long, sizeof (lin) <= sizeof (long)); joachim99@53: joachim99@53: #endif