1 1.3 jonathan /* $NetBSD: flt_rounds.c,v 1.3 1997/10/18 02:43:06 jonathan Exp $ */ 2 1.2 jonathan 3 1.1 jtc /* 4 1.1 jtc * Written by J.T. Conklin, Apr 11, 1995 5 1.1 jtc * Public domain. 6 1.1 jtc */ 7 1.3 jonathan 8 1.3 jonathan #include <machine/float.h> 9 1.1 jtc 10 1.1 jtc static const int map[] = { 11 1.1 jtc 1, /* round to nearest */ 12 1.1 jtc 0, /* round to zero */ 13 1.1 jtc 2, /* round to positive infinity */ 14 1.1 jtc 3 /* round to negative infinity */ 15 1.1 jtc }; 16 1.1 jtc 17 1.1 jtc int 18 1.1 jtc __flt_rounds() 19 1.1 jtc { 20 1.1 jtc int x; 21 1.1 jtc 22 1.1 jtc __asm__("cfc1 %0,$31" : "=r" (x)); 23 1.1 jtc return map[x & 0x03]; 24 1.1 jtc } 25