Blame src/gl/minmax.h

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