Home | History | Annotate | Line # | Download | only in gen
flt_rounds.c revision 1.2
      1  1.2  nakayama /*	$NetBSD: flt_rounds.c,v 1.2 2003/11/01 14:26:29 nakayama Exp $	*/
      2  1.1       eeh 
      3  1.1       eeh /*
      4  1.1       eeh  * Written by J.T. Conklin, Apr 10, 1995
      5  1.1       eeh  * Public domain.
      6  1.1       eeh  */
      7  1.1       eeh 
      8  1.1       eeh #include <sys/types.h>
      9  1.1       eeh #include <machine/float.h>
     10  1.1       eeh 
     11  1.1       eeh static const int map[] = {
     12  1.1       eeh 	1,	/* round to nearest */
     13  1.1       eeh 	0,	/* round to zero */
     14  1.2  nakayama 	2,	/* round to positive infinity */
     15  1.2  nakayama 	3	/* round to negative infinity */
     16  1.1       eeh };
     17  1.1       eeh 
     18  1.1       eeh int
     19  1.1       eeh __flt_rounds()
     20  1.1       eeh {
     21  1.1       eeh 	int x;
     22  1.1       eeh 
     23  1.1       eeh 	__asm__("st %%fsr,%0" : "=m" (*&x));
     24  1.1       eeh 	return map[(x >> 30) & 0x03];
     25  1.1       eeh }
     26