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