summaryrefslogtreecommitdiff
path: root/lib/libc/arch/ns32k/gen/fpgetsticky.c
blob: 86771541ab64f3779e1c88d22a10e724b847c9ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*	$OpenBSD: fpgetsticky.c,v 1.1 1996/04/21 23:38:41 deraadt Exp $	*/

/*
 * Written by J.T. Conklin, Apr 11, 1995
 * Public domain.
 */

#include <ieeefp.h>
#include <machine/cpufunc.h>
#include <machine/fpu.h>

fp_except
fpgetsticky()
{
	fp_except x;
	fp_except ebits = FPC_IEN | FPC_OVE | FPC_IVE | FPC_DZE | FPC_UNDE;

	sfsr(x);
	/* Map FPC_UF to soft underflow enable */
	if (x & FPC_UF)
		x |= FPC_UNDE << 1;
	else
		x &= ~(FPC_UNDE << 1);
	x >>= 1;

	return x & ebits;
}