1/*	$OpenBSD: flt_rounds.c,v 1.4 2015/10/27 05:54:49 guenther Exp $	*/
2/*	$NetBSD: flt_rounds.c,v 1.1 1998/09/11 04:56:23 eeh Exp $	*/
3
4/*
5 * Written by J.T. Conklin, Apr 10, 1995
6 * Public domain.
7 */
8
9#include <sys/types.h>
10#include <float.h>
11
12static const int map[] = {
13	1,	/* round to nearest */
14	0,	/* round to zero */
15	2,	/* round to positive infinity */
16	3	/* round to negative infinity */
17};
18
19int
20__flt_rounds()
21{
22	int x;
23
24	__asm__("st %%fsr,%0" : "=m" (*&x));
25	return map[(x >> 30) & 0x03];
26}
27DEF_STRONG(__flt_rounds);
28