Source-Changes-HG archive

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

[src/trunk]: src Add support for fenv.h interface for i386 and amd64.



details:   https://anonhg.NetBSD.org/src/rev/5aee6b6471ad
branches:  trunk
changeset: 756766:5aee6b6471ad
user:      joerg <joerg%NetBSD.org@localhost>
date:      Sat Jul 31 21:47:52 2010 +0000

description:
Add support for fenv.h interface for i386 and amd64.

Submitted by Stathis Kamperis as part of GSoC 2010 and ported from
FreeBSD.

diffstat:

 distrib/sets/lists/comp/md.amd64 |    4 +-
 distrib/sets/lists/comp/md.i386  |    3 +-
 distrib/sets/lists/comp/mi       |   48 +++-
 include/Makefile                 |    4 +-
 include/fenv.h                   |   62 ++++
 lib/libm/Makefile                |   24 +-
 lib/libm/arch/i387/fenv.c        |  516 ++++++++++++++++++++++++++++++++++++++
 lib/libm/arch/x86_64/fenv.c      |  524 +++++++++++++++++++++++++++++++++++++++
 lib/libm/man/feclearexcept.3     |  140 ++++++++++
 lib/libm/man/feenableexcept.3    |   97 +++++++
 lib/libm/man/fegetenv.3          |  114 ++++++++
 lib/libm/man/fegetround.3        |   84 ++++++
 lib/libm/man/fenv.3              |  283 +++++++++++++++++++++
 sys/arch/amd64/include/Makefile  |    4 +-
 sys/arch/amd64/include/fenv.h    |  107 +++++++
 sys/arch/i386/include/Makefile   |    4 +-
 sys/arch/i386/include/fenv.h     |  116 ++++++++
 sys/arch/i386/include/npx.h      |   34 +-
 sys/arch/x86/include/ieeefp.h    |   28 +-
 19 files changed, 2142 insertions(+), 54 deletions(-)

diffs (truncated from 2438 to 300 lines):

diff -r b98912c67ea3 -r 5aee6b6471ad distrib/sets/lists/comp/md.amd64
--- a/distrib/sets/lists/comp/md.amd64  Sat Jul 31 21:21:17 2010 +0000
+++ b/distrib/sets/lists/comp/md.amd64  Sat Jul 31 21:47:52 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: md.amd64,v 1.71 2010/07/11 06:16:55 mrg Exp $
+# $NetBSD: md.amd64,v 1.72 2010/07/31 21:47:52 joerg Exp $
 ./usr/include/amd64                            comp-c-include
 ./usr/include/amd64/ansi.h                     comp-c-include
 ./usr/include/amd64/aout_machdep.h             comp-c-include
@@ -16,6 +16,7 @@
 ./usr/include/amd64/elf_machdep.h              comp-c-include
 ./usr/include/amd64/endian.h                   comp-c-include
 ./usr/include/amd64/endian_machdep.h           comp-c-include
+./usr/include/amd64/fenv.h                     comp-c-include
 ./usr/include/amd64/float.h                    comp-c-include
 ./usr/include/amd64/fpu.h                      comp-c-include
 ./usr/include/amd64/frame.h                    comp-c-include
@@ -85,6 +86,7 @@
 ./usr/include/i386/elf_machdep.h               comp-c-include
 ./usr/include/i386/endian.h                    comp-c-include
 ./usr/include/i386/endian_machdep.h            comp-c-include
+./usr/include/i386/fenv.h                      comp-c-include
 ./usr/include/i386/float.h                     comp-c-include
 ./usr/include/i386/frame.h                     comp-c-include
 ./usr/include/i386/freebsd_machdep.h           comp-c-include
diff -r b98912c67ea3 -r 5aee6b6471ad distrib/sets/lists/comp/md.i386
--- a/distrib/sets/lists/comp/md.i386   Sat Jul 31 21:21:17 2010 +0000
+++ b/distrib/sets/lists/comp/md.i386   Sat Jul 31 21:47:52 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: md.i386,v 1.113 2010/07/07 00:10:14 njoly Exp $
+# $NetBSD: md.i386,v 1.114 2010/07/31 21:47:52 joerg Exp $
 ./usr/include/emmintrin.h                      comp-c-include          gcccmds
 ./usr/include/i386                             comp-c-include
 ./usr/include/i386/_G_config.h                 comp-obsolete           obsolete
@@ -23,6 +23,7 @@
 ./usr/include/i386/elf_machdep.h               comp-c-include
 ./usr/include/i386/endian.h                    comp-c-include
 ./usr/include/i386/endian_machdep.h            comp-c-include
