2013-02-19 11:20:43 +00:00
|
|
|
/* `NAN' constant for IEEE 754 machines. MIPS version.
|
2013-01-02 19:01:50 +00:00
|
|
|
Copyright (C) 1992-2013 Free Software Foundation, Inc.
|
2002-03-22 10:10:19 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2013-02-19 11:20:43 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
2012-03-09 23:56:38 +00:00
|
|
|
<http://www.gnu.org/licenses/>. */
|
2002-03-22 10:10:19 +00:00
|
|
|
|
|
|
|
#ifndef _MATH_H
|
|
|
|
# error "Never use <bits/nan.h> directly; include <math.h> instead."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2013-02-19 11:20:43 +00:00
|
|
|
/* IEEE Not A Number. */
|
|
|
|
/* Note that MIPS has the QNaN and SNaN patterns reversed compared to most
|
|
|
|
other architectures. The IEEE spec left the definition of this open to
|
|
|
|
implementations, and for MIPS the top bit of the mantissa must be SET to
|
|
|
|
indicate a SNaN. */
|
2002-03-22 10:10:19 +00:00
|
|
|
|
* math/Makefile (headers): Add bits/huge_valf.h, bits/huge_vall.h,
and bits/inf.h.
* math/math.h: Include them.
* sysdeps/alpha/fpu/bits/mathdef.h, sysdeps/arm/fpu/bits/mathdef.h,
sysdeps/generic/bits/mathdef.h, sysdeps/i386/fpu/bits/mathdef.h,
sysdeps/ia64/fpu/bits/mathdef.h, sysdeps/m68k/fpu/bits/mathdef.h,
sysdeps/mips/fpu/bits/mathdef.h, sysdeps/powerpc/fpu/bits/mathdef.h,
sysdeps/sh/sh4/fpu/bits/mathdef.h, sysdeps/sparc/fpu/bits/mathdef.h,
sysdeps/x86_64/fpu/bits/mathdef.h: Remove INFINITY.
* sysdeps/arm/bits/huge_val.h (HUGE_VAL): Use __builtin_huge_val.
(HUGE_VALF, HUGE_VALL): Remove.
* sysdeps/ieee754/bits/huge_val.h: Likewise.
* sysdeps/sh/bits/huge_val.h: Likewise.
* sysdeps/generic/bits/huge_val.h (HUGE_VAL): Use __builtin_huge_val.
* sysdeps/generic/bits/huge_valf.h: New file.
* sysdeps/generic/bits/huge_vall.h: New file.
* sysdeps/generic/bits/inf.h: New file.
* sysdeps/ieee754/bits/huge_valf.h: New file.
* sysdeps/ieee754/bits/inf.h: New file.
* sysdeps/i386/bits/huge_val.h: Remove file.
* sysdeps/i386/bits/huge_vall.h: New file.
* sysdeps/ia64/bits/huge_val.h: Remove file.
* sysdeps/ia64/bits/huge_vall.h: New file.
* sysdeps/ieee754/ldbl-128/bits/huge_vall.h: New file.
* sysdeps/m68k/bits/huge_val.h: Remove file.
* sysdeps/m68k/bits/huge_vall.h: New file.
* sysdeps/s390/bits/huge_val.h: Remove file.
* sysdeps/sh/sh4/fpu/bits/huge_val.h: Remove file.
* sysdeps/sparc/bits/huge_vall.h: New file.
* sysdeps/sparc/sparc32/fpu/bits/huge_val.h: Remove file.
* sysdeps/sparc/sparc64/fpu/bits/huge_val.h: Remove file.
* sysdeps/ieee754/bits/nan.h (NAN): Use __builtin_nanf.
* sysdeps/mips/bits/nan.h (NAN): Likewise.
2004-03-15 21:44:10 +00:00
|
|
|
#if __GNUC_PREREQ(3,3)
|
|
|
|
|
2013-02-19 11:20:43 +00:00
|
|
|
# define NAN (__builtin_nanf (""))
|
* math/Makefile (headers): Add bits/huge_valf.h, bits/huge_vall.h,
and bits/inf.h.
* math/math.h: Include them.
* sysdeps/alpha/fpu/bits/mathdef.h, sysdeps/arm/fpu/bits/mathdef.h,
sysdeps/generic/bits/mathdef.h, sysdeps/i386/fpu/bits/mathdef.h,
sysdeps/ia64/fpu/bits/mathdef.h, sysdeps/m68k/fpu/bits/mathdef.h,
sysdeps/mips/fpu/bits/mathdef.h, sysdeps/powerpc/fpu/bits/mathdef.h,
sysdeps/sh/sh4/fpu/bits/mathdef.h, sysdeps/sparc/fpu/bits/mathdef.h,
sysdeps/x86_64/fpu/bits/mathdef.h: Remove INFINITY.
* sysdeps/arm/bits/huge_val.h (HUGE_VAL): Use __builtin_huge_val.
(HUGE_VALF, HUGE_VALL): Remove.
* sysdeps/ieee754/bits/huge_val.h: Likewise.
* sysdeps/sh/bits/huge_val.h: Likewise.
* sysdeps/generic/bits/huge_val.h (HUGE_VAL): Use __builtin_huge_val.
* sysdeps/generic/bits/huge_valf.h: New file.
* sysdeps/generic/bits/huge_vall.h: New file.
* sysdeps/generic/bits/inf.h: New file.
* sysdeps/ieee754/bits/huge_valf.h: New file.
* sysdeps/ieee754/bits/inf.h: New file.
* sysdeps/i386/bits/huge_val.h: Remove file.
* sysdeps/i386/bits/huge_vall.h: New file.
* sysdeps/ia64/bits/huge_val.h: Remove file.
* sysdeps/ia64/bits/huge_vall.h: New file.
* sysdeps/ieee754/ldbl-128/bits/huge_vall.h: New file.
* sysdeps/m68k/bits/huge_val.h: Remove file.
* sysdeps/m68k/bits/huge_vall.h: New file.
* sysdeps/s390/bits/huge_val.h: Remove file.
* sysdeps/sh/sh4/fpu/bits/huge_val.h: Remove file.
* sysdeps/sparc/bits/huge_vall.h: New file.
* sysdeps/sparc/sparc32/fpu/bits/huge_val.h: Remove file.
* sysdeps/sparc/sparc64/fpu/bits/huge_val.h: Remove file.
* sysdeps/ieee754/bits/nan.h (NAN): Use __builtin_nanf.
* sysdeps/mips/bits/nan.h (NAN): Likewise.
2004-03-15 21:44:10 +00:00
|
|
|
|
|
|
|
#elif defined __GNUC__
|
2002-03-22 10:10:19 +00:00
|
|
|
|
|
|
|
# define NAN \
|
2013-02-19 11:20:43 +00:00
|
|
|
(__extension__ \
|
|
|
|
((union { unsigned __l __attribute__ ((__mode__ (__SI__))); float __d; }) \
|
2002-03-22 10:10:19 +00:00
|
|
|
{ __l: 0x7fbfffffUL }).__d)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
# include <endian.h>
|
|
|
|
|
|
|
|
# if __BYTE_ORDER == __BIG_ENDIAN
|
|
|
|
# define __nan_bytes { 0x7f, 0xbf, 0xff, 0xff }
|
|
|
|
# endif
|
|
|
|
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
|
|
# define __nan_bytes { 0xff, 0xff, 0xbf, 0x7f }
|
|
|
|
# endif
|
|
|
|
|
2013-02-19 11:49:12 +00:00
|
|
|
static union { unsigned char __c[4]; float __d; } __nan_union
|
2013-02-20 17:51:56 +00:00
|
|
|
__attribute__ ((__unused__)) = { __nan_bytes };
|
2002-03-22 10:10:19 +00:00
|
|
|
# define NAN (__nan_union.__d)
|
|
|
|
|
|
|
|
#endif /* GCC. */
|