Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc C99 7.12.3.1: add IEEE library portions of fpclassi...



details:   https://anonhg.NetBSD.org/src/rev/b4af7b1ed4e2
branches:  trunk
changeset: 554485:b4af7b1ed4e2
user:      kleink <kleink%NetBSD.org@localhost>
date:      Tue Oct 28 22:05:37 2003 +0000

description:
C99 7.12.3.1: add IEEE library portions of fpclassify.  Don't build these
yet as the VAX implementation is still subject to discussion.

diffstat:

 lib/libc/arch/hppa/gen/fpclassifyl.c    |  73 ++++++++++++++++++++++++++++++++
 lib/libc/arch/i386/gen/fpclassifyl.c    |  74 +++++++++++++++++++++++++++++++++
 lib/libc/arch/m68k/gen/fpclassifyl.c    |  74 +++++++++++++++++++++++++++++++++
 lib/libc/arch/sparc64/gen/fpclassifyl.c |  73 ++++++++++++++++++++++++++++++++
 lib/libc/arch/x86_64/gen/fpclassifyl.c  |  74 +++++++++++++++++++++++++++++++++
 lib/libc/gen/fpclassify_ieee754.c       |  71 +++++++++++++++++++++++++++++++
 lib/libc/gen/fpclassifyf_ieee754.c      |  71 +++++++++++++++++++++++++++++++
 7 files changed, 510 insertions(+), 0 deletions(-)

diffs (truncated from 538 to 300 lines):

diff -r 3b5b9fbc6406 -r b4af7b1ed4e2 lib/libc/arch/hppa/gen/fpclassifyl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/hppa/gen/fpclassifyl.c      Tue Oct 28 22:05:37 2003 +0000
@@ -0,0 +1,73 @@
+/*     $NetBSD: fpclassifyl.c,v 1.1 2003/10/28 22:05:37 kleink Exp $   */
+
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: fpclassifyl.c,v 1.1 2003/10/28 22:05:37 kleink Exp $");
+#endif
+
+#include <machine/ieee.h>
+#include <math.h>
+
+/*
+ * 7.12.3.1 fpclassify - classify real floating type
+ *          IEEE 754 compatible 128-bit extended-precision version
+ */
+int
+__fpclassifyl(long double x)
+{
+       union ieee_ext_u u;
+
+       u.extu_ld = x;
+
+       if (u.extu_ext.ext_exp == 0) {
+               if (u.extu_ext.ext_frach  == 0 && u.extu_ext.ext_frachm == 0 &&
+                   u.extu_ext.ext_fraclm == 0 && u.extu_ext.ext_fracl  == 0)
+                       return FP_ZERO;
+               else
+                       return FP_SUBNORMAL;
+       } else if (u.extu_ext.ext_exp == EXT_EXP_INFNAN) {
+               if (u.extu_ext.ext_frach  == 0 && u.extu_ext.ext_frachm == 0 &&
+                   u.extu_ext.ext_fraclm == 0 && u.extu_ext.ext_fracl  == 0)
+                       return FP_INFINITE;
+               else
+                       return FP_NAN;
+       }
+
+       return FP_NORMAL;
+}
diff -r 3b5b9fbc6406 -r b4af7b1ed4e2 lib/libc/arch/i386/gen/fpclassifyl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/i386/gen/fpclassifyl.c      Tue Oct 28 22:05:37 2003 +0000
@@ -0,0 +1,74 @@
+/*     $NetBSD: fpclassifyl.c,v 1.1 2003/10/28 22:05:37 kleink Exp $   */
+
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: fpclassifyl.c,v 1.1 2003/10/28 22:05:37 kleink Exp $");
+#endif
+
+#include <machine/ieee.h>
+#include <assert.h>
+#include <math.h>
+
+/*
+ * 7.12.3.1 fpclassify - classify real floating type
+ *          IEEE 754 compatible 80-bit extended-precision Intel 386 version
+ */
+int
+__fpclassifyl(long double x)
+{
+       union ieee_ext_u u;
+
+       u.extu_ld = x;
+
+       _DIAGASSERT(u.extu_ext.ext_exp == 0 || u.extu_ext.ext_int == 1);
+
+       if (u.extu_ext.ext_exp == 0) {
+               if (u.extu_ext.ext_frach == 0 && u.extu_ext.ext_fracl == 0)
+                       return FP_ZERO;
+               else
+                       return FP_SUBNORMAL;
+       } else if (u.extu_ext.ext_exp == EXT_EXP_INFNAN) {
+               if (u.extu_ext.ext_frach == 0 && u.extu_ext.ext_fracl == 0)
+                       return FP_INFINITE;
+               else
+                       return FP_NAN;
+       }
+
+       return FP_NORMAL;
+}
diff -r 3b5b9fbc6406 -r b4af7b1ed4e2 lib/libc/arch/m68k/gen/fpclassifyl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/m68k/gen/fpclassifyl.c      Tue Oct 28 22:05:37 2003 +0000
@@ -0,0 +1,74 @@
+/*     $NetBSD: fpclassifyl.c,v 1.1 2003/10/28 22:05:37 kleink Exp $   */
+
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: fpclassifyl.c,v 1.1 2003/10/28 22:05:37 kleink Exp $");
+#endif
+
+#include <machine/ieee.h>
+#include <assert.h>
+#include <math.h>
+
+/*
+ * 7.12.3.1 fpclassify - classify real floating type
+ *          IEEE 754 compatible 80-bit extended-precision Motorola 68k version
+ */
+int
+__fpclassifyl(long double x)
+{
+       union ieee_ext_u u;
+
+       u.extu_ld = x;
+
+       _DIAGASSERT(u.extu_ext.ext_zero == 0);
+
+       if (u.extu_ext.ext_exp == 0 && u.extu_ext.ext_int == 0) {
+               if (u.extu_ext.ext_frach == 0 && u.extu_ext.ext_fracl == 0)
+                       return FP_ZERO;
+               else
+                       return FP_SUBNORMAL;
+       } else if (u.extu_ext.ext_exp == EXT_EXP_INFNAN) {
+               if (u.extu_ext.ext_frach == 0 && u.extu_ext.ext_fracl == 0)
+                       return FP_INFINITE;
+               else
+                       return FP_NAN;
+       }
+
+       return FP_NORMAL;
+}
diff -r 3b5b9fbc6406 -r b4af7b1ed4e2 lib/libc/arch/sparc64/gen/fpclassifyl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/sparc64/gen/fpclassifyl.c   Tue Oct 28 22:05:37 2003 +0000
@@ -0,0 +1,73 @@
+/*     $NetBSD: fpclassifyl.c,v 1.1 2003/10/28 22:05:37 kleink Exp $   */
+
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: fpclassifyl.c,v 1.1 2003/10/28 22:05:37 kleink Exp $");
+#endif
+
+#include <machine/ieee.h>
+#include <math.h>
+
+/*
+ * 7.12.3.1 fpclassify - classify real floating type
+ *          IEEE 754 compatible 128-bit extended-precision version
+ */
+int
+__fpclassifyl(long double x)
+{
+       union ieee_ext_u u;
+
+       u.extu_ld = x;
+
+       if (u.extu_ext.ext_exp == 0) {
+               if (u.extu_ext.ext_frach  == 0 && u.extu_ext.ext_frachm == 0 &&
+                   u.extu_ext.ext_fraclm == 0 && u.extu_ext.ext_fracl  == 0)
+                       return FP_ZERO;
+               else
+                       return FP_SUBNORMAL;



Home | Main Index | Thread Index | Old Index