+./usr/include/i386/fenv.h                      comp-c-include
 ./usr/include/i386/float.h                     comp-c-include
 ./usr/include/i386/frame.h                     comp-c-include
 ./usr/include/i386/freebsd_machdep.h           comp-c-include
diff -r b98912c67ea3 -r 5aee6b6471ad distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi        Sat Jul 31 21:21:17 2010 +0000
+++ b/distrib/sets/lists/comp/mi        Sat Jul 31 21:47:52 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: mi,v 1.1488 2010/07/31 03:14:06 pgoyette Exp $
+#      $NetBSD: mi,v 1.1489 2010/07/31 21:47:52 joerg Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -632,6 +632,7 @@
 ./usr/include/evrpc.h                          comp-c-include
 ./usr/include/evutil.h                         comp-c-include
 ./usr/include/fcntl.h                          comp-c-include
+./usr/include/fenv.h                           comp-c-include
 ./usr/include/fetch.h                          comp-c-include
 ./usr/include/filecorefs/filecore_mount.h      comp-c-include
 ./usr/include/float.h                          comp-c-include
@@ -5783,9 +5784,24 @@
 ./usr/share/man/cat3/fdiml.0                   comp-c-catman           .cat
 ./usr/share/man/cat3/fdopen.0                  comp-c-catman           .cat
 ./usr/share/man/cat3/fdopendir.0               comp-c-catman           .cat
+./usr/share/man/cat3/feclearexcept.0           comp-c-catman           .cat
+./usr/share/man/cat3/fedisableexcept.0         comp-c-catman           .cat
+./usr/share/man/cat3/feenableexcept.0          comp-c-catman           .cat
+./usr/share/man/cat3/fegetenv.0                        comp-c-catman           .cat
+./usr/share/man/cat3/fegetexcept.0             comp-c-catman           .cat
+./usr/share/man/cat3/fegetexceptflag.0         comp-c-catman           .cat
+./usr/share/man/cat3/fegetround.0              comp-c-catman           .cat
+./usr/share/man/cat3/feholdexcept.0            comp-c-catman           .cat
+./usr/share/man/cat3/fenv.0                    comp-c-catman           .cat
 ./usr/share/man/cat3/feof.0                    comp-c-catman           .cat
+./usr/share/man/cat3/feraiseexcept.0           comp-c-catman           .cat
 ./usr/share/man/cat3/ferror.0                  comp-c-catman           .cat
+./usr/share/man/cat3/feseteexcpetflag.0                comp-c-catman           .cat
+./usr/share/man/cat3/fesetenv.0                        comp-c-catman           .cat
+./usr/share/man/cat3/fesetround.0              comp-c-catman           .cat
 ./usr/share/man/cat3/fetch.0                   comp-c-catman           .cat
+./usr/share/man/cat3/fetestexcept.0            comp-c-catman           .cat
+./usr/share/man/cat3/feupdateenv.0             comp-c-catman           .cat
 ./usr/share/man/cat3/fflush.0                  comp-c-catman           .cat
 ./usr/share/man/cat3/ffs.0                     comp-c-catman           .cat
 ./usr/share/man/cat3/ffs32.0                   comp-c-catman           .cat
@@ -11690,9 +11706,24 @@
 ./usr/share/man/html3/fdiml.html               comp-c-htmlman          html
 ./usr/share/man/html3/fdopen.html              comp-c-htmlman          html
 ./usr/share/man/html3/fdopendir.html           comp-c-htmlman          html
+./usr/share/man/html3/feclearexcept.html       comp-c-htmlman          html
+./usr/share/man/html3/fedisableexcept.html     comp-c-htmlman          html
+./usr/share/man/html3/feenableexcept.html      comp-c-htmlman          html
+./usr/share/man/html3/fegetenv.html            comp-c-htmlman          html
+./usr/share/man/html3/fegetexcept.html         comp-c-htmlman          html
+./usr/share/man/html3/fegetexceptflag.html     comp-c-htmlman          html
+./usr/share/man/html3/fegetround.html          comp-c-htmlman          html
+./usr/share/man/html3/feholdexcept.html                comp-c-htmlman          html
+./usr/share/man/html3/fenv.html                        comp-c-htmlman          html
 ./usr/share/man/html3/feof.html                        comp-c-htmlman          html
+./usr/share/man/html3/feraiseexcept.html       comp-c-htmlman          html
 ./usr/share/man/html3/ferror.html              comp-c-htmlman          html
+./usr/share/man/html3/feseteexcpetflag.html    comp-c-htmlman          html
+./usr/share/man/html3/fesetenv.html            comp-c-htmlman          html
+./usr/share/man/html3/fesetround.html          comp-c-htmlman          html
 ./usr/share/man/html3/fetch.html               comp-c-htmlman          html
