1132383Sdas/*
2132383Sdas * Written by J.T. Conklin, Apr 10, 1995
3132383Sdas * Public domain.
4132383Sdas */
5132383Sdas
6132383Sdas#include <sys/cdefs.h>
7132383Sdas__FBSDID("$FreeBSD$");
8132383Sdas
9132383Sdas#include <float.h>
10132383Sdas
11132383Sdasstatic const int map[] = {
12132383Sdas	1,	/* round to nearest */
13132383Sdas	3,	/* round to zero */
14132383Sdas	2,	/* round to negative infinity */
15132383Sdas	0	/* round to positive infinity */
16132383Sdas};
17132383Sdas
18132383Sdasint
19132383Sdas__flt_rounds(void)
20132383Sdas{
21132383Sdas	int x;
22132383Sdas
23132383Sdas        /* Assume that the x87 and the SSE unit agree on the rounding mode. */
24132383Sdas	__asm("fnstcw %0" : "=m" (x));
25132383Sdas        return (map[(x >> 10) & 0x03]);
26132383Sdas}
27