flt_rounds.c revision 256281
1172301Spjd/* 2172301Spjd * Written by J.T. Conklin, Apr 10, 1995 3172301Spjd * Public domain. 4172301Spjd */ 5172301Spjd 6172301Spjd#include <sys/cdefs.h> 7172301Spjd__FBSDID("$FreeBSD: stable/10/lib/libc/ia64/gen/flt_rounds.c 132383 2004-07-19 08:17:25Z das $"); 8172301Spjd 9172301Spjd#include <float.h> 10172301Spjd 11172301Spjdstatic const int map[] = { 12172301Spjd 1, /* round to nearest */ 13172301Spjd 3, /* round to zero */ 14172301Spjd 2, /* round to negative infinity */ 15172301Spjd 0 /* round to positive infinity */ 16172301Spjd}; 17172301Spjd 18172301Spjdint 19172301Spjd__flt_rounds(void) 20172301Spjd{ 21172301Spjd int x; 22172301Spjd 23172301Spjd __asm("mov %0=ar.fpsr" : "=r" (x)); 24172301Spjd return (map[(x >> 10) & 0x03]); 25172301Spjd} 26172301Spjd