1/*	$NetBSD: flt_rounds.c,v 1.3 2005/06/12 05:21:26 lukem Exp $	*/
2
3/*
4 * Written by J.T. Conklin, Apr 10, 1995
5 * Public domain.
6 */
7
8#include <sys/cdefs.h>
9#if defined(LIBC_SCCS) && !defined(lint)
10__RCSID("$NetBSD: flt_rounds.c,v 1.3 2005/06/12 05:21:26 lukem Exp $");
11#endif /* LIBC_SCCS and not lint */
12
13#include <sys/types.h>
14#include <machine/float.h>
15
16static const int map[] = {
17	1,	/* round to nearest */
18	0,	/* round to zero */
19	2,	/* round to positive infinity */
20	3	/* round to negative infinity */
21};
22
23int
24__flt_rounds()
25{
26	int x;
27
28	__asm("st %%fsr,%0" : "=m" (*&x));
29	return map[(x >> 30) & 0x03];
30}
31