1/*	$OpenBSD: ieeefp.h,v 1.4 2011/03/23 16:54:36 pirofti Exp $	*/
2
3/*
4 * Written by J.T. Conklin, Apr 11, 1995
5 * Public domain.
6 */
7
8#ifndef _MIPS64_IEEEFP_H_
9#define _MIPS64_IEEEFP_H_
10
11typedef int fp_except;
12#define FP_X_IMP	0x01	/* imprecise (loss of precision) */
13#define FP_X_UFL	0x02	/* underflow exception */
14#define FP_X_OFL	0x04	/* overflow exception */
15#define FP_X_DZ		0x08	/* divide-by-zero exception */
16#define FP_X_INV	0x10	/* invalid operation exception */
17
18typedef enum {
19    FP_RN=0,			/* round to nearest representable number */
20    FP_RZ=1,			/* round to zero (truncate) */
21    FP_RP=2,			/* round toward positive infinity */
22    FP_RM=3			/* round toward negative infinity */
23} fp_rnd;
24
25#ifdef _KERNEL
26
27/*
28 * Defines for the floating-point completion/emulation code.
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/proc.h>
34#include <machine/fpu.h>
35
36#define	float_raise(bits) \
37	do { curproc->p_md.md_regs->fsr |= (bits) << FPCSR_C_SHIFT; } while (0)
38#define	float_set_inexact()	float_raise(FP_X_IMP)
39#define	float_set_invalid()	float_raise(FP_X_INV)
40
41#define	float_get_round(csr)	(csr & FPCSR_RM_MASK)
42#define	fpgetround()		float_get_round(curproc->p_md.md_regs->fsr)
43
44#endif
45
46#endif /* !_MIPS64_IEEEFP_H_ */
47