xref: /openbsd/lib/libc/arch/mips64/gen/flt_rounds.c (revision 8529ddd3)
1 /*	$OpenBSD: flt_rounds.c,v 1.3 2012/06/25 17:01:11 deraadt Exp $ */
2 /*
3  * Written by J.T. Conklin, Apr 11, 1995
4  * Public domain.
5  */
6 
7 #include <sys/types.h>
8 #include <float.h>
9 
10 static const int map[] = {
11 	1,	/* round to nearest */
12 	0,	/* round to zero */
13 	2,	/* round to positive infinity */
14 	3	/* round to negative infinity */
15 };
16 
17 int
18 __flt_rounds()
19 {
20 	int x;
21 
22 	__asm__("cfc1 %0,$31" : "=r" (x));
23 	__asm__("nop");
24 	return map[x & 0x03];
25 }
26