1 1.2 jonathan /* $NetBSD: flt_rounds.c,v 1.2 1996/09/16 18:10:42 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.1 jtc 8 1.1 jtc static const int map[] = { 9 1.1 jtc 1, /* round to nearest */ 10 1.1 jtc 0, /* round to zero */ 11 1.1 jtc 2, /* round to positive infinity */ 12 1.1 jtc 3 /* round to negative infinity */ 13 1.1 jtc }; 14 1.1 jtc 15 1.1 jtc int 16 1.1 jtc __flt_rounds() 17 1.1 jtc { 18 1.1 jtc int x; 19 1.1 jtc 20 1.1 jtc __asm__("cfc1 %0,$31" : "=r" (x)); 21 1.1 jtc return map[x & 0x03]; 22 1.1 jtc } 23