1/*	$NetBSD: flt_rounds.c,v 1.5 2005/12/24 23:10:08 perry Exp $	*/
2
3/*
4 * Written by J.T. Conklin, Apr 11, 1995
5 * Public domain.
6 */
7
8#include <sys/cdefs.h>
9__FBSDID("$FreeBSD$");
10#if defined(LIBC_SCCS) && !defined(lint)
11__RCSID("$NetBSD: flt_rounds.c,v 1.5 2005/12/24 23:10:08 perry Exp $");
12#endif /* LIBC_SCCS and not lint */
13
14#include <fenv.h>
15#include <float.h>
16
17#ifdef	__mips_soft_float
18#include "softfloat-for-gcc.h"
19#include "milieu.h"
20#include "softfloat.h"
21#endif
22
23static const int map[] = {
24	1,	/* round to nearest */
25	0,	/* round to zero */
26	2,	/* round to positive infinity */
27	3	/* round to negative infinity */
28};
29
30int
31__flt_rounds()
32{
33	int mode;
34
35#ifdef __mips_soft_float
36	mode = __softfloat_float_rounding_mode;
37#else
38	__asm __volatile("cfc1 %0,$31" : "=r" (mode));
39#endif
40
41	return map[mode & 0x03];
42}
43