xref: /netbsd/sys/arch/alpha/include/ieeefp.h (revision bf9ec67e)
1 /* $NetBSD: ieeefp.h,v 1.4 2001/04/26 03:10:46 ross Exp $ */
2 
3 /*
4  * Written by J.T. Conklin, Apr 28, 1995
5  * Public domain.
6  */
7 
8 #ifndef _ALPHA_IEEEFP_H_
9 #define _ALPHA_IEEEFP_H_
10 
11 typedef int fp_except;
12 
13 #ifdef _KERNEL
14 
15 #include <sys/param.h>
16 #include <sys/proc.h>
17 #include <machine/fpu.h>
18 #include <machine/alpha.h>
19 
20 /* FP_X_IOV is intentionally omitted from the architecture flags mask */
21 
22 #define	FP_AA_FLAGS (FP_X_INV | FP_X_DZ | FP_X_OFL | FP_X_UFL | FP_X_IMP)
23 
24 #define float_raise(f)						\
25 	do curproc->p_md.md_flags |= NETBSD_FLAG_TO_FP_C(f);	\
26 	while(0)
27 
28 #define float_set_inexact()	float_raise(FP_X_IMP)
29 #define float_set_invalid()	float_raise(FP_X_INV)
30 #define	fpgetround()		(alpha_read_fpcr() >> 58 & 3)
31 
32 #endif
33 
34 #define	FP_X_INV	0x01	/* invalid operation exception */
35 #define	FP_X_DZ		0x02	/* divide-by-zero exception */
36 #define	FP_X_OFL	0x04	/* overflow exception */
37 #define	FP_X_UFL	0x08	/* underflow exception */
38 #define	FP_X_IMP	0x10	/* imprecise (loss of precision; "inexact") */
39 #define	FP_X_IOV	0x20    /* integer overflow */
40 
41 /*
42  * fp_rnd bits match the fpcr, below, as well as bits 12:11
43  * in fp operate instructions
44  */
45 typedef enum {
46     FP_RZ = 0,			/* round to zero (truncate) */
47     FP_RM = 1,			/* round toward negative infinity */
48     FP_RN = 2,			/* round to nearest representable number */
49     FP_RP = 3,			/* round toward positive infinity */
50     _FP_DYNAMIC=FP_RP
51 } fp_rnd;
52 
53 #endif /* _ALPHA_IEEEFP_H_ */
54