flt_rounds.c revision 1.3
11.3Sperry/* $NetBSD: flt_rounds.c,v 1.3 1998/01/09 03:15:12 perry 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.1Sjtc 3, /* round to negative infinity */ 151.1Sjtc 2 /* round to positive 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