* New MI man page for fp{set,get}{round,sticky,mask}(3).

* Implement fpgetsticky() for alpha.
* Direct fpsetsticky() and fp{get,set}mask() into alpha kernel via sysarch(2).
* Define new sysarch(2) stub for above and install and distribute sysarch.h
for alpha.  (The fpcr IS user mode r/w, but for reasons beyond the scope
of a commit message kernel calls are needed.) And much kernel Magick is
required before these do anything, but this way programs compiled under
1.4 will DTRT on future snapshots and releases.
This commit is contained in:
ross 1999-04-30 00:58:30 +00:00
parent bf92a11622
commit c5a82dd848
11 changed files with 222 additions and 33 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: md.alpha,v 1.18 1999/04/19 04:20:13 ross Exp $
# $NetBSD: md.alpha,v 1.19 1999/04/30 00:58:30 ross Exp $
./usr/include/alpha
./usr/include/alpha/_G_config.h
./usr/include/alpha/alpha_cpu.h
@ -49,3 +49,4 @@
./usr/include/alpha/vmparam.h
./usr/include/alpha/vuid_event.h
./usr/include/alpha/z8530var.h
./usr/include/alpha/sysarch.h

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.136 1999/04/19 03:11:34 simonb Exp $
# $NetBSD: mi,v 1.137 1999/04/30 00:58:30 ross Exp $
./sys
./usr/bin/ar
./usr/bin/as
@ -1562,7 +1562,13 @@
./usr/share/man/cat3/fopen.0
./usr/share/man/cat3/forkpty.0
./usr/share/man/cat3/fparseln.0
./usr/share/man/cat3/fpgetmask.0
./usr/share/man/cat3/fpgetround.0
./usr/share/man/cat3/fpgetsticky.0
./usr/share/man/cat3/fprintf.0
./usr/share/man/cat3/fpsetmask.0
./usr/share/man/cat3/fpsetround.0
./usr/share/man/cat3/fpsetsticky.0
./usr/share/man/cat3/fpurge.0
./usr/share/man/cat3/fputc.0
./usr/share/man/cat3/fputs.0
@ -2606,7 +2612,13 @@
./usr/share/man/man3/fopen.3
./usr/share/man/man3/forkpty.3
./usr/share/man/man3/fparseln.3
./usr/share/man/man3/fpgetmask.3
./usr/share/man/man3/fpgetround.3
./usr/share/man/man3/fpgetsticky.3
./usr/share/man/man3/fprintf.3
./usr/share/man/man3/fpsetmask.3
./usr/share/man/man3/fpsetround.3
./usr/share/man/man3/fpsetsticky.3
./usr/share/man/man3/fpurge.3
./usr/share/man/man3/fputc.3
./usr/share/man/man3/fputs.3

View File

