1139825Simp/* 2139740Sphk * Written by J.T. Conklin, Apr 10, 1995 350974Swpaul * Public domain. 450974Swpaul */ 550974Swpaul 650974Swpaul#include <sys/cdefs.h> 750974Swpaul__FBSDID("$FreeBSD$"); 850974Swpaul 950974Swpaul#include <float.h> 1050974Swpaul 1150974Swpaulstatic const int map[] = { 1250974Swpaul 1, /* round to nearest */ 1350974Swpaul 3, /* round to zero */ 1450974Swpaul 2, /* round to negative infinity */ 1550974Swpaul 0 /* round to positive infinity */ 1650974Swpaul}; 1750974Swpaul 1850974Swpaulint 1950974Swpaul__flt_rounds(void) 2050974Swpaul{ 2150974Swpaul int x; 2250974Swpaul 2350974Swpaul /* Assume that the x87 and the SSE unit agree on the rounding mode. */ 2450974Swpaul __asm("fnstcw %0" : "=m" (x)); 2550974Swpaul return (map[(x >> 10) & 0x03]); 2650974Swpaul} 2750974Swpaul