2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A/* Copyright (c) 1988 AT&T */
2N/A/* All Rights Reserved */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A/* IEEE recommended functions */
2N/A
2N/A#pragma weak _finite = finite
2N/A#pragma weak _fpclass = fpclass
2N/A#pragma weak _unordered = unordered
2N/A
2N/A#include "lint.h"
2N/A#include <values.h>
2N/A#include "fpparts.h"
2N/A
2N/A#define P754_NOFAULT 1 /* avoid generating extra code */
2N/A#include <ieeefp.h>
2N/A
2N/A/*
2N/A * FINITE(X)
2N/A * finite(x) returns 1 if x > -inf and x < +inf and 0 otherwise
2N/A * NaN returns 0
2N/A */
2N/A
2N/Aint
2N/Afinite(double x)
2N/A{
2N/A return ((EXPONENT(x) != MAXEXP));
2N/A}
2N/A
2N/A/*
2N/A * UNORDERED(x,y)
2N/A * unordered(x,y) returns 1 if x is unordered with y, otherwise
2N/A * it returns 0; x is unordered with y if either x or y is NAN
2N/A */
2N/A
2N/Aint
2N/Aunordered(double x, double y)
2N/A{
2N/A if ((EXPONENT(x) == MAXEXP) && (HIFRACTION(x) || LOFRACTION(x)))
2N/A return (1);
2N/A if ((EXPONENT(y) == MAXEXP) && (HIFRACTION(y) || LOFRACTION(y)))
2N/A return (1);
2N/A return (0);
2N/A}
2N/A
2N/A/*
2N/A * FPCLASS(X)
2N/A * fpclass(x) returns the floating point class x belongs to
2N/A */
2N/A
2N/Afpclass_t
2N/Afpclass(double x)
2N/A{
2N/A int sign, exp;
2N/A
2N/A exp = EXPONENT(x);
2N/A sign = SIGNBIT(x);
2N/A if (exp == 0) { /* de-normal or zero */
2N/A if (HIFRACTION(x) || LOFRACTION(x)) /* de-normal */
2N/A return (sign ? FP_NDENORM : FP_PDENORM);
2N/A else
2N/A return (sign ? FP_NZERO : FP_PZERO);
2N/A }
2N/A if (exp == MAXEXP) { /* infinity or NaN */
2N/A if ((HIFRACTION(x) == 0) && (LOFRACTION(x) == 0)) /* infinity */
2N/A return (sign ? FP_NINF : FP_PINF);
2N/A else
2N/A if (QNANBIT(x))
2N/A /* hi-bit of mantissa set - quiet nan */
2N/A return (FP_QNAN);
2N/A else return (FP_SNAN);
2N/A }
2N/A /* if we reach here we have non-zero normalized number */
2N/A return (sign ? FP_NNORM : FP_PNORM);
2N/A}