xref: /openbsd-src/lib/libc/arch/sparc64/gen/flt_rounds.c (revision af3276d5e32f3e939032c022c530ad02a9ed9a1e)
1*af3276d5Sguenther /*	$OpenBSD: flt_rounds.c,v 1.4 2015/10/27 05:54:49 guenther Exp $	*/
27e2260f1Sart /*	$NetBSD: flt_rounds.c,v 1.1 1998/09/11 04:56:23 eeh Exp $	*/
37e2260f1Sart 
47e2260f1Sart /*
57e2260f1Sart  * Written by J.T. Conklin, Apr 10, 1995
67e2260f1Sart  * Public domain.
77e2260f1Sart  */
87e2260f1Sart 
97e2260f1Sart #include <sys/types.h>
10fba30992Sderaadt #include <float.h>
117e2260f1Sart 
127e2260f1Sart static const int map[] = {
137e2260f1Sart 	1,	/* round to nearest */
147e2260f1Sart 	0,	/* round to zero */
1583e18f2bSmiod 	2,	/* round to positive infinity */
1683e18f2bSmiod 	3	/* round to negative infinity */
177e2260f1Sart };
187e2260f1Sart 
197e2260f1Sart int
__flt_rounds()207e2260f1Sart __flt_rounds()
217e2260f1Sart {
227e2260f1Sart 	int x;
237e2260f1Sart 
247e2260f1Sart 	__asm__("st %%fsr,%0" : "=m" (*&x));
257e2260f1Sart 	return map[(x >> 30) & 0x03];
267e2260f1Sart }
27*af3276d5Sguenther DEF_STRONG(__flt_rounds);
28