xref: /netbsd-src/sys/arch/powerpc/include/ieeefp.h (revision 7e30e94394d0994ab9534f68a8f91665045c91ce)
1 /*	$NetBSD: ieeefp.h,v 1.7 2017/03/22 23:11:09 chs Exp $	*/
2 
3 /*
4  * Written by J.T. Conklin, Apr 6, 1995
5  * Public domain.
6  */
7 
8 #ifndef _POWERPC_IEEEFP_H_
9 #define _POWERPC_IEEEFP_H_
10 
11 #include <sys/featuretest.h>
12 
13 #if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE)
14 
15 #include <powerpc/fenv.h>
16 
17 #if !defined(_ISOC99_SOURCE)
18 
19 typedef int fp_except;
20 
21 /* adjust for FP_* and FE_* value differences */
22 #define	__FPE(x) ((x) >> 25)
23 #define	__FEE(x) ((x) << 25)
24 #define	__FPR(x) ((x))
25 #define	__FER(x) ((x))
26 
27 #define FP_X_IMP	__FPE(FE_INEXACT)	/* imprecise (loss of precision) */
28 #define FP_X_DZ		__FPE(FE_DIVBYZERO)	/* divide-by-zero exception */
29 #define FP_X_UFL	__FPE(FE_UNDERFLOW)	/* underflow exception */
30 #define FP_X_OFL	__FPE(FE_OVERFLOW)	/* overflow exception */
31 #define FP_X_INV	__FPE(FE_INVALID)	/* invalid operation exception */
32 
33 typedef enum {
34     FP_RN=__FPR(FE_TONEAREST),	/* round to nearest representable number */
35     FP_RZ=__FPR(FE_TOWARDZERO),	/* round to zero (truncate) */
36     FP_RP=__FPR(FE_UPWARD),	/* round toward positive infinity */
37     FP_RM=__FPR(FE_DOWNWARD)	/* round toward negative infinity */
38 } fp_rnd;
39 
40 #endif /* !_ISOC99_SOURCE */
41 
42 #endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */
43 
44 #endif /* _POWERPC_IEEEFP_H_ */
45