1 /* $NetBSD: ieeefp.h,v 1.10 2016/08/25 07:39:55 christos 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 #include <sys/featuretest.h>
12 
13 #if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE)
14 
15 #include <machine/fenv.h>
16 
17 #if !defined(_ISOC99_SOURCE)
18 
19 typedef int fp_except;
20 
21 #if defined(_KERNEL)
22 
23 #include <sys/param.h>
24 #include <sys/proc.h>
25 #include <machine/fpu.h>
26 #include <machine/alpha.h>
27 
28 /* FP_X_IOV is intentionally omitted from the architecture flags mask */
29 
30 #define   FP_AA_FLAGS (FP_X_INV | FP_X_DZ | FP_X_OFL | FP_X_UFL | FP_X_IMP)
31 
32 #define float_raise(f)                                                          \
33           do curlwp->l_md.md_flags |= NETBSD_FLAG_TO_FP_C(f);         \
34           while(0)
35 
36 #define float_set_inexact()   float_raise(FP_X_IMP)
37 #define float_set_invalid()   float_raise(FP_X_INV)
38 #define   fpgetround()                  (alpha_read_fpcr() >> 58 & 3)
39 
40 #endif /* _KERNEL */
41 
42 #define   FP_X_INV  FE_INVALID          /* invalid operation exception */
43 #define   FP_X_DZ             FE_DIVBYZERO        /* divide-by-zero exception */
44 #define   FP_X_OFL  FE_OVERFLOW         /* overflow exception */
45 #define   FP_X_UFL  FE_UNDERFLOW        /* underflow exception */
46 #define   FP_X_IMP  FE_INEXACT          /* imprecise (prec. loss; "inexact") */
47 #define   FP_X_IOV  FE_INTOVF /* integer overflow */
48 
49 /*
50  * fp_rnd bits match the fpcr, below, as well as bits 12:11
51  * in fp operate instructions
52  */
53 typedef enum {
54     FP_RZ = FE_TOWARDZERO,    /* round to zero (truncate) */
55     FP_RM = FE_DOWNWARD,      /* round toward negative infinity */
56     FP_RN = FE_TONEAREST,     /* round to nearest representable number */
57     FP_RP = FE_UPWARD,                  /* round toward positive infinity */
58     _FP_DYNAMIC=FP_RP
59 } fp_rnd;
60 
61 #endif /* !_ISOC99_SOURCE */
62 
63 #endif    /* _NETBSD_SOURCE || _ISOC99_SOURCE */
64 
65 #endif /* _ALPHA_IEEEFP_H_ */
66