4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1988 AT&T */
23 /* All Rights Reserved */
27 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
29 * Copyright (c) 1996, by Sun Microsystems, Inc.
37 * Handling of Not_a_Number's (only in IEEE floating-point standard)
40 #include <sys/isa_defs.h>
47 #if defined(_IEEE_754)
49 * Structure order is endian dependent. Only the common variants of
50 * big and little endian are supported.
53 #if defined(_BIG_ENDIAN)
60 unsigned exponent
:11;
62 unsigned fraction_low
:32;
67 unsigned exponent
:11;
68 unsigned qnan_bit
: 1;
70 unsigned fraction_low
:32;
76 #else /* Must be _LITTLE_ENDIAN */
81 unsigned fraction_low
:32;
83 unsigned exponent
:11;
87 unsigned fraction_low
:32;
89 unsigned qnan_bit
: 1;
90 unsigned exponent
:11;
96 #endif /* Endian based selection */
99 * IsNANorINF checks that exponent of double == 2047
100 * i.e. that number is a NaN or an infinity
102 #define IsNANorINF(X) (((dnan *)&(X))->nan_parts.exponent == 0x7ff)
105 * IsINF must be used after IsNANorINF has checked the exponent
107 #define IsINF(X) (((dnan *)&(X))->inf_parts.bits == 0 && \
108 ((dnan *)&(X))->inf_parts.fraction_low == 0)
111 * IsPosNAN and IsNegNAN can be used to check the sign of infinities too
113 #define IsPosNAN(X) (((dnan *)&(X))->nan_parts.sign == 0)
115 #define IsNegNAN(X) (((dnan *)&(X))->nan_parts.sign == 1)
118 * GETNaNPC gets the leftmost 32 bits of the fraction part
120 #define GETNaNPC(dval) (((dnan *)&(dval))->inf_parts.bits << 12 | \
121 ((dnan *)&(dval))->nan_parts.fraction_low >> 20)
123 #define KILLFPE() (void) _kill(_getpid(), 8)
124 #define NaN(X) (((dnan *)&(X))->nan_parts.exponent == 0x7ff)
125 #define KILLNaN(X) if (NaN(X)) KILLFPE()
127 #else /* defined(_IEEE_754) */
128 /* #error is strictly ansi-C, but works as well as anything for K&R systems. */
129 #error ISA not supported
130 #endif /* defined(_IEEE_754) */