xref: /netbsd-src/lib/libc/arch/mips/gen/flt_rounds.c (revision d48f14661dda8638fee055ba15d35bdfb29b9fa8)
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 #if defined(LIBC_SCCS) && !defined(lint)
10 __RCSID("$NetBSD: flt_rounds.c,v 1.5 2005/12/24 23:10:08 perry Exp $");
11 #endif /* LIBC_SCCS and not lint */
12 
13 #include <machine/float.h>
14 
15 static const int map[] = {
16 	1,	/* round to nearest */
17 	0,	/* round to zero */
18 	2,	/* round to positive infinity */
19 	3	/* round to negative infinity */
20 };
21 
22 int
23 __flt_rounds()
24 {
25 	int x;
26 
27 	__asm("cfc1 %0,$31" : "=r" (x));
28 	return map[x & 0x03];
29 }
30