1 /* $OpenBSD: flt_rounds.c,v 1.5 2013/01/05 11:20:55 miod Exp $ */ 2 3 /* 4 * Written by J.T. Conklin, Apr 10, 1995 5 * Public domain. 6 */ 7 8 #include <sys/types.h> 9 #include <float.h> 10 11 /* 12 * Ported to 88k (Nivas Madhur) 13 */ 14 15 static const int map[] = { 16 1, /* round to nearest */ 17 0, /* round to zero */ 18 3, /* round to negative infinity */ 19 2 /* round to positive infinity */ 20 }; 21 22 int 23 __flt_rounds() 24 { 25 int x; 26 27 __asm__("fldcr %0, %%fcr63" : "=r" (x)); 28 return map[(x >> 14) & 0x03]; 29 } 30