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