1178580Simp/*	$NetBSD: flt_rounds.c,v 1.5 2005/12/24 23:10:08 perry Exp $	*/
2178580Simp
3178580Simp/*
4178580Simp * Written by J.T. Conklin, Apr 11, 1995
5178580Simp * Public domain.
6178580Simp */
7178580Simp
8178580Simp#include <sys/cdefs.h>
9178580Simp__FBSDID("$FreeBSD: releng/10.3/lib/libc/mips/gen/flt_rounds.c 178580 2008-04-26 12:08:02Z imp $");
10178580Simp#if defined(LIBC_SCCS) && !defined(lint)
11178580Simp__RCSID("$NetBSD: flt_rounds.c,v 1.5 2005/12/24 23:10:08 perry Exp $");
12178580Simp#endif /* LIBC_SCCS and not lint */
13178580Simp
14178580Simp#include <machine/float.h>
15178580Simp
16178580Simpstatic const int map[] = {
17178580Simp	1,	/* round to nearest */
18178580Simp	0,	/* round to zero */
19178580Simp	2,	/* round to positive infinity */
20178580Simp	3	/* round to negative infinity */
21178580Simp};
22178580Simp
23178580Simpint
24178580Simp__flt_rounds()
25178580Simp{
26178580Simp	int x;
27178580Simp
28178580Simp	__asm("cfc1 %0,$31" : "=r" (x));
29178580Simp	return map[x & 0x03];
30178580Simp}
31