From a0c1305064c6fa996613d6b155ca66a675978be1 Mon Sep 17 00:00:00 2001 From: jtc Date: Mon, 10 Apr 1995 21:09:06 +0000 Subject: [PATCH] Added __flt_rounds, fp{get,set}{mask,round,sticky}. --- lib/libc/arch/sparc/gen/Makefile.inc | 4 +++- lib/libc/arch/sparc/gen/flt_rounds.c | 20 ++++++++++++++++++++ lib/libc/arch/sparc/gen/fpgetmask.c | 15 +++++++++++++++ lib/libc/arch/sparc/gen/fpgetround.c | 15 +++++++++++++++ lib/libc/arch/sparc/gen/fpgetsticky.c | 15 +++++++++++++++ lib/libc/arch/sparc/gen/fpsetmask.c | 24 ++++++++++++++++++++++++ lib/libc/arch/sparc/gen/fpsetround.c | 24 ++++++++++++++++++++++++ lib/libc/arch/sparc/gen/fpsetsticky.c | 24 ++++++++++++++++++++++++ 8 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 lib/libc/arch/sparc/gen/flt_rounds.c create mode 100644 lib/libc/arch/sparc/gen/fpgetmask.c create mode 100644 lib/libc/arch/sparc/gen/fpgetround.c create mode 100644 lib/libc/arch/sparc/gen/fpgetsticky.c create mode 100644 lib/libc/arch/sparc/gen/fpsetmask.c create mode 100644 lib/libc/arch/sparc/gen/fpsetround.c create mode 100644 lib/libc/arch/sparc/gen/fpsetsticky.c diff --git a/lib/libc/arch/sparc/gen/Makefile.inc b/lib/libc/arch/sparc/gen/Makefile.inc index 0ab42b4aa9f8..87d7b1bbffab 100644 --- a/lib/libc/arch/sparc/gen/Makefile.inc +++ b/lib/libc/arch/sparc/gen/Makefile.inc @@ -1,4 +1,6 @@ -# $NetBSD: Makefile.inc,v 1.2 1995/02/25 16:24:39 cgd Exp $ +# $NetBSD: Makefile.inc,v 1.3 1995/04/10 21:09:06 jtc Exp $ SRCS+= _setjmp.S fabs.S frexp.c infinity.c isinf.c isnan.c ldexp.c modf.S +SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ + fpsetround.c fpsetsticky.c SRCS+= fixunsdfsi.S mul.S umul.S saveregs.S setjmp.S sigsetjmp.S diff --git a/lib/libc/arch/sparc/gen/flt_rounds.c b/lib/libc/arch/sparc/gen/flt_rounds.c new file mode 100644 index 000000000000..1904287c1438 --- /dev/null +++ b/lib/libc/arch/sparc/gen/flt_rounds.c @@ -0,0 +1,20 @@ +/* + * Written by J.T. Conklin, Apr 10, 1995 + * Public domain. + */ + +static const int map[] = { + 1, /* round to nearest */ + 0, /* round to zero */ + 3, /* round to negative infinity */ + 2 /* round to positive infinity */ +}; + +int +__flt_rounds() +{ + int x; + + __asm__("st %%fsr,%0" : "=m" (*&x)); + return map[(x >> 30) & 0x03]; +} diff --git a/lib/libc/arch/sparc/gen/fpgetmask.c b/lib/libc/arch/sparc/gen/fpgetmask.c new file mode 100644 index 000000000000..b2d0c471162e --- /dev/null +++ b/lib/libc/arch/sparc/gen/fpgetmask.c @@ -0,0 +1,15 @@ +/* + * Written by J.T. Conklin, Apr 10, 1995 + * Public domain. + */ + +#include + +fp_except +fpgetmask() +{ + int x; + + __asm__("st %%fsr,%0" : "=m" (*&x)); + return (x >> 23) & 0x1f; +} diff --git a/lib/libc/arch/sparc/gen/fpgetround.c b/lib/libc/arch/sparc/gen/fpgetround.c new file mode 100644 index 000000000000..6cd5b4a126ca --- /dev/null +++ b/lib/libc/arch/sparc/gen/fpgetround.c @@ -0,0 +1,15 @@ +/* + * Written by J.T. Conklin, Apr 10, 1995 + * Public domain. + */ + +#include + +fp_rnd +fpgetround() +{ + int x; + + __asm__("st %%fsr,%0" : "=m" (*&x)); + return (x >> 30) & 0x03; +} diff --git a/lib/libc/arch/sparc/gen/fpgetsticky.c b/lib/libc/arch/sparc/gen/fpgetsticky.c new file mode 100644 index 000000000000..417dec82f24f --- /dev/null +++ b/lib/libc/arch/sparc/gen/fpgetsticky.c @@ -0,0 +1,15 @@ +/* + * Written by J.T. Conklin, Apr 10, 1995 + * Public domain. + */ + +#include + +fp_except +fpgetsticky() +{ + int x; + + __asm__("st %%fsr,%0" : "=m" (*&x)); + return (x >> 5) & 0x1f; +} diff --git a/lib/libc/arch/sparc/gen/fpsetmask.c b/lib/libc/arch/sparc/gen/fpsetmask.c new file mode 100644 index 000000000000..eb674c0da6bf --- /dev/null +++ b/lib/libc/arch/sparc/gen/fpsetmask.c @@ -0,0 +1,24 @@ +/* + * Written by J.T. Conklin, Apr 10, 1995 + * Public domain. + */ + +#include + +fp_except +fpsetmask(mask) + fp_except mask; +{ + fp_except old; + fp_except new; + + __asm__("st %%fsr,%0" : "=m" (*&old)); + + new = old; + new &= ~(0x1f << 23); + new |= ((mask & 0x1f) << 23); + + __asm__("ld %0,%%fsr" : : "m" (*&new)); + + return (old >> 23) & 0x1f; +} diff --git a/lib/libc/arch/sparc/gen/fpsetround.c b/lib/libc/arch/sparc/gen/fpsetround.c new file mode 100644 index 000000000000..924509bcaa98 --- /dev/null +++ b/lib/libc/arch/sparc/gen/fpsetround.c @@ -0,0 +1,24 @@ +/* + * Written by J.T. Conklin, Apr 10, 1995 + * Public domain. + */ + +#include + +fp_rnd +fpsetround(rnd_dir) + fp_rnd rnd_dir; +{ + fp_rnd old; + fp_rnd new; + + __asm__("st %%fsr,%0" : "=m" (*&old)); + + new = old; + new &= ~(0x03 << 30); + new |= ((rnd_dir & 0x03) << 30); + + __asm__("ld %0,%%fsr" : : "m" (*&new)); + + return (old >> 30) & 0x03; +} diff --git a/lib/libc/arch/sparc/gen/fpsetsticky.c b/lib/libc/arch/sparc/gen/fpsetsticky.c new file mode 100644 index 000000000000..e08c682ff0ef --- /dev/null +++ b/lib/libc/arch/sparc/gen/fpsetsticky.c @@ -0,0 +1,24 @@ +/* + * Written by J.T. Conklin, Apr 10, 1995 + * Public domain. + */ + +#include + +fp_except +fpsetsticky(sticky) + fp_except sticky; +{ + fp_except old; + fp_except new; + + __asm__("st %%fsr,%0" : "=m" (*&old)); + + new = old; + new &= ~(0x1f << 5); + new |= ((sticky & 0x1f) << 5); + + __asm__("ld %0,%%fsr" : : "m" (*&new)); + + return (old >> 5) & 0x1f; +}