diff options
author | das <das@FreeBSD.org> | 2004-08-05 01:46:11 +0000 |
---|---|---|
committer | das <das@FreeBSD.org> | 2004-08-05 01:46:11 +0000 |
commit | e4fbd5d17285aa77573a1d717ddf675761c44511 (patch) | |
tree | c24cbe82179d12b52376808137dcf7fbffc4cb65 /lib/msun/src | |
parent | 73fe96f0a7ad5f492ecc11937cd91884c841d6dd (diff) | |
download | FreeBSD-src-e4fbd5d17285aa77573a1d717ddf675761c44511.zip FreeBSD-src-e4fbd5d17285aa77573a1d717ddf675761c44511.tar.gz |
Replace s_isnan.c and s_isnanf.c with the more compact s_isnan.c from
libc. The externally-visible effect of this is to add __isnanl() to
libm, which means that libm.so.2 can once again link against libc.so.4
when LD_BIND_NOW is set. This was broken by the addition of fdiml(),
which calls __isnanl().
Diffstat (limited to 'lib/msun/src')
-rw-r--r-- | lib/msun/src/s_isnan.c | 79 | ||||
-rw-r--r-- | lib/msun/src/s_isnanf.c | 39 |
2 files changed, 52 insertions, 66 deletions
diff --git a/lib/msun/src/s_isnan.c b/lib/msun/src/s_isnan.c index bd1f6c9..5de99ad 100644 --- a/lib/msun/src/s_isnan.c +++ b/lib/msun/src/s_isnan.c @@ -1,37 +1,62 @@ -/* @(#)s_isnan.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +/*- + * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG> + * All rights reserved. * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ */ -/* For binary compat; to be removed in FreeBSD 6.0. */ +#include <math.h> -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif +#include "fpmath.h" -/* - * isnan(x) returns 1 is x is nan, else 0; - * no branching! - */ +/* Provided by libc */ +#if 0 +int +isnan(double d) +{ + union IEEEd2bits u; -#include "math.h" -#include "math_private.h" + u.d = d; + return (u.bits.exp == 2047 && (u.bits.manl != 0 || u.bits.manh != 0)); +} +#endif -#undef isnan +int +isnanf(float f) +{ + union IEEEf2bits u; - int isnan(double x) + u.f = f; + return (u.bits.exp == 255 && u.bits.man != 0); +} + +int +__isnanl(long double e) { - int32_t hx,lx; - EXTRACT_WORDS(hx,lx,x); - hx &= 0x7fffffff; - hx |= (u_int32_t)(lx|(-lx))>>31; - hx = 0x7ff00000 - hx; - return (int)((u_int32_t)(hx))>>31; + union IEEEl2bits u; + + u.e = e; + mask_nbit_l(u); + return (u.bits.exp == 32767 && (u.bits.manl != 0 || u.bits.manh != 0)); } diff --git a/lib/msun/src/s_isnanf.c b/lib/msun/src/s_isnanf.c deleted file mode 100644 index 4e6e7b2..0000000 --- a/lib/msun/src/s_isnanf.c +++ /dev/null @@ -1,39 +0,0 @@ -/* s_isnanf.c -- float version of s_isnan.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* For binary compat; to be removed in FreeBSD 6.0. */ - -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif - -/* - * isnanf(x) returns 1 is x is nan, else 0; - * no branching! - */ - -#include "math.h" -#include "math_private.h" - -#undef isnanf - - int isnanf(float x) -{ - int32_t ix; - GET_FLOAT_WORD(ix,x); - ix &= 0x7fffffff; - ix = 0x7f800000 - ix; - return (int)(((u_int32_t)(ix))>>31); -} |