Add implementations of fpgetmask(), fpgetround(), fpgetsticky(),

fpsetround(), fpsetsticky(), obtained from NetBSD and tweaked a little
to use definitions from machine/fsr.h instead of magic numbers.
This commit is contained in:
Thomas Moestl 2002-09-14 18:06:21 +00:00
parent ac9e4b5aea
commit 8579151e4b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=103323
6 changed files with 126 additions and 1 deletions

View File

@ -1,4 +1,5 @@
# $FreeBSD$
SRCS+= _setjmp.S fabs.S fixunsdfsi.S flt_rounds.c fpsetmask.c frexp.c \
SRCS+= _setjmp.S fabs.S fixunsdfsi.S flt_rounds.c fpgetmask.c fpgetround.c \
fpgetsticky.c fpsetmask.c fpsetround.c fpsetsticky.c frexp.c \
infinity.c isinf.c ldexp.c modf.S setjmp.S sigsetjmp.S

View File

@ -0,0 +1,22 @@
/* $NetBSD: fpgetmask.c,v 1.2 2002/01/13 21:45:50 thorpej Exp $ */
/*
* Written by J.T. Conklin, Apr 10, 1995
* Public domain.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <machine/fsr.h>
#include <ieeefp.h>
fp_except_t
fpgetmask()
{
unsigned int x;
__asm__("st %%fsr,%0" : "=m" (x));
return (FSR_GET_TEM(x));
}

View File

@ -0,0 +1,21 @@
/* $NetBSD: fpgetround.c,v 1.2 2002/01/13 21:45:50 thorpej Exp $ */
/*
* Written by J.T. Conklin, Apr 10, 1995
* Public domain.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <machine/fsr.h>
#include <ieeefp.h>
fp_rnd_t
fpgetround()
{
unsigned int x;
__asm__("st %%fsr,%0" : "=m" (x));
return ((fp_rnd_t)FSR_GET_RD(x));
}

View File

@ -0,0 +1,21 @@
/* $NetBSD: fpgetsticky.c,v 1.2 2002/01/13 21:45:50 thorpej Exp $ */
/*
* Written by J.T. Conklin, Apr 10, 1995
* Public domain.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <machine/fsr.h>
#include <ieeefp.h>
fp_except_t
fpgetsticky()
{
unsigned int x;
__asm__("st %%fsr,%0" : "=m" (x));
return (FSR_GET_AEXC(x));
}

View File

@ -0,0 +1,30 @@
/* $NetBSD: fpsetround.c,v 1.2 2002/01/13 21:45:51 thorpej Exp $ */
/*
* Written by J.T. Conklin, Apr 10, 1995
* Public domain.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <machine/fsr.h>
#include <ieeefp.h>
fp_rnd_t
fpsetround(rnd_dir)
fp_rnd_t rnd_dir;
{
unsigned int old;
unsigned int new;
__asm__("st %%fsr,%0" : "=m" (old));
new = old;
new &= ~FSR_RD_MASK;
new |= FSR_RD((unsigned int)rnd_dir & 0x03);
__asm__("ld %0,%%fsr" : : "m" (new));
return ((fp_rnd_t)FSR_GET_RD(old));
}

View File

@ -0,0 +1,30 @@
/* $NetBSD: fpsetsticky.c,v 1.2 2002/01/13 21:45:51 thorpej Exp $ */
/*
* Written by J.T. Conklin, Apr 10, 1995
* Public domain.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <machine/fsr.h>
#include <ieeefp.h>
fp_except_t
fpsetsticky(sticky)
fp_except_t sticky;
{
unsigned int old;
unsigned int new;
__asm__("st %%fsr,%0" : "=m" (old));
new = old;
new &= ~FSR_AEXC_MASK;
new |= FSR_AEXC(sticky & FSR_EXC_MASK);
__asm__("ld %0,%%fsr" : : "m" (new));
return (FSR_GET_AEXC(old));
}