Source-Changes-HG archive

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

[src/trunk]: src/sys/arch fenv for m68k



details:   https://anonhg.NetBSD.org/src/rev/db2bd248ebe0
branches:  trunk
changeset: 342487:db2bd248ebe0
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Dec 24 14:12:39 2015 +0000

description:
fenv for m68k

diffstat:

 sys/arch/amiga/include/Makefile   |    4 +-
 sys/arch/amiga/include/fenv.h     |    3 +
 sys/arch/atari/include/Makefile   |    4 +-
 sys/arch/atari/include/fenv.h     |    3 +
 sys/arch/cesfic/include/Makefile  |    4 +-
 sys/arch/cesfic/include/fenv.h    |    3 +
 sys/arch/evbcf/include/Makefile   |    4 +-
 sys/arch/evbcf/include/fenv.h     |    3 +
 sys/arch/hp300/include/Makefile   |    4 +-
 sys/arch/hp300/include/fenv.h     |    3 +
 sys/arch/luna68k/include/Makefile |    4 +-
 sys/arch/luna68k/include/fenv.h   |    3 +
 sys/arch/m68k/include/Makefile    |    4 +-
 sys/arch/m68k/include/fenv.h      |  302 ++++++++++++++++++++++++++++++++++++++
 sys/arch/mac68k/include/Makefile  |    4 +-
 sys/arch/mac68k/include/fenv.h    |    3 +
 sys/arch/mvme68k/include/Makefile |    4 +-
 sys/arch/mvme68k/include/fenv.h   |    3 +
 sys/arch/news68k/include/Makefile |    4 +-
 sys/arch/news68k/include/fenv.h   |    3 +
 sys/arch/next68k/include/Makefile |    4 +-
 sys/arch/next68k/include/fenv.h   |    3 +
 sys/arch/sun2/include/Makefile    |    4 +-
 sys/arch/sun2/include/fenv.h      |    3 +
 sys/arch/sun3/include/Makefile    |    4 +-
 sys/arch/sun3/include/fenv.h      |    3 +
 sys/arch/x68k/include/Makefile    |    4 +-
 sys/arch/x68k/include/fenv.h      |    3 +
 28 files changed, 369 insertions(+), 28 deletions(-)

diffs (truncated from 649 to 300 lines):

diff -r 39f8c8c77933 -r db2bd248ebe0 sys/arch/amiga/include/Makefile
--- a/sys/arch/amiga/include/Makefile   Thu Dec 24 14:12:12 2015 +0000
+++ b/sys/arch/amiga/include/Makefile   Thu Dec 24 14:12:39 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.25 2011/07/17 20:54:36 joerg Exp $
+#      $NetBSD: Makefile,v 1.26 2015/12/24 14:13:35 christos Exp $
 
 INCSDIR= /usr/include/amiga
 
@@ -7,7 +7,7 @@
        cdefs.h cpu.h cpufunc.h \
        disklabel.h \
        elf_machdep.h endian.h endian_machdep.h \
-       float.h frame.h \
+       fenv.h float.h frame.h \
        ieee.h ieeefp.h \
        int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
        intr.h \
diff -r 39f8c8c77933 -r db2bd248ebe0 sys/arch/amiga/include/fenv.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/amiga/include/fenv.h     Thu Dec 24 14:12:39 2015 +0000
@@ -0,0 +1,3 @@
+/*     $NetBSD: fenv.h,v 1.1 2015/12/24 14:13:35 christos Exp $        */
+
+#include <m68k/fenv.h>
diff -r 39f8c8c77933 -r db2bd248ebe0 sys/arch/atari/include/Makefile
--- a/sys/arch/atari/include/Makefile   Thu Dec 24 14:12:12 2015 +0000
+++ b/sys/arch/atari/include/Makefile   Thu Dec 24 14:12:39 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.25 2011/07/17 20:54:37 joerg Exp $
+#      $NetBSD: Makefile,v 1.26 2015/12/24 14:13:35 christos Exp $
 
 INCSDIR= /usr/include/atari
 
@@ -7,7 +7,7 @@
        cdefs.h cpu.h cpufunc.h \
        disklabel.h \
        elf_machdep.h endian.h endian_machdep.h \
-       float.h frame.h \
+       fenv.h float.h frame.h \
        intr.h ieee.h ieeefp.h \
        int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
        kcore.h \
diff -r 39f8c8c77933 -r db2bd248ebe0 sys/arch/atari/include/fenv.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/atari/include/fenv.h     Thu Dec 24 14:12:39 2015 +0000
@@ -0,0 +1,3 @@
+/*     $NetBSD: fenv.h,v 1.1 2015/12/24 14:13:35 christos Exp $        */
+
+#include <m68k/fenv.h>
diff -r 39f8c8c77933 -r db2bd248ebe0 sys/arch/cesfic/include/Makefile
--- a/sys/arch/cesfic/include/Makefile  Thu Dec 24 14:12:12 2015 +0000
+++ b/sys/arch/cesfic/include/Makefile  Thu Dec 24 14:12:39 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.10 2011/07/17 20:54:38 joerg Exp $
+#      $NetBSD: Makefile,v 1.11 2015/12/24 14:13:35 christos Exp $
 
 INCSDIR= /usr/include/cesfic
 
