xref: /netbsd/sys/arch/arm/include/ieeefp.h (revision 6550d01e)
1 /*	$NetBSD: ieeefp.h,v 1.2 2008/08/05 16:47:41 matt Exp $	*/
2 
3 /*
4  * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995
5  * Public domain.
6  */
7 
8 #ifndef _ARM32_IEEEFP_H_
9 #define _ARM32_IEEEFP_H_
10 
11 #include <sys/featuretest.h>
12 
13 #if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE)
14 
15 typedef int fenv_t;
16 typedef int fexcept_t;
17 
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 
24 #define	FE_ALL_EXCEPT	0x1f
25 
26 #define	FE_TONEAREST	0	/* round to nearest representable number */
27 #define	FE_UPWARD	1	/* round toward positive infinity */
28 #define	FE_DOWNWARD	2	/* round toward negative infinity */
29 #define	FE_TOWARDZERO	3	/* round to zero (truncate) */
30 
31 #if !defined(_ISOC99_SOURCE)
32 
33 /* Exception type (used by fpsetmask() et al.) */
34 
35 typedef int fp_except;
36 
37 /* Bit defines for fp_except */
38 
39 #define	FP_X_INV	FE_INVALID	/* invalid operation exception */
40 #define	FP_X_DZ		FE_DIVBYZERO	/* divide-by-zero exception */
41 #define	FP_X_OFL	FE_OVERFLOW	/* overflow exception */
42 #define	FP_X_UFL	FE_UNDERFLOW	/* underflow exception */
43 #define	FP_X_IMP	FE_INEXACT	/* imprecise (prec. loss; "inexact") */
44 
45 /* Rounding modes */
46 
47 typedef enum {
48     FP_RN=FE_TONEAREST,		/* round to nearest representable number */
49     FP_RP=FE_UPWARD,		/* round toward positive infinity */
50     FP_RM=FE_DOWNWARD,		/* round toward negative infinity */
51     FP_RZ=FE_TOWARDZERO		/* round to zero (truncate) */
52 } fp_rnd;
53 
54 #endif /* !_ISOC99_SOURCE */
55 
56 #endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */
57 
58 #endif /* _ARM32_IEEEFP_H_ */
59