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