@@ -7,7 +7,7 @@
        cdefs.h cpu.h \
        disklabel.h elf_machdep.h \
        endian.h endian_machdep.h \
-       float.h frame.h \
+       fenv.h float.h frame.h \
        ieee.h ieeefp.h \
        int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
        intr.h \
diff -r 39f8c8c77933 -r db2bd248ebe0 sys/arch/cesfic/include/fenv.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/cesfic/include/fenv.h    Thu Dec 24 14:12:39 2015 +0000
@@ -0,0 +1,3 @@
+/*     $NetBSD: fenv.h,v 1.1 2015/12/24 14:13:35 christos Exp $        */
+
+#include <m68k/fenv.h>
diff -r 39f8c8c77933 -r db2bd248ebe0 sys/arch/evbcf/include/Makefile
--- a/sys/arch/evbcf/include/Makefile   Thu Dec 24 14:12:12 2015 +0000
+++ b/sys/arch/evbcf/include/Makefile   Thu Dec 24 14:12:39 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.2 2014/03/18 18:20:41 riastradh Exp $
+#      $NetBSD: Makefile,v 1.3 2015/12/24 14:13:35 christos Exp $
 
 INCSDIR= /usr/include/evbcf
 
@@ -7,7 +7,7 @@
        cdefs.h cpu.h \
        disklabel.h \
        elf_machdep.h endian.h endian_machdep.h \
-       float.h frame.h \
+       fenv.h float.h frame.h \
        ieee.h ieeefp.h \
        int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
        intr.h \
diff -r 39f8c8c77933 -r db2bd248ebe0 sys/arch/evbcf/include/fenv.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/evbcf/include/fenv.h     Thu Dec 24 14:12:39 2015 +0000
@@ -0,0 +1,3 @@
+/*     $NetBSD: fenv.h,v 1.1 2015/12/24 14:13:35 christos Exp $        */
+
+#include <m68k/fenv.h>
diff -r 39f8c8c77933 -r db2bd248ebe0 sys/arch/hp300/include/Makefile
--- a/sys/arch/hp300/include/Makefile   Thu Dec 24 14:12:12 2015 +0000
+++ b/sys/arch/hp300/include/Makefile   Thu Dec 24 14:12:39 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.26 2011/07/17 20:54:40 joerg Exp $
+#      $NetBSD: Makefile,v 1.27 2015/12/24 14:13:35 christos Exp $
 
 INCSDIR= /usr/include/hp300
 
@@ -7,7 +7,7 @@
        cdefs.h cpu.h \
        disklabel.h \
        elf_machdep.h endian.h endian_machdep.h \
-       float.h frame.h \
+       fenv.h float.h frame.h \
        hp300spu.h hpux_machdep.h \
        ieee.h ieeefp.h \
        int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
diff -r 39f8c8c77933 -r db2bd248ebe0 sys/arch/hp300/include/fenv.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hp300/include/fenv.h     Thu Dec 24 14:12:39 2015 +0000
@@ -0,0 +1,3 @@
+/*     $NetBSD: fenv.h,v 1.1 2015/12/24 14:13:35 christos Exp $        */
+
+#include <m68k/fenv.h>
diff -r 39f8c8c77933 -r db2bd248ebe0 sys/arch/luna68k/include/Makefile
--- a/sys/arch/luna68k/include/Makefile Thu Dec 24 14:12:12 2015 +0000
+++ b/sys/arch/luna68k/include/Makefile Thu Dec 24 14:12:39 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.17 2011/07/17 20:54:43 joerg Exp $
+#      $NetBSD: Makefile,v 1.18 2015/12/24 14:13:35 christos Exp $
 
 INCSDIR= /usr/include/luna68k
 
@@ -7,7 +7,7 @@
        cdefs.h cpu.h \
        disklabel.h \
        elf_machdep.h endian.h endian_machdep.h \
-       float.h frame.h \
+       fenv.h float.h frame.h \
        ieee.h ieeefp.h \
        int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
        intr.h \
diff -r 39f8c8c77933 -r db2bd248ebe0 sys/arch/luna68k/include/fenv.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/luna68k/include/fenv.h   Thu Dec 24 14:12:39 2015 +0000
@@ -0,0 +1,3 @@
+/*     $NetBSD: fenv.h,v 1.1 2015/12/24 14:13:35 christos Exp $        */
+
+#include <m68k/fenv.h>
diff -r 39f8c8c77933 -r db2bd248ebe0 sys/arch/m68k/include/Makefile
--- a/sys/arch/m68k/include/Makefile    Thu Dec 24 14:12:12 2015 +0000
+++ b/sys/arch/m68k/include/Makefile    Thu Dec 24 14:12:39 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.28 2013/07/17 05:42:02 matt Exp $
+#      $NetBSD: Makefile,v 1.29 2015/12/24 14:12:39 christos Exp $
 
 INCSDIR= /usr/include/m68k
 
