summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2002-05-22 20:05:02 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2002-05-22 20:05:02 +0000
commit0ab8a6a7ce8fdf2d0b3158bd2f4bb5d4d5660d3a (patch)
treeed35f34d517cf56fc111c403347da2cd2d25109b
parentae2371e83f0601b26cb0a46001c128068b62b173 (diff)
I was on drugs when I commited this initially, and still do not understand
how I got libc to compile with this. Blush. Replace this with a correct implementation, and write a faster fabs() while there. ok mickey@
-rw-r--r--lib/libc/arch/hppa/gen/fabs.c14
-rw-r--r--lib/libc/arch/hppa/gen/flt_rounds.c13
-rw-r--r--lib/libc/arch/hppa/gen/fpgetmask.c43
-rw-r--r--lib/libc/arch/hppa/gen/fpgetround.c43
-rw-r--r--lib/libc/arch/hppa/gen/fpgetsticky.c43
-rw-r--r--lib/libc/arch/hppa/gen/fpsetmask.c47
-rw-r--r--lib/libc/arch/hppa/gen/fpsetround.c47
-rw-r--r--lib/libc/arch/hppa/gen/fpsetsticky.c47
-rw-r--r--sys/arch/hppa/include/ieeefp.h20
9 files changed, 62 insertions, 255 deletions
diff --git a/lib/libc/arch/hppa/gen/fabs.c b/lib/libc/arch/hppa/gen/fabs.c
index e9e8510399d..35c0d764b4a 100644
--- a/lib/libc/arch/hppa/gen/fabs.c
+++ b/lib/libc/arch/hppa/gen/fabs.c
@@ -1,9 +1,13 @@
+/* $OpenBSD: fabs.c,v 1.2 2002/05/22 20:05:01 miod Exp $ */
+
+/*
+ * Written by Miodrag Vallat. Public domain
+ */
+
double
fabs(double val)
{
- if (val > 0) {
- return val;
- } else {
- return -val;
- }
+
+ __asm__ __volatile__("fabs,dbl %0,%0" : "+f"(val));
+ return (val);
}
diff --git a/lib/libc/arch/hppa/gen/flt_rounds.c b/lib/libc/arch/hppa/gen/flt_rounds.c
index 34d31bf7095..515bb930881 100644
--- a/lib/libc/arch/hppa/gen/flt_rounds.c
+++ b/lib/libc/arch/hppa/gen/flt_rounds.c
@@ -1,4 +1,8 @@
-/* $OpenBSD: flt_rounds.c,v 1.1 2002/03/11 02:59:01 miod Exp $ */
+/* $OpenBSD: flt_rounds.c,v 1.2 2002/05/22 20:05:01 miod Exp $ */
+
+/*
+ * Written by Miodrag Vallat. Public domain.
+ */
#include <sys/types.h>
#include <machine/float.h>
@@ -13,9 +17,8 @@ static const int map[] = {
int
__flt_rounds()
{
- double tmp;
- int x;
+ u_int32_t fpsr;
- asm("mffs %0; stfiwx %0,0,%1" : "=f"(tmp): "b"(&x));
- return map[x & 0x03];
+ __asm__ __volatile__("fstw %%fr0,0(%1)" : "=m"(fpsr) : "r"(&fpsr));
+ return map[(fpsr >> 9) & 0x03];
}
diff --git a/lib/libc/arch/hppa/gen/fpgetmask.c b/lib/libc/arch/hppa/gen/fpgetmask.c
index 15c2d33e9bb..dc7b6c98133 100644
--- a/lib/libc/arch/hppa/gen/fpgetmask.c
+++ b/lib/libc/arch/hppa/gen/fpgetmask.c
@@ -1,40 +1,7 @@
-/* $OpenBSD: fpgetmask.c,v 1.1 2002/03/11 02:59:01 miod Exp $ */
-/* $NetBSD: fpgetmask.c,v 1.1 1999/07/07 01:55:07 danw Exp $ */
+/* $OpenBSD: fpgetmask.c,v 1.2 2002/05/22 20:05:01 miod Exp $ */
/*
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Dan Winship.
- *
- * 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.
+ * Written by Miodrag Vallat. Public domain
*/
#include <sys/types.h>
@@ -43,8 +10,8 @@
fp_except
fpgetmask()
{
- u_int64_t fpscr;
+ u_int32_t fpsr;
- __asm__ __volatile("mffs %0" : "=f"(fpscr));
- return ((fpscr >> 3) & 0x1f);
+ __asm__ __volatile__("fstw %%fr0,0(%1)" : "=m"(fpsr) : "r"(&fpsr));
+ return (fpsr & 0x1f);
}
diff --git a/lib/libc/arch/hppa/gen/fpgetround.c b/lib/libc/arch/hppa/gen/fpgetround.c
index 4b5714d99c2..db1b7f55eaa 100644
--- a/lib/libc/arch/hppa/gen/fpgetround.c
+++ b/lib/libc/arch/hppa/gen/fpgetround.c
@@ -1,40 +1,7 @@
-/* $OpenBSD: fpgetround.c,v 1.1 2002/03/11 02:59:01 miod Exp $ */
-/* $NetBSD: fpgetround.c,v 1.1 1999/07/07 01:55:08 danw Exp $ */
+/* $OpenBSD: fpgetround.c,v 1.2 2002/05/22 20:05:01 miod Exp $ */
/*
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Dan Winship.
- *
- * 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.
+ * Written by Miodrag Vallat. Public domain
*/
#include <sys/types.h>
@@ -43,8 +10,8 @@
fp_rnd
fpgetround()
{
- u_int64_t fpscr;
+ u_int32_t fpsr;
- __asm__ __volatile("mffs %0" : "=f"(fpscr));
- return (fpscr & 0x3);
+ __asm__ __volatile__("fstw %%fr0,0(%1)" : "=m"(fpsr) : "r"(&fpsr));
+ return ((fpsr >> 9) & 0x3);
}
diff --git a/lib/libc/arch/hppa/gen/fpgetsticky.c b/lib/libc/arch/hppa/gen/fpgetsticky.c
index a92ace4911b..515ab823a13 100644
--- a/lib/libc/arch/hppa/gen/fpgetsticky.c
+++ b/lib/libc/arch/hppa/gen/fpgetsticky.c
@@ -1,40 +1,7 @@
-/* $OpenBSD: fpgetsticky.c,v 1.1 2002/03/11 02:59:01 miod Exp $ */
-/* $NetBSD: fpgetsticky.c,v 1.1 1999/07/07 01:55:08 danw Exp $ */
+/* $OpenBSD: fpgetsticky.c,v 1.2 2002/05/22 20:05:01 miod Exp $ */
/*
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Dan Winship.
- *
- * 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.
+ * Written by Miodrag Vallat. Public domain
*/
#include <sys/types.h>
@@ -43,8 +10,8 @@
fp_except
fpgetsticky()
{
- u_int64_t fpscr;
+ u_int32_t fpsr;
- __asm__ __volatile("mffs %0" : "=f"(fpscr));
- return ((fpscr >> 25) & 0x1f);
+ __asm__ __volatile__("fstw %%fr0,0(%1)" : "=m"(fpsr) : "r"(&fpsr));
+ return ((fpsr >> 27) & 0x1f);
}
diff --git a/lib/libc/arch/hppa/gen/fpsetmask.c b/lib/libc/arch/hppa/gen/fpsetmask.c
index f7cc89ad184..91edb78ced3 100644
--- a/lib/libc/arch/hppa/gen/fpsetmask.c
+++ b/lib/libc/arch/hppa/gen/fpsetmask.c
@@ -1,40 +1,7 @@
-/* $OpenBSD: fpsetmask.c,v 1.1 2002/03/11 02:59:01 miod Exp $ */
-/* $NetBSD: fpsetmask.c,v 1.1 1999/07/07 01:55:08 danw Exp $ */
+/* $OpenBSD: fpsetmask.c,v 1.2 2002/05/22 20:05:01 miod Exp $ */
/*
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Dan Winship.
- *
- * 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.
+ * Written by Miodrag Vallat. Public domain
*/
#include <sys/types.h>
@@ -44,12 +11,12 @@ fp_except
fpsetmask(mask)
fp_except mask;
{
- u_int64_t fpscr;
+ u_int32_t fpsr;
fp_rnd old;
- __asm__ __volatile("mffs %0" : "=f"(fpscr));
- old = (fpscr >> 3) & 0x1f;
- fpscr = (fpscr & 0xffffff07) | (mask << 3);
- __asm__ __volatile("mtfsf 0xff,%0" :: "f"(fpscr));
+ __asm__ __volatile__("fstw %%fr0,0(%1)" : "=m"(fpsr) : "r"(&fpsr));
+ old = fpsr & 0x1f;
+ fpsr = (fpsr & 0xffffffe0) | (mask & 0x1f);
+ __asm__ __volatile__("fldw 0(%0),%%fr0" : : "r"(&fpsr));
return (old);
}
diff --git a/lib/libc/arch/hppa/gen/fpsetround.c b/lib/libc/arch/hppa/gen/fpsetround.c
index 5457deb6b54..14b1f0804b5 100644
--- a/lib/libc/arch/hppa/gen/fpsetround.c
+++ b/lib/libc/arch/hppa/gen/fpsetround.c
@@ -1,40 +1,7 @@
-/* $OpenBSD: fpsetround.c,v 1.1 2002/03/11 02:59:01 miod Exp $ */
-/* $NetBSD: fpsetround.c,v 1.1 1999/07/07 01:55:08 danw Exp $ */
+/* $OpenBSD: fpsetround.c,v 1.2 2002/05/22 20:05:01 miod Exp $ */
/*
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Dan Winship.
- *
- * 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.
+ * Written by Miodrag Vallat. Public domain
*/
#include <sys/types.h>
@@ -44,12 +11,12 @@ fp_rnd
fpsetround(rnd_dir)
fp_rnd rnd_dir;
{
- u_int64_t fpscr;
+ u_int32_t fpsr;
fp_rnd old;
- __asm__ __volatile("mffs %0" : "=f"(fpscr));
- old = fpscr & 0x3;
- fpscr = (fpscr & 0xfffffffc) | rnd_dir;
- __asm__ __volatile("mtfsf 0xff,%0" :: "f"(fpscr));
+ __asm__ __volatile__("fstw %%fr0,0(%1)" : "=m"(fpsr) : "r"(&fpsr));
+ old = (fpsr >> 9) & 0x03;
+ fpsr = (fpsr & 0xfffff9ff) | ((rnd_dir & 0x03) << 9);
+ __asm__ __volatile__("fldw 0(%0),%%fr0" : : "r"(&fpsr));
return (old);
}
diff --git a/lib/libc/arch/hppa/gen/fpsetsticky.c b/lib/libc/arch/hppa/gen/fpsetsticky.c
index d3346a47290..0a86282d2a4 100644
--- a/lib/libc/arch/hppa/gen/fpsetsticky.c
+++ b/lib/libc/arch/hppa/gen/fpsetsticky.c
@@ -1,40 +1,7 @@
-/* $OpenBSD: fpsetsticky.c,v 1.1 2002/03/11 02:59:01 miod Exp $ */
-/* $NetBSD: fpsetsticky.c,v 1.1 1999/07/07 01:55:08 danw Exp $ */
+/* $OpenBSD: fpsetsticky.c,v 1.2 2002/05/22 20:05:01 miod Exp $ */
/*
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Dan Winship.
- *
- * 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.
+ * Written by Miodrag Vallat. Public domain
*/
#include <sys/types.h>
@@ -44,12 +11,12 @@ fp_except
fpsetsticky(mask)
fp_except mask;
{
- u_int64_t fpscr;
+ u_int32_t fpsr;
fp_rnd old;
- __asm__ __volatile("mffs %0" : "=f"(fpscr));
- old = (fpscr >> 25) & 0x1f;
- fpscr = (fpscr & 0xc1ffffff) | (mask << 25);
- __asm__ __volatile("mtfsf 0xff,%0" :: "f"(fpscr));
+ __asm__ __volatile__("fstw %%fr0,0(%1)" : "=m"(fpsr) : "r"(&fpsr));
+ old = (fpsr >> 27) & 0x1f;
+ fpsr = (fpsr & 0x07ffffff) | ((mask & 0x1f) << 27);
+ __asm__ __volatile__("fldw 0(%0),%%fr0" : : "r"(&fpsr));
return (old);
}
diff --git a/sys/arch/hppa/include/ieeefp.h b/sys/arch/hppa/include/ieeefp.h
index b8befa634ed..07845bbab09 100644
--- a/sys/arch/hppa/include/ieeefp.h
+++ b/sys/arch/hppa/include/ieeefp.h
@@ -1,26 +1,24 @@
-/* $OpenBSD: ieeefp.h,v 1.1 2002/03/11 02:05:22 miod Exp $ */
+/* $OpenBSD: ieeefp.h,v 1.2 2002/05/22 20:04:55 miod Exp $ */
/*
- * Written by J.T. Conklin, Apr 6, 1995
- * Public domain.
+ * Written by Miodrag Vallat. Public domain.
*/
#ifndef _HPPA_IEEEFP_H_
#define _HPPA_IEEEFP_H_
typedef int fp_except;
-#define FP_X_INV 0x01 /* invalid operation exception */
-#define FP_X_DNML 0x02 /* denormalization exception */
-#define FP_X_DZ 0x04 /* divide-by-zero exception */
-#define FP_X_OFL 0x08 /* overflow exception */
-#define FP_X_UFL 0x10 /* underflow exception */
-#define FP_X_IMP 0x20 /* imprecise (loss of precision) */
+#define FP_X_INV 0x10 /* invalid operation exception */
+#define FP_X_DZ 0x08 /* divide-by-zero exception */
+#define FP_X_OFL 0x04 /* overflow exception */
+#define FP_X_UFL 0x02 /* underflow exception */
+#define FP_X_IMP 0x01 /* imprecise (loss of precision) */
typedef enum {
FP_RN=0, /* round to nearest representable number */
- FP_RM=1, /* round toward negative infinity */
+ FP_RZ=1, /* round to zero (truncate) */
FP_RP=2, /* round toward positive infinity */
- FP_RZ=3 /* round to zero (truncate) */
+ FP_RM=3 /* round toward negative infinity */
} fp_rnd;
#endif /* _HPPA_IEEEFP_H_ */