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:
parent
69c3f107e2
commit
6bea77d590
@ -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
|
||||
|
22
lib/libc/sparc64/gen/fpgetmask.c
Normal file
22
lib/libc/sparc64/gen/fpgetmask.c
Normal 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));
|
||||
}
|
21
lib/libc/sparc64/gen/fpgetround.c
Normal file
21
lib/libc/sparc64/gen/fpgetround.c
Normal 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));
|
||||
}
|
21
lib/libc/sparc64/gen/fpgetsticky.c
Normal file
21
lib/libc/sparc64/gen/fpgetsticky.c
Normal 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));
|
||||
}
|
30
lib/libc/sparc64/gen/fpsetround.c
Normal file
30
lib/libc/sparc64/gen/fpsetround.c
Normal 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));
|
||||
}
|
30
lib/libc/sparc64/gen/fpsetsticky.c
Normal file
30
lib/libc/sparc64/gen/fpsetsticky.c
Normal 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));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user