flt_rounds.c revision 1.4
11.4Snakayama/*	$NetBSD: flt_rounds.c,v 1.4 2003/11/01 14:26:29 nakayama Exp $	*/
21.3Sperry
31.1Sjtc/*
41.1Sjtc * Written by J.T. Conklin, Apr 10, 1995
51.1Sjtc * Public domain.
61.1Sjtc */
71.1Sjtc
81.2Sthorpej#include <sys/types.h>
91.2Sthorpej#include <machine/float.h>
101.2Sthorpej
111.1Sjtcstatic const int map[] = {
121.1Sjtc	1,	/* round to nearest */
131.1Sjtc	0,	/* round to zero */
141.4Snakayama	2,	/* round to positive infinity */
151.4Snakayama	3	/* round to negative infinity */
161.1Sjtc};
171.1Sjtc
181.1Sjtcint
191.1Sjtc__flt_rounds()
201.1Sjtc{
211.1Sjtc	int x;
221.1Sjtc
231.1Sjtc	__asm__("st %%fsr,%0" : "=m" (*&x));
241.1Sjtc	return map[(x >> 30) & 0x03];
251.1Sjtc}
26