@ -1,7 +1,7 @@
/* $NetBSD: fpgetmask.c,v 1.1 1995/04/29 05:10:55 cgd Exp $ */
/* $NetBSD: fpgetmask.c,v 1.2 1999/04/30 00:58:31 ross Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou
* Copyright (c) 1999 Ross Harvey
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -14,7 +14,7 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Christopher G. Demetriou
* This product includes software developed by Ross Harvey
* for the NetBSD Project.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
@ -32,11 +32,10 @@
*/
#include <ieeefp.h>
#include <machine/sysarch.h>
fp_except
fpgetmask()
fpgetmask __P((void))
{
/* XXX */
abort();
return sysarch(ALPHA_FPGETMASK, (void *)0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: fpgetsticky.c,v 1.1 1995/04/29 05:10:59 cgd Exp $ */
/* $NetBSD: fpgetsticky.c,v 1.2 1999/04/30 00:58:31 ross Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou
@ -31,12 +31,19 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <ieeefp.h>
fp_except
fpgetsticky()
fpgetsticky __P((void))
{
double fpcrval;
u_int64_t old;
/* XXX */
abort();
__asm__("trapb");
__asm__("mf_fpcr %0" : "=f" (fpcrval));
__asm__("trapb");
old = *(u_int64_t *)&fpcrval;
return (old >> 52) & 0x3f;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: fpsetmask.c,v 1.1 1995/04/29 05:11:01 cgd Exp $ */
/* $NetBSD: fpsetmask.c,v 1.2 1999/04/30 00:58:31 ross Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou
* Copyright (c) 1995 Ross Harvey
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -14,7 +14,7 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Christopher G. Demetriou
* This product includes software developed by Ross Harvey
* for the NetBSD Project.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
@ -32,12 +32,14 @@
*/
#include <ieeefp.h>
#include <machine/sysarch.h>
fp_except
fpsetmask(mask)
fp_except mask;
{
struct alpha_fp_except_args a;
/* XXX */
abort();
a.mask = mask;
return sysarch(ALPHA_FPSETMASK, &a);
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: fpsetsticky.c,v 1.1 1995/04/29 05:11:04 cgd Exp $ */
/* $NetBSD: fpsetsticky.c,v 1.2 1999/04/30 00:58:31 ross Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou
* Copyright (c) 1999 Ross Harvey
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -14,7 +14,7 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Christopher G. Demetriou
* This product includes software developed by Ross Harvey
* for the NetBSD Project.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
@ -32,12 +32,14 @@
*/
#include <ieeefp.h>
#include <machine/sysarch.h>
fp_except
fpsetsticky(sticky)
fp_except sticky;
{
struct alpha_fp_except_args a;
/* XXX */
abort();
a.mask = sticky;
return sysarch(ALPHA_FPSETSTICKY, &a);
}

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.97 1999/02/24 15:05:20 drochner Exp $
# $NetBSD: Makefile.inc,v 1.98 1999/04/30 00:58:31 ross Exp $
# from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95
# gen sources
@ -38,7 +38,7 @@ SRCS+= _err.c _errx.c _sys_errlist.c _sys_nerr.c _sys_siglist.c \
MAN+= alarm.3 basename.3 bswap.3 clock.3 confstr.3 ctermid.3 ctype.3 \
daemon.3 devname.3 directory.3 dirname.3 err.3 exec.3 \
fnmatch.3 frexp.3 ftok.3 fts.3 getbsize.3 getcap.3 \
fnmatch.3 fpgetmask.3 frexp.3 ftok.3 fts.3 getbsize.3 getcap.3 \
getcwd.3 getdomainname.3 getdiskbyname.3 getfsent.3 \
getgrent.3 getgrouplist.3 gethostname.3 getloadavg.3 \
getmntinfo.3 getnetgrent.3 getpagesize.3 getpass.3 \
@ -53,6 +53,7 @@ MAN+= alarm.3 basename.3 bswap.3 clock.3 confstr.3 ctermid.3 ctype.3 \
timezone.3 toascii.3 tolower.3 toupper.3 ttyname.3 \
ualarm.3 uname.3 unvis.3 usleep.3 utime.3 valloc.3 vis.3
MLINKS+=fpgetround.3 fpgetsticky.3 fpsetmask.3 fpsetround.3 fpsetsticky.3
MLINKS+=bswap.3 bswap16.3
MLINKS+=bswap.3 bswap32.3
MLINKS+=bswap.3 bswap64.3

131
lib/libc/gen/fpgetmask.3 Normal file
View File

@ -0,0 +1,131 @@
.\" $NetBSD: fpgetmask.3,v 1.1 1999/04/30 00:58:31 ross Exp $
.\"
.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Ross Harvey.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the NetBSD
.\" Foundation, Inc. and its contributors.
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
.\" contributors may be used to endorse or promote products derived
.\" from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd April 29, 1999
.Dt FPGETMASK 3
.Os
.Sh NAME
.Nm fpgetmask ,
.Nm fpgetround ,
.Nm fpgetsticky ,
.Nm fpsetmask ,
.Nm fpsetround ,
.Nm fpsetsticky
.Nd IEEE FP mode control
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.Fd #include <ieeefp.h>
.Ft fp_except
.Fn fpgetmask void
.Ft fp_rnd
.Fn fpgetround void
.Ft fp_except
.Fn fpgetsticky void
.Ft fp_except
.Fn fpsetmask fp_except\ mask
.Ft fp_rnd
.Fn fpsetround fp_rnd\ rnd_dir
.Ft fp_except
.Fn fpsetsticky fp_except\ sticky
.Sh DESCRIPTION
A rounding mode is one of
.Dv FP_RZ , FP_RM , FP_RN ,
or
.Dv FP_RP ,
for rounding towards zero, rounding
.Pq Em Minus infinity
down, rounding to
.Em nearest ,
and rounding
.Pq Em Plus infinity
up.
The default mode is
.Dv FP_RN .
.Pp
An
.Ft fp_except
value is a bitmask specifying an exception type and containing any of
the values listed below.
.Bl -column -offset indent FP_X_UFLxx
.It Dv FP_X_INV Ta Invalid\ Operation
.It Dv FP_X_DZ Ta Division\ by\ zero
.It Dv FP_X_OFL Ta Overflow
.It Dv FP_X_UFL Ta Underflow
.It Dv FP_X_IMP Ta Imprecision (inexact)
.It Dv FP_X_IOV Ta Integer\ Overflow
.El
.Pp
.Pp
The
.Fn fpsetmask
function will cause future operations with the specified result status to
raise the
.Dv SIGFPE
exception.
The
.Fn fpsetround
function will cause future operations to use the specified dynamic mode.
.Bl -tag -width Note:x
.It Em Note:
On some architectures, instructions can optionally specify static
rounding modes and exception enables that will supersede the specified
dynamic mode. On other architectures, these features may not be fully
supported.
.El
.Pp
The
.Fn fpsetsticky
function will set or clear the specified exception history bits.
.Sh RETURN VALUES
The
.Fn fpgetround
and
.Fn fpsetround
functions return the
.Pq previous
rounding mode.
The
.Fn fpgetmask ,
.Fn fpsetmask ,
.Fn fpgetsticky ,
and
.Fn fpsetsticky
functions return the
.Pq previous
exception mask and exception history bits.
.Sh SEE ALSO
.Xr sigaction 2

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys_machdep.c,v 1.9 1998/02/25 21:41:55 perry Exp $ */
/* $NetBSD: sys_machdep.c,v 1.10 1999/04/30 00:58:31 ross Exp $ */
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@ -29,13 +29,14 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.9 1998/02/25 21:41:55 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.10 1999/04/30 00:58:31 ross Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
#include <machine/sysarch.h>
int
sys_sysarch(p, v, retval)
@ -43,12 +44,22 @@ sys_sysarch(p, v, retval)
void *v;
register_t *retval;
{
#if 0
struct sys_sysarch_args /* {
syscallarg(int) op;
syscallarg(void *) parms;
} */ *uap = v;
#endif
int error = 0;
return (ENOSYS);
switch(SCARG(uap, op)) {
case ALPHA_FPGETMASK:
case ALPHA_FPSETMASK:
case ALPHA_FPSETSTICKY:
/* XXX kernel Magick required here */
break;
default:
error = EINVAL;
break;
}
return error;
}

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.3 1999/04/17 13:00:04 drochner Exp $
# $NetBSD: Makefile,v 1.4 1999/04/30 00:58:32 ross Exp $
KDIR= /sys/arch/alpha/include
INCSDIR= /usr/include/alpha
@ -8,7 +8,7 @@ INCS= alpha_cpu.h ansi.h aout_machdep.h asm.h autoconf.h bswap.h bus.h \
ecoff_machdep.h elf_machdep.h endian.h fbio.h float.h frame.h ieee.h \
ieeefp.h intr.h intrcnt.h kbio.h kcore.h limits.h pal.h param.h pcb.h \
pmap.h proc.h profile.h prom.h psl.h pte.h ptrace.h reg.h rpb.h \
setjmp.h sfbreg.h signal.h stdarg.h types.h varargs.h vmparam.h \
vuid_event.h z8530var.h
setjmp.h sfbreg.h signal.h stdarg.h sysarch.h types.h varargs.h \
vmparam.h vuid_event.h z8530var.h
.include <bsd.kinc.mk>

View File

@ -0,0 +1,23 @@
/* $NetBSD: sysarch.h,v 1.3 1999/04/30 00:58:32 ross Exp $ */
#ifndef _ALPHA_SYSARCH_H_
#define _ALPHA_SYSARCH_H_
#include <machine/ieeefp.h>
/*
* Architecture specific syscalls (ALPHA)
*/
#define ALPHA_FPGETMASK 0
#define ALPHA_FPSETMASK 1
#define ALPHA_FPSETSTICKY 2
struct alpha_fp_except_args {
fp_except mask;
};
#ifndef _KERNEL
int sysarch __P((int, void *));
#endif
#endif /* !_ALPHA_SYSARCH_H_ */