+./usr/share/man/html3/fetestexcept.html                comp-c-htmlman          html
+./usr/share/man/html3/feupdateenv.html         comp-c-html             html
 ./usr/share/man/html3/fflush.html              comp-c-htmlman          html
 ./usr/share/man/html3/ffs.html                 comp-c-htmlman          html
 ./usr/share/man/html3/ffs32.html               comp-c-htmlman          html
@@ -17507,8 +17538,23 @@
 ./usr/share/man/man3/fdiml.3                   comp-c-man              .man
 ./usr/share/man/man3/fdopen.3                  comp-c-man              .man
 ./usr/share/man/man3/fdopendir.3               comp-c-man              .man
+./usr/share/man/man3/feclearexcept.3           comp-c-man              .man
+./usr/share/man/man3/fedisableexcept.3         comp-c-man              .man
+./usr/share/man/man3/feenableexcept.3          comp-c-man              .man
+./usr/share/man/man3/fegetenv.3                        comp-c-man              .man
+./usr/share/man/man3/fegetexcept.3             comp-c-man              .man
+./usr/share/man/man3/fegetexceptflag.3         comp-c-man              .man
+./usr/share/man/man3/fegetround.3              comp-c-man              .man
+./usr/share/man/man3/feholdexcept.3            comp-c-man              .man
+./usr/share/man/man3/fenv.3                    comp-c-man              .man
 ./usr/share/man/man3/feof.3                    comp-c-man              .man
+./usr/share/man/man3/feraiseexcept.3           comp-c-man              .man
 ./usr/share/man/man3/ferror.3                  comp-c-man              .man
+./usr/share/man/man3/feseteexcpetflag.3         comp-c-man              .man
+./usr/share/man/man3/fesetenv.3                 comp-c-man              .man
+./usr/share/man/man3/fesetround.3               comp-c-man              .man
+./usr/share/man/man3/fetestexcept.3            comp-c-man              .man
+./usr/share/man/man3/feupdateenv.3             comp-c-man              .man
 ./usr/share/man/man3/fetch.3                   comp-c-man              .man
 ./usr/share/man/man3/fflush.3                  comp-c-man              .man
 ./usr/share/man/man3/ffs.3                     comp-c-man              .man
diff -r b98912c67ea3 -r 5aee6b6471ad include/Makefile
--- a/include/Makefile  Sat Jul 31 21:21:17 2010 +0000
+++ b/include/Makefile  Sat Jul 31 21:47:52 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.132 2010/04/25 00:54:45 joerg Exp $
+#      $NetBSD: Makefile,v 1.133 2010/07/31 21:47:53 joerg Exp $
 #      @(#)Makefile    8.2 (Berkeley) 1/4/94
 
 # Doing a make includes builds /usr/include
@@ -9,7 +9,7 @@
 
 INCS=  a.out.h aio.h ar.h assert.h atomic.h \
        bitstring.h bm.h cdbr.h cdbw.h complex.h cpio.h ctype.h \
-       db.h dirent.h disktab.h dlfcn.h err.h errno.h fmtmsg.h fnmatch.h \
+       db.h dirent.h disktab.h dlfcn.h err.h errno.h fenv.h fmtmsg.h fnmatch.h \
        fstab.h fts.h ftw.h getopt.h glob.h grp.h ifaddrs.h iconv.h \
        inttypes.h iso646.h kvm.h langinfo.h libgen.h \
        limits.h link.h link_aout.h link_elf.h locale.h \
