flt_rounds.c revision 1.2
11.1Sjtc/*
21.1Sjtc * Written by J.T. Conklin, Apr 10, 1995
31.1Sjtc * Public domain.
41.1Sjtc */
51.1Sjtc
61.2Sthorpej#include <sys/types.h>
71.2Sthorpej#include <machine/float.h>
81.2Sthorpej
91.1Sjtcstatic const int map[] = {
101.1Sjtc	1,	/* round to nearest */
111.1Sjtc	0,	/* round to zero */
121.1Sjtc	3,	/* round to negative infinity */
131.1Sjtc	2	/* round to positive infinity */
141.1Sjtc};
151.1Sjtc
161.1Sjtcint
171.1Sjtc__flt_rounds()
181.1Sjtc{
191.1Sjtc	int x;
201.1Sjtc
211.1Sjtc	__asm__("st %%fsr,%0" : "=m" (*&x));
221.1Sjtc	return map[(x >> 30) & 0x03];
231.1Sjtc}
24