flt_rounds.c revision 1.2
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
9static 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
16int
17__flt_rounds()
18{
19	int x;
20
21	__asm__("st %%fsr,%0" : "=m" (*&x));
22	return map[(x >> 30) & 0x03];
23}
24