| 1 | /*	$NetBSD: ieeefp.h,v 1.1 2001/01/10 19:02:06 bjh21 Exp $	*/ |
| 2 | /*- |
| 3 | * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995 |
| 4 | * Public domain. |
| 5 | */ |
| 6 | |
| 7 | #ifndef _MACHINE_IEEEFP_H_ |
| 8 | #define _MACHINE_IEEEFP_H_ |
| 9 | |
| 10 | /* Deprecated historical FPU control interface */ |
| 11 | |
| 12 | /* FP exception codes */ |
| 13 | #define FP_EXCEPT_INV	0 |
| 14 | #define FP_EXCEPT_DZ	1 |
| 15 | #define FP_EXCEPT_OFL	2 |
| 16 | #define FP_EXCEPT_UFL	3 |
| 17 | #define FP_EXCEPT_IMP	4 |
| 18 | |
| 19 | /* Exception type (used by fpsetmask() et al.) */ |
| 20 | |
| 21 | typedef int fp_except; |
| 22 | |
| 23 | /* Bit defines for fp_except */ |
| 24 | |
| 25 | #define	FP_X_INV	(1 << FP_EXCEPT_INV)	/* invalid operation exception */ |
| 26 | #define	FP_X_DZ		(1 << FP_EXCEPT_DZ)	/* divide-by-zero exception */ |
| 27 | #define	FP_X_OFL	(1 << FP_EXCEPT_OFL)	/* overflow exception */ |
| 28 | #define	FP_X_UFL	(1 << FP_EXCEPT_UFL)	/* underflow exception */ |
| 29 | #define	FP_X_IMP	(1 << FP_EXCEPT_IMP)	/* imprecise (loss of precision; "inexact") */ |
| 30 | |
| 31 | /* Rounding modes */ |
| 32 | |
| 33 | typedef enum { |
| 34 | FP_RN=0,			/* round to nearest representable number */ |
| 35 | FP_RP=1,			/* round toward positive infinity */ |
| 36 | FP_RM=2,			/* round toward negative infinity */ |
| 37 | FP_RZ=3			/* round to zero (truncate) */ |
| 38 | } fp_rnd_t; |
| 39 | |
| 40 | /* |
| 41 | * FP precision modes |
| 42 | */ |
| 43 | typedef enum { |
| 44 | 	FP_PS=0,	/* 24 bit (single-precision) */ |
| 45 | 	FP_PRS,		/* reserved */ |
| 46 | 	FP_PD,		/* 53 bit (double-precision) */ |
| 47 | 	FP_PE		/* 64 bit (extended-precision) */ |
| 48 | } fp_prec_t; |
| 49 | |
| 50 | #define fp_except_t	int |
| 51 | |
| 52 | /* Augment the userland declarations. */ |
| 53 | __BEGIN_DECLS |
| 54 | extern fp_rnd_t fpgetround(void); |
| 55 | extern fp_rnd_t fpsetround(fp_rnd_t); |
| 56 | extern fp_except_t fpgetmask(void); |
| 57 | extern fp_except_t fpsetmask(fp_except_t); |
| 58 | extern fp_except_t fpgetsticky(void); |
| 59 | extern fp_except_t fpsetsticky(fp_except_t); |
| 60 | __END_DECLS |
| 61 | |
| 62 | #endif /* _MACHINE_IEEEFP_H_ */ |