Home | History | Annotate | Line # | Download | only in gen
fpsetround.c revision 1.3
      1 /*	$NetBSD: fpsetround.c,v 1.3 2002/01/13 21:45:45 thorpej Exp $	*/
      2 
      3 /*
      4  * Written by J.T. Conklin, Apr 11, 1995
      5  * Public domain.
      6  */
      7 
      8 #include <sys/cdefs.h>
      9 
     10 #include "namespace.h"
     11 
     12 #include <ieeefp.h>
     13 
     14 #ifdef __weak_alias
     15 __weak_alias(fpsetround,_fpsetround)
     16 #endif
     17 
     18 fp_rnd
     19 fpsetround(rnd_dir)
     20 	fp_rnd rnd_dir;
     21 {
     22 	fp_rnd old;
     23 	fp_rnd new;
     24 
     25 	__asm__("cfc1 %0,$31" : "=r" (old));
     26 
     27 	new = old;
     28 	new &= ~0x03;
     29 	new |= (rnd_dir & 0x03);
     30 
     31 	__asm__("ctc1 %0,$31" : : "r" (new));
     32 
     33 	return old & 0x03;
     34 }
     35