Subject: port-pc532/2281: The ns32k arch is missing fpsetmask, fpgetmask, fpsetsticky and fpgetsticky
To: None <gnats-bugs@NetBSD.ORG>
From: None <leo@marco.de>
List: netbsd-bugs
Date: 04/01/1996 11:00:00
>Number:         2281
>Category:       port-pc532
>Synopsis:       The ns32k arch is missing fpsetmask, fpgetmask, fpsetsticky and fpgetsticky
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Apr  1 04:35:00 1996
>Last-Modified:
>Originator:     Matthias Pfaller
>Organization:
leo@dachau.marco.de			in real life: Matthias Pfaller
marco GmbH, 85221 Dachau, Germany	tel: +49 8131 516142
>Release:        960328
>Environment:
	
System: NetBSD klondike 1.1B NetBSD 1.1B (KLONDIKE) #99: Sat Mar 30 00:49:14 MET 1996 leo@klondike:/usr/src/sys/arch/pc532/compile/KLONDIKE pc532


>Description:
	The ns32k arch is missing fpsetmask, fpgetmask, fpsetsticky
	and fpgetsticky. With the upcoming kernel changes to support
	full ieee math, these routines can now get added.
>How-To-Repeat:
>Fix:
--- lib/libc/arch/ns32k/gen/fpsetmask.c.ORIG	Sun Mar 31 11:23:10 1996
+++ lib/libc/arch/ns32k/gen/fpsetmask.c	Sun Mar 31 12:04:56 1996
@@ -0,0 +1,27 @@
+/*
+ * Written by J.T. Conklin, Apr 10, 1995
+ * Public domain.
+ */
+
+#include <ieeefp.h>
+#include <machine/cpufunc.h>
+#include <machine/fpu.h>
+
+fp_except
+fpsetmask(mask)
+	fp_except mask;
+{
+	fp_except old;
+	fp_except new;
+	fp_except ebits = FPC_IEN | FPC_OVE | FPC_IVE | FPC_DZE | FPC_UNDE;
+
+	sfsr(old);
+
+	new = old;
+	new &= ~ebits;
+	new |= mask & ebits;
+
+	lfsr(new);
+
+	return old & ebits;
+}
--- lib/libc/arch/ns32k/gen/Makefile.inc.ORIG	Sat Oct 14 01:43:04 1995
+++ lib/libc/arch/ns32k/gen/Makefile.inc	Sun Mar 31 11:36:00 1996
@@ -2,4 +2,5 @@
 
 SRCS+=	__main.c _setjmp.S alloca.S fabs.S frexp.S infinity.c isinf.c
 SRCS+=	ldexp.S modf.S setjmp.S sigsetjmp.S
-SRCS+=	flt_rounds.c fpgetround.c fpsetround.c
+SRCS+=	flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
+	fpsetround.c fpsetsticky.c
--- lib/libc/arch/ns32k/gen/fpgetsticky.c.ORIG	Sun Mar 31 11:34:07 1996
+++ lib/libc/arch/ns32k/gen/fpgetsticky.c	Sun Mar 31 12:36:57 1996
@@ -0,0 +1,25 @@
+/*
+ * Written by J.T. Conklin, Apr 11, 1995
+ * Public domain.
+ */
+
+#include <ieeefp.h>
+#include <machine/cpufunc.h>
+#include <machine/fpu.h>
+
+fp_except
+fpgetsticky()
+{
+	fp_except x;
+	fp_except ebits = FPC_IEN | FPC_OVE | FPC_IVE | FPC_DZE | FPC_UNDE;
+
+	sfsr(x);
+	/* Map FPC_UF to soft underflow enable */
+	if (x & FPC_UF)
+		x |= FPC_UNDE << 1;
+	else
+		x &= ~(FPC_UNDE << 1);
+	x >>= 1;
+
+	return x & ebits;
+}
--- lib/libc/arch/ns32k/gen/fpgetmask.c.ORIG	Sun Mar 31 11:40:11 1996
+++ lib/libc/arch/ns32k/gen/fpgetmask.c	Sun Mar 31 12:04:55 1996
@@ -0,0 +1,19 @@
+/*
+ * Written by J.T. Conklin, Apr 10, 1995
+ * Public domain.
+ */
+
+#include <ieeefp.h>
+#include <machine/cpufunc.h>
+#include <machine/fpu.h>
+
+fp_except
+fpgetmask()
+{
+	fp_except x;
+	fp_except ebits = FPC_IEN | FPC_OVE | FPC_IVE | FPC_DZE | FPC_UNDE;
+
+	sfsr(x);
+
+	return x & ebits;
+}
--- lib/libc/arch/ns32k/gen/fpsetsticky.c.ORIG	Sun Mar 31 11:53:56 1996
+++ lib/libc/arch/ns32k/gen/fpsetsticky.c	Sun Mar 31 17:49:24 1996
@@ -0,0 +1,40 @@
+/*
+ * Written by J.T. Conklin, Apr 10, 1995
+ * Public domain.
+ */
+
+#include <ieeefp.h>
+#include <machine/cpufunc.h>
+#include <machine/fpu.h>
+
+fp_except
+fpsetsticky(sticky)
+	fp_except sticky;
+{
+	fp_except old;
+	fp_except new;
+	fp_except ebits = FPC_IEN | FPC_OVE | FPC_IVE | FPC_DZE | FPC_UEN | FPC_UNDE;
+
+	if (sticky & FPC_UNDE) {
+		sticky |= FPC_UEN;
+		sticky &= ~FPC_UNDE;
+	}
+
+	sfsr(old);
+
+	new = old;
+	new &= ~ebits;
+	new |= (sticky & ebits) << 1;
+
+	lfsr(new);
+
+	/* Map FPC_UF to soft underflow enable */
+	if (old & FPC_UF) {
+		old |= FPC_UNDE << 1;
+		old &= FPC_UF;
+	} else
+		old &= ~(FPC_UNDE << 1);
+	old >>= 1;
+
+	return old & ebits;
+}
>Audit-Trail:
>Unformatted: