1 /* $OpenBSD: flt_rounds.c,v 1.1 2002/03/11 02:59:01 miod Exp $ */ 2 3 #include <sys/types.h> 4 #include <machine/float.h> 5 6 static const int map[] = { 7 1, /* round to nearest */ 8 0, /* round to zero */ 9 2, /* round to positive infinity */ 10 3 /* round to negative infinity */ 11 }; 12 13 int 14 __flt_rounds() 15 { 16 double tmp; 17 int x; 18 19 asm("mffs %0; stfiwx %0,0,%1" : "=f"(tmp): "b"(&x)); 20 return map[x & 0x03]; 21 } 22