Home | History | Annotate | Line # | Download | only in gen
flt_rounds.c revision 1.1
      1  1.1  eeh /*	$NetBSD: flt_rounds.c,v 1.1 1998/09/11 04:56:23 eeh 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.1  eeh 	3,	/* round to negative infinity */
     15  1.1  eeh 	2	/* round to positive 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