@@ -7,7 +7,7 @@
        cacheops.h cacheops_20.h cacheops_30.h cacheops_40.h cacheops_60.h \
        cdefs.h cpu.h cpuframe.h \
        elf_machdep.h endian.h endian_machdep.h \
-       float.h fpreg.h frame.h \
+       fenv.h float.h fpreg.h frame.h \
        ieee.h ieeefp.h \
        int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
        kcore.h \
diff -r 39f8c8c77933 -r db2bd248ebe0 sys/arch/m68k/include/fenv.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/m68k/include/fenv.h      Thu Dec 24 14:12:39 2015 +0000
@@ -0,0 +1,302 @@
+/*     $NetBSD: fenv.h,v 1.1 2015/12/24 14:12:39 christos Exp $        */
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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.
+ */
+
+#ifndef _M68K_FENV_H_
+#define _M68K_FENV_H_
+
+#include <sys/stdint.h>
+#include <m68k/float.h>
+#include <m68k/fpreg.h>
+
+#ifndef __fenv_static   
+#define __fenv_static   static
+#endif
+
+/* Exception bits, from FPSR */
+#define        FE_INEXACT      FPSR_AINEX
+#define        FE_DIVBYZERO    FPSR_ADZ
+#define        FE_UNDERFLOW    FPSR_AUNFL
+#define        FE_OVERFLOW     FPSR_AOVFL
+#define        FE_INVALID      FPSR_AIOP
+
+#define FE_ALL_EXCEPT \
+    (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
+
+/* Rounding modes, from FPSR */
+#define FE_TONEAREST   FPCR_NEAR
+#define        FE_TOWARDZERO   FPCR_ZERO
+#define        FE_DOWNWARD     FPCR_MINF
+#define        FE_UPWARD       FPCR_PINF
+
+#define _ROUND_MASK    \
+    (FE_TONEAREST | FE_TOWARDZERO | FE_DOWNWARD | FE_UPWARD)
+
+typedef uint32_t fexcept_t;
+
+/* same layout as fmovem */
+typedef struct {
+       uint32_t fpcr;
+       uint32_t fpsr;
+       uint32_t fppc;
+} fenv_t;
+
+#define FE_DFL_ENV     ((fenv_t *) -1)
+
+#define __get_fpcr(__fpcr) \
+    __asm__ __volatile__ ("fmove%.l %!,%0" : "=dm" (__fpcr))
+#define __set_fpcr(__fpcr) \
+    __asm__ __volatile__ ("fmove%.l %0,%!" : : "dm" (__fpcr))
+
+#define __get_fpsr(__fpsr) \
+    __asm__ __volatile__ ("fmove%.l %/fpsr,%0" : "=dm" (__fpsr))
+#define __set_fpsr(__fpsr) \
+    __asm__ __volatile__ ("fmove%.l %0,%/fpsr" : : "dm" (__fpsr))
+
+#define __fmul(__s, __t, __d) \
+    do { \
+           __t d = __d; \
+           __asm__ __volatile__ ("fmul" __s "; fnop" : "=f" (d) : "0" (d)); \
+    } while (/*CONSTCOND*/0) 
+
+#define __fdiv(__s, __t, __d) \
+    do { \
+           __t d = __d; \
+           __asm__ __volatile__ ("fdiv" __s "; fnop" : "=f" (d) : "0" (d)); \
+    } while (/*CONSTCOND*/0) 
+
+#define __fetox(__s, __t, __d) \
+    do { \
+           __t d = __d; \
+           __asm__ __volatile__ ("fetox" __s "; fnop" : "=f" (d) : "0" (d)); \
+    } while (/*CONSTCOND*/0) 
+
+#define __fgetenv(__envp) \
+    __asm__ __volatile__ ("fmovem%.l %/fpcr/%/fpsr/%/fpiar,%0" : "=m" (__envp))
+
+#define __fsetenv(__envp) \
+    __asm__ __volatile__ ("fmovem%.l %0,%/fpcr/%/fpsr/%/fpiar" : : "m" (__envp))
+
+__fenv_static inline int
+feclearexcept(int __excepts)
+{
+       fexcept_t __fpsr;
+
+       __excepts &= FE_ALL_EXCEPT;
+
+       __get_fpsr(__fpsr);
+       __fpsr &= ~__excepts;
+       __set_fpsr(__fpsr);
+
+       return 0;
+}
+
+__fenv_static inline int
+fegetexceptflag(fexcept_t *__flagp, int __excepts)
+{
+       fexcept_t __fpsr;
+
+       __get_fpsr(__fpsr);
+
+       *__flagp = __fpsr & __excepts & FE_ALL_EXCEPT;



Home | Main Index | Thread Index | Old Index