diff -r b98912c67ea3 -r 5aee6b6471ad include/fenv.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/include/fenv.h    Sat Jul 31 21:47:52 2010 +0000
@@ -0,0 +1,62 @@
+/*     $NetBSD: fenv.h,v 1.1 2010/07/31 21:47:53 joerg Exp $   */
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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 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.
+ */
+
+#if !defined(__i386__) && !defined(__amd64__)
+#error "fenv.h is currently not supported for this architecture"
+#endif
+
+#ifndef _FENV_H_
+#define _FENV_H_
+
+#include <machine/fenv.h>
+
+__BEGIN_DECLS
+
+/* Function prototypes */
+int    feclearexcept(int);
+int    fegetexceptflag(fexcept_t *, int);
+int    feraiseexcept(int);
+int    fesetexceptflag(const fexcept_t *, int);
+int    fetestexcept(int);
+int    fegetround(void);
+int    fesetround(int);
+int    fegetenv(fenv_t *);
+int    feholdexcept(fenv_t *);
+int    fesetenv(const fenv_t *);
+int    feupdateenv(const fenv_t *);
+
+#if defined(_NETBSD_SOURCE) || (_GNU_SOURCE)
+
+int    feenableexcept(int mask);
+int    fedisableexcept(int mask);
+int    fegetexcept(void);
+
+#endif /* _NETBDS_SOURCE || _GNU_SOURCE */
+
+__END_DECLS
+
+#endif /* ! _FENV_H_ */
diff -r b98912c67ea3 -r 5aee6b6471ad lib/libm/Makefile
--- a/lib/libm/Makefile Sat Jul 31 21:21:17 2010 +0000
+++ b/lib/libm/Makefile Sat Jul 31 21:47:52 2010 +0000
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.94 2010/04/23 19:17:07 drochner Exp $
+#  $NetBSD: Makefile,v 1.95 2010/07/31 21:47:53 joerg Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -51,7 +51,13 @@
 .PATH: ${.CURDIR}/arch/alpha
 ARCH_SRCS = s_copysign.S s_copysignf.S lrint.S
 .elif ((${MACHINE_ARCH} == "i386") || (${MACHINE_ARCH} == "x86_64"))
+
+.if (${MACHINE_ARCH} == "x86_64")
+.PATH: ${.CURDIR}/arch/x86_64
+.endif
 .PATH: ${.CURDIR}/arch/i387
+
+COMMON_SRCS+= fenv.c
 ARCH_SRCS = e_acos.S e_asin.S e_atan2.S e_exp.S e_expf.S e_fmod.S e_log.S \
            e_logf.S e_log10.S e_log10f.S e_log2.S e_log2f.S e_remainder.S \
            e_remainderf.S e_scalb.S e_scalbf.S e_sqrt.S e_sqrtf.S s_atan.S \
@@ -60,6 +66,7 @@
            s_ilogbf.S s_log1p.S s_log1pf.S s_logb.S s_logbf.S s_rint.S \
            s_rintf.S s_scalbn.S s_scalbnf.S s_significand.S \
            s_significandf.S s_sin.S s_sinf.S s_tan.S s_tanf.S lrint.S
+
 .if (${MACHINE_ARCH} == "i386")
 SUBDIR=arch/i387
 .endif
@@ -108,7 +115,7 @@
 CPPFLAGS+=-DLIBM_SCCS
 
 LIB=   m
-COMMON_SRCS = e_acos.c e_acosf.c e_acosh.c e_acoshf.c e_asin.c e_asinf.c \
+COMMON_SRCS+= e_acos.c e_acosf.c e_acosh.c e_acoshf.c e_asin.c e_asinf.c \
        e_atan2.c e_atan2f.c e_atanh.c e_atanhf.c e_cosh.c e_coshf.c e_exp.c \
        e_expf.c e_fmod.c e_fmodf.c e_hypot.c e_hypotf.c e_j0.c e_j0f.c \
        e_j1.c e_j1f.c e_jn.c e_jnf.c e_lgamma_r.c e_lgammaf_r.c e_log.c \
@@ -188,6 +195,19 @@
        math.3 modf.3 rint.3 round.3 sin.3 sinh.3 \
        sqrt.3 tan.3 tanh.3 trunc.3 fmax.3 fdim.3
 
+# fenv.h interface
+MAN+=  feclearexcept.3 feenableexcept.3 fegetenv.3 fegetround.3 fenv.3
+MLINKS+=feclearexcept.3 fegetexceptflag.3      \
+       feclearexcept.3 feraiseexcept.3         \
+       feclearexcept.3 feseteexcpetflag.3      \
+       feclearexcept.3 fetestexcept.3
+MLINKS+=feenableexcept.3 fedisableexcept.3     \
+       feenableexcept.3 fegetexcept.3
+MLINKS+=fegetenv.3 feholdexcept.3              \
+       fegetenv.3 fesetenv.3                   \
+       fegetenv.3 feupdateenv.3
+MLINKS+=fegetround.3 fesetround.3
+
 MLINKS+=acos.3 acosf.3
 MLINKS+=acosh.3 acoshf.3
 MLINKS+=asin.3 asinf.3
diff -r b98912c67ea3 -r 5aee6b6471ad lib/libm/arch/i387/fenv.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libm/arch/i387/fenv.c Sat Jul 31 21:47:52 2010 +0000
@@ -0,0 +1,516 @@
+/* $NetBSD: fenv.c,v 1.1 2010/07/31 21:47:53 joerg Exp $ */
+
+/*-
+ * Copyright (c) 2004-2005 David Schultz <das%FreeBSD.ORG@localhost>
+ * All rights reserved.
+ *
+ * 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



Home | Main Index | Thread Index | Old Index