Blame src/gl/minmax.h

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