1 /* $NetBSD: ieeefp.h,v 1.6 2008/08/05 16:47:41 matt Exp $ */
4 * Written by J.T. Conklin, Apr 28, 1995
8 #ifndef _ALPHA_IEEEFP_H_
9 #define _ALPHA_IEEEFP_H_
11 #include <sys/featuretest.h>
13 #if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE)
16 typedef int fexcept_t
;
18 #define FE_INVALID 0x01 /* invalid operation exception */
19 #define FE_DIVBYZERO 0x02 /* divide-by-zero exception */
20 #define FE_OVERFLOW 0x04 /* overflow exception */
21 #define FE_UNDERFLOW 0x08 /* underflow exception */
22 #define FE_INEXACT 0x10 /* imprecise (loss of precision; "inexact") */
23 #define FE_IOVERFLOW 0x20 /* integer overflow */
25 #define FE_ALL_EXCEPT 0x3f
28 * These bits match the fpcr as well as bits 12:11
29 * in fp operate instructions
31 #define FE_TOWARDZERO 0 /* round to zero (truncate) */
32 #define FE_DOWNWARD 1 /* round toward negative infinity */
33 #define FE_TONEAREST 2 /* round to nearest representable number */
34 #define FE_UPWARD 3 /* round toward positive infinity */
36 #if !defined(_ISOC99_SOURCE)
38 typedef int fp_except
;
42 #include <sys/param.h>
44 #include <machine/fpu.h>
45 #include <machine/alpha.h>
47 /* FP_X_IOV is intentionally omitted from the architecture flags mask */
49 #define FP_AA_FLAGS (FP_X_INV | FP_X_DZ | FP_X_OFL | FP_X_UFL | FP_X_IMP)
51 #define float_raise(f) \
52 do curlwp->l_md.md_flags |= NETBSD_FLAG_TO_FP_C(f); \
55 #define float_set_inexact() float_raise(FP_X_IMP)
56 #define float_set_invalid() float_raise(FP_X_INV)
57 #define fpgetround() (alpha_read_fpcr() >> 58 & 3)
61 #define FP_X_INV FE_INVALID /* invalid operation exception */
62 #define FP_X_DZ FE_DIVBYZERO /* divide-by-zero exception */
63 #define FP_X_OFL FE_OVERFLOW /* overflow exception */
64 #define FP_X_UFL FE_UNDERFLOW /* underflow exception */
65 #define FP_X_IMP FE_INEXACT /* imprecise (prec. loss; "inexact") */
66 #define FP_X_IOV FE_IOVERFLOW /* integer overflow */
69 * fp_rnd bits match the fpcr, below, as well as bits 12:11
70 * in fp operate instructions
73 FP_RZ
= FE_TOWARDZERO
, /* round to zero (truncate) */
74 FP_RM
= FE_DOWNWARD
, /* round toward negative infinity */
75 FP_RN
= FE_TONEAREST
, /* round to nearest representable number */
76 FP_RP
= FE_UPWARD
, /* round toward positive infinity */
80 #endif /* !_ISOC99_SOURCE */
82 #endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */
84 #endif /* _ALPHA_IEEEFP_H_ */