Added __flt_rounds, fp{get,set}{mask,round,sticky}.
This commit is contained in:
parent
01194e13e9
commit
53bd3d0603
@ -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
|
||||
|
20
lib/libc/arch/mips/gen/flt_rounds.c
Normal file
20
lib/libc/arch/mips/gen/flt_rounds.c
Normal 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];
|
||||
}
|
15
lib/libc/arch/mips/gen/fpgetmask.c
Normal file
15
lib/libc/arch/mips/gen/fpgetmask.c
Normal 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;
|
||||
}
|
15
lib/libc/arch/mips/gen/fpgetround.c
Normal file
15
lib/libc/arch/mips/gen/fpgetround.c
Normal 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;
|
||||
}
|
15
lib/libc/arch/mips/gen/fpgetsticky.c
Normal file
15
lib/libc/arch/mips/gen/fpgetsticky.c
Normal 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;
|
||||
}
|
24
lib/libc/arch/mips/gen/fpsetmask.c
Normal file
24
lib/libc/arch/mips/gen/fpsetmask.c
Normal 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;
|
||||
}
|
24
lib/libc/arch/mips/gen/fpsetround.c
Normal file
24
lib/libc/arch/mips/gen/fpsetround.c
Normal 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;
|
||||
}
|
24
lib/libc/arch/mips/gen/fpsetsticky.c
Normal file
24
lib/libc/arch/mips/gen/fpsetsticky.c
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user