flt_rounds.c revision 132383
117446Swollman/*
250476Speter * Written by J.T. Conklin, Apr 10, 1995
31638Srgrimes * Public domain.
4278202Sngie */
5278202Sngie
6174763Simp#include <sys/cdefs.h>
7174763Simp__FBSDID("$FreeBSD: head/lib/libc/ia64/gen/flt_rounds.c 132383 2004-07-19 08:17:25Z das $");
8168054Sflz
9168054Sflz#include <float.h>
10102065Sschweikh
11278202Sngiestatic const int map[] = {
12243890Seadler	1,	/* round to nearest */
13174763Simp	3,	/* round to zero */
1488055Sru	2,	/* round to negative infinity */
151638Srgrimes	0	/* round to positive infinity */
16278202Sngie};
17278202Sngie
18278202Sngieint
19278202Sngie__flt_rounds(void)
20278202Sngie{
211638Srgrimes	int x;
22
23	__asm("mov %0=ar.fpsr" : "=r" (x));
24        return (map[(x >> 10) & 0x03]);
25}
26