Compatibility text updated.
[gnutls.git] / gl / minmax.h
blob172fafee4da0d39fd18a6a907c0baaa2719c8dcd
1 /* MIN, MAX macros.
2 Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2011 Free Software
3 Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 #ifndef _MINMAX_H
20 #define _MINMAX_H
22 /* Note: MIN, MAX are also defined in <sys/param.h> on some systems
23 (glibc, IRIX, HP-UX, OSF/1). Therefore you might get warnings about
24 MIN, MAX macro redefinitions on some systems; the workaround is to
25 #include this file as the last one among the #include list. */
27 /* Before we define the following symbols we get the <limits.h> file
28 since otherwise we get redefinitions on some systems if <limits.h> is
29 included after this file. Likewise for <sys/param.h>.
30 If more than one of these system headers define MIN and MAX, pick just
31 one of the headers (because the definitions most likely are the same). */
32 #if HAVE_MINMAX_IN_LIMITS_H
33 # include <limits.h>
34 #elif HAVE_MINMAX_IN_SYS_PARAM_H
35 # include <sys/param.h>
36 #endif
38 /* Note: MIN and MAX should be used with two arguments of the
39 same type. They might not return the minimum and maximum of their two
40 arguments, if the arguments have different types or have unusual
41 floating-point values. For example, on a typical host with 32-bit 'int',
42 64-bit 'long long', and 64-bit IEEE 754 'double' types:
44 MAX (-1, 2147483648) returns 4294967295.
45 MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0.
46 MAX (NaN, 0.0) returns 0.0.
47 MAX (+0.0, -0.0) returns -0.0.
49 and in each case the answer is in some sense bogus. */
51 /* MAX(a,b) returns the maximum of A and B. */
52 #ifndef MAX
53 # define MAX(a,b) ((a) > (b) ? (a) : (b))
54 #endif
56 /* MIN(a,b) returns the minimum of A and B. */
57 #ifndef MIN
58 # define MIN(a,b) ((a) < (b) ? (a) : (b))
59 #endif
61 #endif /* _MINMAX_H */