1 1.1 cherry /* 2 1.1 cherry * Written by J.T. Conklin, Apr 10, 1995 3 1.1 cherry * Public domain. 4 1.1 cherry */ 5 1.1 cherry 6 1.1 cherry #include <sys/cdefs.h> 7 1.1 cherry /* __FBSDID("$FreeBSD: src/lib/libc/ia64/gen/flt_rounds.c,v 1.1 2004/07/19 08:17:24 das Exp $"); */ 8 1.1 cherry 9 1.1 cherry #include <float.h> 10 1.1 cherry 11 1.1 cherry static const int map[] = { 12 1.1 cherry 1, /* round to nearest */ 13 1.1 cherry 3, /* round to zero */ 14 1.1 cherry 2, /* round to negative infinity */ 15 1.1 cherry 0 /* round to positive infinity */ 16 1.1 cherry }; 17 1.1 cherry 18 1.1 cherry int 19 1.1 cherry __flt_rounds(void) 20 1.1 cherry { 21 1.1 cherry int x; 22 1.1 cherry 23 1.1 cherry __asm("mov %0=ar.fpsr" : "=r" (x)); 24 1.1 cherry return (map[(x >> 10) & 0x03]); 25 1.1 cherry } 26