Blame lib/minmax.h

Packit 33f14e
/* MIN, MAX macros.
Packit 33f14e
   Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2017 Free Software
Packit 33f14e
   Foundation, Inc.
Packit 33f14e
Packit 33f14e
   This program is free software; you can redistribute it and/or modify
Packit 33f14e
   it under the terms of the GNU General Public License as published by
Packit 33f14e
   the Free Software Foundation; either version 3, or (at your option)
Packit 33f14e
   any later version.
Packit 33f14e
Packit 33f14e
   This program is distributed in the hope that it will be useful,
Packit 33f14e
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 33f14e
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 33f14e
   GNU General Public License for more details.
Packit 33f14e
Packit 33f14e
   You should have received a copy of the GNU General Public License
Packit 33f14e
   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
Packit 33f14e
Packit 33f14e
#ifndef _MINMAX_H
Packit 33f14e
#define _MINMAX_H
Packit 33f14e
Packit 33f14e
/* Note: MIN, MAX are also defined in <sys/param.h> on some systems
Packit 33f14e
   (glibc, IRIX, HP-UX, OSF/1).  Therefore you might get warnings about
Packit 33f14e
   MIN, MAX macro redefinitions on some systems; the workaround is to
Packit 33f14e
   #include this file as the last one among the #include list.  */
Packit 33f14e
Packit 33f14e
/* Before we define the following symbols we get the <limits.h> file
Packit 33f14e
   since otherwise we get redefinitions on some systems if <limits.h> is
Packit 33f14e
   included after this file.  Likewise for <sys/param.h>.
Packit 33f14e
   If more than one of these system headers define MIN and MAX, pick just
Packit 33f14e
   one of the headers (because the definitions most likely are the same).  */
Packit 33f14e
#if HAVE_MINMAX_IN_LIMITS_H
Packit 33f14e
# include <limits.h>
Packit 33f14e
#elif HAVE_MINMAX_IN_SYS_PARAM_H
Packit 33f14e
# include <sys/param.h>
Packit 33f14e
#endif
Packit 33f14e
Packit 33f14e
/* Note: MIN and MAX should be used with two arguments of the
Packit 33f14e
   same type.  They might not return the minimum and maximum of their two
Packit 33f14e
   arguments, if the arguments have different types or have unusual
Packit 33f14e
   floating-point values.  For example, on a typical host with 32-bit 'int',
Packit 33f14e
   64-bit 'long long', and 64-bit IEEE 754 'double' types:
Packit 33f14e
Packit 33f14e
     MAX (-1, 2147483648) returns 4294967295.
Packit 33f14e
     MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0.
Packit 33f14e
     MAX (NaN, 0.0) returns 0.0.
Packit 33f14e
     MAX (+0.0, -0.0) returns -0.0.
Packit 33f14e
Packit 33f14e
   and in each case the answer is in some sense bogus.  */
Packit 33f14e
Packit 33f14e
/* MAX(a,b) returns the maximum of A and B.  */
Packit 33f14e
#ifndef MAX
Packit 33f14e
# define MAX(a,b) ((a) > (b) ? (a) : (b))
Packit 33f14e
#endif
Packit 33f14e
Packit 33f14e
/* MIN(a,b) returns the minimum of A and B.  */
Packit 33f14e
#ifndef MIN
Packit 33f14e
# define MIN(a,b) ((a) < (b) ? (a) : (b))
Packit 33f14e
#endif
Packit 33f14e
Packit 33f14e
#endif /* _MINMAX_H */