Home | History | Annotate | Line # | Download | only in gen
fpsetround.c revision 1.5.44.1
      1  1.5.44.1      yamt /*	$NetBSD: fpsetround.c,v 1.5.44.1 2012/04/17 00:05:14 yamt Exp $	*/
      2       1.2  jonathan 
      3       1.1       jtc /*
      4       1.1       jtc  * Written by J.T. Conklin, Apr 11, 1995
      5       1.1       jtc  * Public domain.
      6       1.1       jtc  */
      7       1.1       jtc 
      8       1.3   thorpej #include <sys/cdefs.h>
      9       1.4     lukem #if defined(LIBC_SCCS) && !defined(lint)
     10  1.5.44.1      yamt __RCSID("$NetBSD: fpsetround.c,v 1.5.44.1 2012/04/17 00:05:14 yamt Exp $");
     11       1.4     lukem #endif /* LIBC_SCCS and not lint */
     12       1.3   thorpej 
     13       1.3   thorpej #include "namespace.h"
     14       1.3   thorpej 
     15       1.1       jtc #include <ieeefp.h>
     16       1.3   thorpej 
     17       1.3   thorpej #ifdef __weak_alias
     18       1.3   thorpej __weak_alias(fpsetround,_fpsetround)
     19       1.3   thorpej #endif
     20       1.1       jtc 
     21       1.1       jtc fp_rnd
     22  1.5.44.1      yamt fpsetround(fp_rnd rnd_dir)
     23       1.1       jtc {
     24       1.1       jtc 	fp_rnd old;
     25       1.1       jtc 	fp_rnd new;
     26       1.1       jtc 
     27       1.5     perry 	__asm("cfc1 %0,$31" : "=r" (old));
     28       1.1       jtc 
     29  1.5.44.1      yamt 	new = old & ~0x03;
     30  1.5.44.1      yamt 	new |= rnd_dir & 0x03;
     31       1.1       jtc 
     32       1.5     perry 	__asm("ctc1 %0,$31" : : "r" (new));
     33       1.1       jtc 
     34       1.1       jtc 	return old & 0x03;
     35       1.1       jtc }
     36