| 1 | /*	$NetBSD: ieeefp.h,v 1.11 2023/09/26 12:46:30 tsutsui Exp $	*/ |
| 2 | |
| 3 | /* |
| 4 | * Written by J.T. Conklin, Apr 6, 1995 |
| 5 | * Modified by Jason R. Thorpe, June 22, 2003 |
| 6 | * Public domain. |
| 7 | */ |
| 8 | |
| 9 | #ifndef _M68K_IEEEFP_H_ |
| 10 | #define _M68K_IEEEFP_H_ |
| 11 | |
| 12 | #include <sys/featuretest.h> |
| 13 | |
| 14 | #if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE) |
| 15 | |
| 16 | #include <m68k/fenv.h> |
| 17 | |
| 18 | #if !defined(_ISOC99_SOURCE) |
| 19 | |
| 20 | typedef int fp_except; |
| 21 | |
| 22 | /* adjust for FP_* and FE_* value differences */ |
| 23 | #define	__FPE(x) ((x) >> 3) |
| 24 | #define	__FEE(x) ((x) << 3) |
| 25 | #define	__FPR(x) ((x) >> 4) |
| 26 | #define	__FER(x) ((x) << 4) |
| 27 | |
| 28 | #define FP_X_IMP	__FPE(FE_INEXACT)	/* imprecise (loss of precision) */ |
| 29 | #define FP_X_DZ		__FPE(FE_DIVBYZERO)	/* divide-by-zero exception */ |
| 30 | #define FP_X_UFL	__FPE(FE_UNDERFLOW)	/* underflow exception */ |
| 31 | #define FP_X_OFL	__FPE(FE_OVERFLOW)	/* overflow exception */ |
| 32 | #define FP_X_INV	__FPE(FE_INVALID)	/* invalid operation exception */ |
| 33 | |
| 34 | typedef enum { |
| 35 | FP_RN=__FPR(FE_TONEAREST),	/* round to nearest representable number */ |
| 36 | FP_RZ=__FPR(FE_TOWARDZERO),	/* round to zero (truncate) */ |
| 37 | FP_RM=__FPR(FE_DOWNWARD),	/* round toward negative infinity */ |
| 38 | FP_RP=__FPR(FE_UPWARD)	/* round toward positive infinity */ |
| 39 | } fp_rnd; |
| 40 | |
| 41 | typedef enum { |
| 42 | FP_PE=0,			/* extended-precision (64-bit) */ |
| 43 | FP_PS=1,			/* single-precision (24-bit) */ |
| 44 | FP_PD=2			/* double-precision (53-bit) */ |
| 45 | } fp_prec; |
| 46 | |
| 47 | #endif /* !_ISOC99_SOURCE */ |
| 48 | |
| 49 | #define	__HAVE_FP_PREC |
| 50 | |
| 51 | #endif	/* _NETBSD_SOURCE || _ISOC99_SOURCE */ |
| 52 | |
| 53 | #endif /* _M68K_IEEEFP_H_ */ |