Added __flt_rounds, fp{get,set}{mask,round,sticky}.

This commit is contained in:
jtc 1995-04-11 18:13:49 +00:00
parent 01194e13e9
commit 53bd3d0603
8 changed files with 140 additions and 1 deletions

View File

@ -1,4 +1,6 @@
# $NetBSD: Makefile.inc,v 1.2 1995/02/25 16:24:32 cgd Exp $
# $NetBSD: Makefile.inc,v 1.3 1995/04/11 18:13:49 jtc Exp $
SRCS+= _setjmp.S fabs.S frexp.c infinity.c isinf.S ldexp.S modf.S
SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
fpsetround.c fpsetsticky.c
SRCS+= setjmp.S

View File

@ -0,0 +1,20 @@
/*
* Written by J.T. Conklin, Apr 11, 1995
* Public domain.
*/
static const int map[] = {
1, /* round to nearest */
0, /* round to zero */
2, /* round to positive infinity */
3 /* round to negative infinity */
};
int
__flt_rounds()
{
int x;
__asm__("cfc1 %0,$31" : "=r" (x));
return map[x & 0x03];
}

View File

@ -0,0 +1,15 @@
/*
* Written by J.T. Conklin, Apr 11, 1995
* Public domain.
*/
#include <ieeefp.h>
fp_except
fpgetmask()
{
int x;
__asm__("cfc1 %0,$31" : "=r" (x));
return (x >> 7) & 0x1f;
}

View File

@ -0,0 +1,15 @@
/*
* Written by J.T. Conklin, Apr 11, 1995
* Public domain.
*/
#include <ieeefp.h>
fp_rnd
fpgetround()
{
int x;
__asm__("cfc1 %0,$31" : "=r" (x));
return x & 0x03;
}

View File

@ -0,0 +1,15 @@
/*
* Written by J.T. Conklin, Apr 11, 1995
* Public domain.
*/
#include <ieeefp.h>
fp_except
fpgetsticky()
{
int x;
__asm__("cfc1 %0,$31" : "=r" (x));
return (x >> 2) & 0x1f;
}

View File

@ -0,0 +1,24 @@
/*
* Written by J.T. Conklin, Apr 11, 1995
* Public domain.
*/
#include <ieeefp.h>
fp_except
fpsetmask(mask)
fp_except mask;
{
fp_except old;
fp_except new;
__asm__("cfc1 %0,$31" : "=r" (old));
new = old;
new &= ~(0x1f << 7);
new |= ((mask & 0x1f) << 7);
__asm__("ctc1 %0,$31" : : "r" (new));
return (old >> 7) & 0x1f;
}

View File

@ -0,0 +1,24 @@
/*
* Written by J.T. Conklin, Apr 11, 1995
* Public domain.
*/
#include <ieeefp.h>
fp_rnd
fpsetround(rnd_dir)
fp_rnd rnd_dir;
{
fp_rnd old;
fp_rnd new;
__asm__("cfc1 %0,$31" : "=r" (old));
new = old;
new &= ~0x03;
new |= (rnd_dir & 0x03);
__asm__("ctc1 %0,$31" : : "r" (new));
return old & 0x03;
}

View File

@ -0,0 +1,24 @@
/*
* Written by J.T. Conklin, Apr 11, 1995
* Public domain.
*/
#include <ieeefp.h>
fp_except
fpsetsticky(sticky)
fp_except sticky;
{
fp_except old;
fp_except new;
__asm__("cfc1 %0,$31" : "=r" (old));
new = old;
new &= ~(0x1f << 2);
new |= ((sticky & 0x1f) << 2);
__asm__("ctc1 %0,$31" : : "r" (new));
return (old >> 2) & 0x1f;
}