Home | History | Annotate | Line # | Download | only in include
fenv.h revision 1.4
      1 /*	$NetBSD: fenv.h,v 1.4 2017/03/22 23:11:09 chs Exp $	*/
      2 
      3 /*
      4  * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995
      5  * Public domain.
      6  */
      7 
      8 #ifndef _ARM_FENV_H_
      9 #define _ARM_FENV_H_
     10 
     11 #include <sys/cdefs.h>
     12 
     13 #ifdef __ARM_PCS_AAPCS64
     14 /* AArch64 split FPSCR into two registers FPCR and FPSR */
     15 typedef struct {
     16 	unsigned int __fpcr;
     17 	unsigned int __fpsr;
     18 } fenv_t;
     19 #else
     20 typedef int fenv_t;		/* FPSCR */
     21 #endif
     22 typedef int fexcept_t;
     23 
     24 #define	FE_INVALID	0x01	/* invalid operation exception */
     25 #define	FE_DIVBYZERO	0x02	/* divide-by-zero exception */
     26 #define	FE_OVERFLOW	0x04	/* overflow exception */
     27 #define	FE_UNDERFLOW	0x08	/* underflow exception */
     28 #define	FE_INEXACT	0x10	/* imprecise (loss of precision; "inexact") */
     29 
     30 #define	FE_ALL_EXCEPT	0x1f
     31 
     32 #define	FE_TONEAREST	0	/* round to nearest representable number */
     33 #define	FE_UPWARD	1	/* round toward positive infinity */
     34 #define	FE_DOWNWARD	2	/* round toward negative infinity */
     35 #define	FE_TOWARDZERO	3	/* round to zero (truncate) */
     36 
     37 #ifdef __SOFTFP__
     38 
     39 /*
     40  * Provide a platform-specific softfloat ABI.
     41  */
     42 
     43 #include <arm/vfpreg.h>
     44 
     45 typedef int fenv_t;
     46 #define __FENV_GET_FLAGS(__envp)	__SHIFTOUT(*(__envp), VFP_FPSCR_CSUM)
     47 #define __FENV_GET_MASK(__envp)		__SHIFTOUT(*(__envp), VFP_FPSCR_ESUM)
     48 #define __FENV_GET_ROUND(__envp)	__SHIFTOUT(*(__envp), VFP_FPSCR_RMODE)
     49 #define __FENV_SET_FLAGS(__envp, __val) \
     50 	*(__envp) = __SHIFTIN((__val), VFP_FPSCR_CSUM)
     51 #define __FENV_SET_MASK(__envp, __val) \
     52 	*(__envp) = __SHIFTIN((__val), VFP_FPSCR_ESUM)
     53 #define __FENV_SET_ROUND(__envp, __val) \
     54 	*(__envp) = __SHIFTIN((__val), VFP_FPSCR_RMODE)
     55 
     56 #define __HAVE_FENV_SOFTFLOAT_DEFS
     57 
     58 #endif /* __SOFTFP__ */
     59 
     60 __BEGIN_DECLS
     61 
     62 /* Default floating-point environment */
     63 extern const fenv_t	__fe_dfl_env;
     64 #define FE_DFL_ENV	(&__fe_dfl_env)
     65 
     66 __END_DECLS
     67 
     68 #endif /* _ARM_FENV_H_ */
     69