xref: /netbsd-src/sys/arch/riscv/include/ieeefp.h (revision 35563434c42fdf6cfc592445e8dc7f23a65d90c0)
1*35563434Sskrll /*	$NetBSD: ieeefp.h,v 1.2 2020/03/14 16:12:16 skrll Exp $	*/
26cf6fe02Smatt 
36cf6fe02Smatt /*
46cf6fe02Smatt  * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995
56cf6fe02Smatt  * Public domain.
66cf6fe02Smatt  */
76cf6fe02Smatt 
86cf6fe02Smatt #ifndef _RISCV_IEEEFP_H_
96cf6fe02Smatt #define _RISCV_IEEEFP_H_
106cf6fe02Smatt 
116cf6fe02Smatt #include <sys/featuretest.h>
126cf6fe02Smatt 
136cf6fe02Smatt #if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE)
146cf6fe02Smatt 
156cf6fe02Smatt #include <riscv/fenv.h>
166cf6fe02Smatt 
176cf6fe02Smatt #if !defined(_ISOC99_SOURCE)
186cf6fe02Smatt 
196cf6fe02Smatt /* Exception type (used by fpsetmask() et al.) */
206cf6fe02Smatt 
216cf6fe02Smatt typedef int fp_except;
226cf6fe02Smatt 
236cf6fe02Smatt /* Bit defines for fp_except */
246cf6fe02Smatt 
256cf6fe02Smatt #define	FP_X_INV	FE_INVALID	/* invalid operation exception */
266cf6fe02Smatt #define	FP_X_DZ		FE_DIVBYZERO	/* divide-by-zero exception */
276cf6fe02Smatt #define	FP_X_OFL	FE_OVERFLOW	/* overflow exception */
286cf6fe02Smatt #define	FP_X_UFL	FE_UNDERFLOW	/* underflow exception */
296cf6fe02Smatt #define	FP_X_IMP	FE_INEXACT	/* imprecise (prec. loss; "inexact") */
306cf6fe02Smatt 
316cf6fe02Smatt /* Rounding modes */
326cf6fe02Smatt 
336cf6fe02Smatt typedef enum {
346cf6fe02Smatt     FP_RN=FE_TONEAREST,		/* round to nearest representable number */
356cf6fe02Smatt     FP_RP=FE_UPWARD,		/* round toward positive infinity */
366cf6fe02Smatt     FP_RM=FE_DOWNWARD,		/* round toward negative infinity */
376cf6fe02Smatt     FP_RZ=FE_TOWARDZERO		/* round to zero (truncate) */
386cf6fe02Smatt } fp_rnd;
396cf6fe02Smatt 
406cf6fe02Smatt #endif /* !_ISOC99_SOURCE */
416cf6fe02Smatt 
426cf6fe02Smatt #endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */
436cf6fe02Smatt 
446cf6fe02Smatt #endif /* _RISCV_IEEEFP_H_ */
45