xref: /netbsd-src/lib/libc/arch/sparc/gen/flt_rounds.c (revision a5a68ff5f29de57339ca14f6c671c0a87714f1f8)
1 /*
2  * Written by J.T. Conklin, Apr 10, 1995
3  * Public domain.
4  */
5 
6 #include <sys/types.h>
7 #include <machine/float.h>
8 
9 static const int map[] = {
10 	1,	/* round to nearest */
11 	0,	/* round to zero */
12 	3,	/* round to negative infinity */
13 	2	/* round to positive infinity */
14 };
15 
16 int
17 __flt_rounds()
18 {
19 	int x;
20 
21 	__asm__("st %%fsr,%0" : "=m" (*&x));
22 	return map[(x >> 30) & 0x03];
23 }
24