summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/msun/Makefile2
-rw-r--r--lib/msun/src/s_isnan.c79
-rw-r--r--lib/msun/src/s_isnanf.c39
3 files changed, 53 insertions, 67 deletions
diff --git a/lib/msun/Makefile b/lib/msun/Makefile
index 092a70f..73d7475 100644
--- a/lib/msun/Makefile
+++ b/lib/msun/Makefile
@@ -84,7 +84,7 @@ COMMON_SRCS= b_exp.c b_log.c b_tgamma.c \
s_expm1.c s_expm1f.c s_fabsf.c s_fdim.c s_finite.c s_finitef.c \
s_floor.c s_floorf.c s_fmax.c s_fmaxf.c s_fmaxl.c s_fmin.c \
s_fminf.c s_fminl.c s_frexp.c s_frexpf.c s_ilogb.c s_ilogbf.c \
- s_isfinite.c s_isnanf.c s_isnormal.c s_ldexpf.c \
+ s_isfinite.c s_isnan.c s_isnormal.c s_ldexpf.c \
s_lib_version.c s_log1p.c \
s_log1pf.c s_logb.c s_logbf.c s_matherr.c s_modff.c \
s_nearbyint.c s_nextafter.c s_nextafterf.c \
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);
-}
OpenPOWER on IntegriCloud