Home | History | Annotate | Line # | Download | only in gen
flt_rounds.c revision 1.1
      1  1.1  thorpej /*	$NetBSD: flt_rounds.c,v 1.1 1997/03/29 20:55:55 thorpej Exp $	*/
      2  1.1  thorpej 
      3  1.1  thorpej static const int map[] = {
      4  1.1  thorpej 	1,	/* round to nearest */
      5  1.1  thorpej 	0,	/* round to zero */
      6  1.1  thorpej 	2,	/* round to positive infinity */
      7  1.1  thorpej 	3	/* round to negative infinity */
      8  1.1  thorpej };
      9  1.1  thorpej 
     10  1.1  thorpej int
     11  1.1  thorpej __flt_rounds()
     12  1.1  thorpej {
     13  1.1  thorpej 	double tmp;
     14  1.1  thorpej 	int x;
     15  1.1  thorpej 
     16  1.1  thorpej 	asm("mffs %0; stfiwx %0,0,%1" : "=f"(tmp): "b"(&x));
     17  1.1  thorpej 	return map[x & 0x03];
     18  1.1  thorpej }
     19