Blame gnulib-tests/nan.h

Packit 9e4112
/* Macros for not-a-number.
Packit 9e4112
   Copyright (C) 2007-2018 Free Software Foundation, Inc.
Packit 9e4112
Packit 9e4112
   This program is free software: you can redistribute it and/or modify
Packit 9e4112
   it under the terms of the GNU General Public License as published by
Packit 9e4112
   the Free Software Foundation; either version 3 of the License, or
Packit 9e4112
   (at your option) any later version.
Packit 9e4112
Packit 9e4112
   This program is distributed in the hope that it will be useful,
Packit 9e4112
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 9e4112
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 9e4112
   GNU General Public License for more details.
Packit 9e4112
Packit 9e4112
   You should have received a copy of the GNU General Public License
Packit 9e4112
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit 9e4112
Packit 9e4112
Packit 9e4112
/* IBM z/OS supports both hexadecimal and IEEE floating-point formats. The
Packit 9e4112
   former does not support NaN and its isnan() implementation returns zero
Packit 9e4112
   for all values.  */
Packit 9e4112
#if defined __MVS__ && defined __IBMC__ && !defined __BFP__
Packit 9e4112
# error "NaN is not supported with IBM's hexadecimal floating-point format; please re-compile with -qfloat=ieee"
Packit 9e4112
#endif
Packit 9e4112
Packit 9e4112
/* NaNf () returns a 'float' not-a-number.  */
Packit 9e4112
Packit 9e4112
/* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke
Packit 9e4112
   on the expression 0.0 / 0.0.  The IBM XL C compiler on z/OS complains.
Packit 9e4112
   PGI 16.10 complains.  */
Packit 9e4112
#if (defined __DECC || defined _MSC_VER \
Packit 9e4112
     || (defined __MVS__ && defined __IBMC__)   \
Packit 9e4112
     || defined __PGI)
Packit 9e4112
static float
Packit 9e4112
NaNf ()
Packit 9e4112
{
Packit 9e4112
  static float zero = 0.0f;
Packit 9e4112
  return zero / zero;
Packit 9e4112
}
Packit 9e4112
#else
Packit 9e4112
# define NaNf() (0.0f / 0.0f)
Packit 9e4112
#endif
Packit 9e4112
Packit 9e4112
Packit 9e4112
/* NaNd () returns a 'double' not-a-number.  */
Packit 9e4112
Packit 9e4112
/* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke
Packit 9e4112
   on the expression 0.0 / 0.0.  The IBM XL C compiler on z/OS complains.
Packit 9e4112
   PGI 16.10 complains.  */
Packit 9e4112
#if (defined __DECC || defined _MSC_VER \
Packit 9e4112
     || (defined __MVS__ && defined __IBMC__)   \
Packit 9e4112
     || defined __PGI)
Packit 9e4112
static double
Packit 9e4112
NaNd ()
Packit 9e4112
{
Packit 9e4112
  static double zero = 0.0;
Packit 9e4112
  return zero / zero;
Packit 9e4112
}
Packit 9e4112
#else
Packit 9e4112
# define NaNd() (0.0 / 0.0)
Packit 9e4112
#endif
Packit 9e4112
Packit 9e4112
Packit 9e4112
/* NaNl () returns a 'long double' not-a-number.  */
Packit 9e4112
Packit 9e4112
/* On Irix 6.5, gcc 3.4.3 can't compute compile-time NaN, and needs the
Packit 9e4112
   runtime type conversion.
Packit 9e4112
   The Microsoft MSVC 9 compiler chokes on the expression 0.0L / 0.0L.
Packit 9e4112
   The IBM XL C compiler on z/OS complains.
Packit 9e4112
   PGI 16.10 complains.  */
Packit 9e4112
#ifdef __sgi
Packit 9e4112
static long double NaNl ()
Packit 9e4112
{
Packit 9e4112
  double zero = 0.0;
Packit 9e4112
  return zero / zero;
Packit 9e4112
}
Packit 9e4112
#elif defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI
Packit 9e4112
static long double
Packit 9e4112
NaNl ()
Packit 9e4112
{
Packit 9e4112
  static long double zero = 0.0L;
Packit 9e4112
  return zero / zero;
Packit 9e4112
}
Packit 9e4112
#else
Packit 9e4112
# define NaNl() (0.0L / 0.0L)
Packit 9e4112
#endif