2 Copyright (C) 1995, 1998, 2001, 2003 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 /* Note: MIN, MAX are also defined in <sys/param.h> on some systems
22 (glibc, IRIX, HP-UX, OSF/1). Therefore you might get warnings about
23 MIN, MAX macro redefinitions on some systems; the workaround is to
24 #include this file as the last one among the #include list. */
26 /* Before we define the following symbols we get the <limits.h> file
27 since otherwise we get redefinitions on some systems. */
30 /* Note: MIN and MAX should preferrably be used with two arguments of the
31 same type. They might not return the minimum and maximum of their two
32 arguments, if the arguments have different types or have unusual
33 floating-point values. For example, on a typical host with 32-bit 'int',
34 64-bit 'long long', and 64-bit IEEE 754 'double' types:
36 MAX (-1, 2147483648) returns 4294967295.
37 MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0.
38 MAX (NaN, 0.0) returns 0.0.
39 MAX (+0.0, -0.0) returns -0.0.
41 and in each case the answer is in some sense bogus. */
43 /* MAX(a,b) returns the maximum of A and B. */
45 # if __STDC__ && defined __GNUC__ && __GNUC__ >= 2
46 # define MAX(a,b) (__extension__ \
47 ({__typeof__ (a) _a = (a); \
48 __typeof__ (b) _b = (b); \
52 # define MAX(a,b) ((a) > (b) ? (a) : (b))
56 /* MIN(a,b) returns the minimum of A and B. */
58 # if __STDC__ && defined __GNUC__ && __GNUC__ >= 2
59 # define MIN(a,b) (__extension__ \
60 ({__typeof__ (a) _a = (a); \
61 __typeof__ (b) _b = (b); \
65 # define MIN(a,b) ((a) < (b) ? (a) : (b))
69 #endif /* _MINMAX_H */